[Linux] Review of commands for deploying on AWS

table of contents

--About Linux --Basic commands --Server settings --Process display --Combine multiple commands on the terminal

I wrote a review of Linux commands for deploying applications to production on AWS.

[About Linux]

I've used commands many times on my Mac, but I thought it was suspicious in the first place, so I read through it and relearned. Linux is one of the types of OS such as Mac, and is an OS (operating system) that is widely used for smartphones, web applications, routers, and so on. The OS is a basic program such as a PC. It has functions such as inputting characters when you hit the keyboard and operating the screen with a mouse. Other than Linux, there are Mac and Windows as OS.

Features of Linux ・ Open source (Public code can be used, modified, and reused by anyone) -Can be operated with commands, easy to automate and easy to operate the server ・ Some license fees are not incurred ・ Many compatible software allows you to use high-quality software.

Package manager This is a program that installs, updates, or removes new software. Execute it using the yum command. -Yum install package name (package installation) ・ Yum update (package update) -Yum erase package name (delete package) -Yum lis (lists installed)

[Basic commands]

When working with Linux, type in a terminal and run the command. The software that interprets the command entered at this time is called a shell.

ls command

A list of directories and files that are one of the current directories is displayed. (A directory is a folder) There are more directories and files under the directory, and it has a hierarchical structure. ・. (Dot) Current directory (currently working) ・ .. Parent directory (directory one level higher) ・ ~ Home directory (when a new terminal is launched) -/ Root directory (top directory in hierarchical structure)

cp command

This is a command to copy a file. cp file name (copy source) File name (copy destination)

mv command

This command is used when you want to rename or move a file. mv Original file name File name with new name mv File you want to move Destination directory

mkdir touch command

mkdir directory name (create a new directory one level below) touch file name (create new file)

cat command

This command displays and combines the contents of files. cat file name cat file name File name (3 files can be combined)

tail command

tail -f error.log This command is for checking the error log in a file called error.log. -f is an option added, and the error log will be displayed automatically whenever a new error occurs. To end the error log display, press Carl + C. vi You need an editor when you want to edit a file on the server. Software called vi is installed as standard on CentOS and Amazon Linux, so we will use this. To use it, first open the file. You can start it by typing the vi file name and terminal. If the specified file does not exist, a new one will be created. If created, the terminal will display the file name New File.

The vi editor has two modes. ・ Normal mode : W Save created and edited files : Q end vi command : Q! Quit the vi command without saving the edited content : Wq Save the edited content and exit the vi command

・ Insert mode Since you cannot enter characters in normal mode, switch to insert mode. Must be Press i to enter insert mode. Esc switches to normal mode.

/ Is used to search for strings in the vi editor. Enter the character string you want to search after /.

u (Undo) can erase one action that affected the file from the time the character is inserted until after it is inserted.

[Server settings]

Linux allows multiple users to work on one machine. Therefore, if there are files that you do not want other users to see, they may be viewed or edited.

Here we will write about users and permissions. ・ Root user You have view and edit permissions for everything, including other user files. ·General user Only permitted files can be viewed and edited.

The sudo command can execute commands on behalf of other users. You must be authorized to use sudo before you can do this.

The su command allows you to log in again as another user. You need to know the user's password before you can log back in.

Permission is permission information to allow who can operate a directory or file to what extent. For authority, ・ R Read (authority to see the contents of the file) -W write (authority to write to a file) -Execution x (permission to execute files) there is.

The user who created the file is called the owner, but if you do not want other users to edit it, you can give write permission only to the owner so that it will not be changed by other users.

If you want to check the permissions, ls -l You can check by entering the path of the file you want to check.

・ Chmod command It is a command to rewrite the access authority. chmod Privilege to give (r, w, x) Directory name or file name and input

・ Chown command A command to change the owner of a directory or file. chown owner directory name or file name and input

[Process display]

When building a server, you may need to check the commands you have executed. A process is a process that is processed by executing a command on Linux.

To see the process, run the ps command. When you run the command, you'll see a line-by-line process. Some ps command options are listed below.

-A Display processes of users other than yourself -R Show only running processes -U Username You can check the user name and the time of the executed process. · Aux Displayed with detailed information (CPU usage, etc.) for all running processes

[Combine multiple commands]

To combine multiple commands, use what is called pipe processing. For pipe processing, enter | (shift key + ) as shown below.

-First command executed | Command that receives the command processing on the left and returns the final result Display the list in the directory like ls | grep p Make ls finally display files containing the character p. The grep command is a command for extracting those that contain a specific character.

-Kill command By specifying the process id, you can terminate or forcibly terminate the process.

kill process id (process end) kill -9 process id (process kill)

I reviewed it because I often use command input to build an application environment on an EC2 instance. I will continue to study.

Recommended Posts

[Linux] Review of commands for deploying on AWS
[Linux] Review of frequently used basic commands 2
Summary of petit techniques for Linux commands
[Linux] Review of frequently used basic commands
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
Explanation of package tools and commands for Linux OS
Basic knowledge of Linux and basic commands
Completion of docker command on Linux
Convenient shortcut keys for Linux commands! !! !!
Frequently used Linux commands (for beginners)
[Must-see for beginners] Basics of Linux
List of frequently used Linux commands
pykintone on Windows Subsystem for Linux
Use Linux commands on Android devices
Linux (for users and su / sudo commands)
Linux commands
Linux commands
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
[Linux] Summary of middleware version confirmation commands
[Linux] List of Linux commands used in practice
linux commands
Basic usage of Btrfs on Arch Linux
[Linux] Learn the basics of shell commands
Linux commands
Linux commands
Including docker-nginx port forwarding on AWS Linux 2
[2020July] Check the UDID of the iPad on Linux
Start for free First AWS ② Start Linux virtual machine
(For myself) AWS_Flask_3 (Install / Run Flask on AWS)
[Linux command] A memorandum of frequently used commands
[AWS S3] Confirmation of the existence of folders on S3
Network Linux commands
Verbalize Linux commands
[Note] The story of setting up the SDK for Python of Azure IoT Hub on Linux
Review of exceptions
Linux user commands
New Linux commands! !!
Basic LINUX commands
pyenv for linux
Jupyter on AWS
Various Linux commands
Typical Linux commands (7)
[Linux] A list of Linux commands that beginners should know
Try compiling "Linux driver for Dual Sense of PS5"
Summary of Linux (UNIX) commands that appeared in Progate
Summary of useful tips for Linux terminals ☆ Updated daily
Procedure for manually installing Java (jdk1.8) on Linux (CentOS7)
Create a QR code for the URL on Linux
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Make your cursor a photo of your choice on Linux
Native playback of DSD sound source on Linux desktop
[AWS CLI] Enable the AWS CLI on Red Hat Enterprise Linux 8
A memo of installing Chainer 1.5 for GPU on Windows
A brief summary of Linux antivirus software for individuals
Memo of deploying Django × Postgresql on Docker to Heroku
Create an environment for MkDocs on Amazon Linux (attempted)
[Linux] Basics of authority setting by chmod for beginners
MySQL installation on Aws Linux 2 and test data preparation
Compile and install MySQL-python for python2.7 on amazon linux
Procedure for creating a Line Bot on AWS Lambda
[AWS EC2] How to install Maven on Amazon Linux 2