[Linux] List of Linux commands used in practice

List of Linux commands used in practice

Recently, I'm (probably) less doing things in the LAMP environment, I myself didn't really touch Linux commands very much.

I used it at best

cd
mkdir
rm
vim
ls

It was about.

It's rare to have an option. (Rm -rf, if any)

However, from March, when I was working as an engineer at a contract company, Well, Linux commands are used fairly normally. (Of course ... lol)

That's why I started to buy various things. I have summarized the Linux commands so that they can be used as memorandums.

ls

It seems to be an abbreviation for List Segments. It displays the files and directories in the current directory at once.

Execution result


$ ls
Application  Documents  Downloads  Library  Movies  Music
Pictures  Public

Personally, if you display it with the l option, it will be lined up vertically and the permissions of the file will also be displayed. It is an indispensable option that makes it easy to see and manages it as a list, and also for simple browsing.

mkdir

Abbreviation for Make Directory Literally a command to create a directory.

Execution result


$ mkdir test_directory
$ ls
test_directory

cd

It seems to be an abbreviation for Change Directory, This is a command to move the directory.

Execution result


$ cd test 
$ pwd
Users/User_Name/test

By the way, because you can't move to a directory that doesn't exist If you intend to create a directory Let's create a directory with mkdir first!

A common command is ".." to move to a directory one level higher. Just hit cd to get back to your home directory in one shot. If you make a mistake in moving the directory, press "cd-" to return to the previous directory.

pwd

It seems to be an abbreviation for Positioning Work Directory. The command is to display the path of the current directory.

Execution result


$ pwd
Users/User_Name/

That's it, but when working in a production environment etc. Did you move to the expected directory after moving with the cd command? It is used for confirmation such as.

rm

I think it stands for Remove. This is a command for deleting files.

Execution result


$ ls
test1.txt test2.txt test3.txt
$ rm test1.txt
$ ls
test2.txt test3.txt

You can delete the directory with the -rf option. By the way, you cannot delete the directory without adding it.

It was executed, but at the end, it will be deleted without any questions. Be careful when you are in a production environment.

mv

It's an abbreviation for move. As the meaning of move, move is a command to move files.

Here are some examples I often use: scp hoge fuga:~/ After transferring the file ...

$ cd var/www/html
$ mv fuga .
$ ls
fuga

I use it to move the transferred files.

The dot points to the "current directory (current location)", so move to the location you want to move first, Recently, I've been doing a lot of things like moving files by description.

cp

It's an abbreviation for copy. Needless to say, it is a command to copy files and directories.

The environment of the other party is old or old, If you have to connect and deploy with ssh, It is often used for the purpose of making a backup.

$ cp test.txt test.txt_back
$ ls
test.txt  test.txt_back

You can get a backup file like this.

However, in the case of the above purpose, basically the file or directory you want to copy already has If you do not keep the read / write authority and the owner as it is, the meaning as "backup" I wouldn't have it, but the solution is the -p option.

$ cp -p test.txt test.txt_back

In this way, the permissions, owner, and other time stamps originally set in test.txt, etc. It is not an exaggeration to say that it is essential when using cp because you can get a copy of the information as it is.

Also, when you get a backup file, you can add the date to the end of the file. It may be easier to manage later, but in that case you can add date +% Y% m% d.

$ cp -p test.txt test.txt_back`date +%Y%m%d`
$ ls
test.txt  test.txt_back20200414

With that feeling, it will schedule the day.

Also, if you want to copy the directory, the "-r" option is OK.

$ cp -r DIRECTORY MOVE_DIRECTORY

ps

I don't know what it stands for. Lol This command displays the processes running on Linux.

Execution result


$ ps
 PID TTY           TIME CMD
1989 XXXXXXX    0:00.03 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server

With the aux option, you can see more detailed and broader process information. The following commands are used in practice.

Execution result


$ ps aux| grep hoge
USER               PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
hoge     2336   0.0  0.0  4268212    540 s001  R+    1:21AM   0:00.00 grep root

grep

This guy that came out during the introduction of the ps command, It is a command to search and display a character string in a file using a regular expression.

Execution image


$ grep test DIRECTORY_NAME/*

When you type the above command, it will search the contents of the file in the directory DIRECTORY_NAME and The part with the word test is displayed on the console.

ssh

Type too many commands thanks to useful connection tools such as Teraterm and PuTTy I think that the image of connecting to a server is decreasing, but How is it actually?

Execution result


$ ssh hoge_server
hoge_server $

Basically, you need to enter the password and so on, but you can use this command to connect to another server. Also, the ssh connection information is stored in a file called ~ / .ssh / config. It is also possible to reduce the time and effort when connecting to ssh by describing it here.

chmod

Abbreviation for Change Mode, a command that changes the permissions given to a file or directory.

Execution result


$ chmod 777 test.txt

I don't think I use the 777 very much, You can change the authority for read / write execution.

By executing the ls command introduced earlier with the -l option, You can also check the authority mentioned here.

chown

Abbreviation for Change Owner, a command to change the owner of a file or directory.

Is it mostly a user or root? I think, Well, it's a command to change these.

Execution result


$ chown root:root

I wrote as much as I can remember.

Since there are many Linux commands and many options for each command, Hard to remember! You may think. ..

So it ’s not a production environment or a project test environment, In a local environment that does not completely affect the project I think it's a good idea to try moving it and remember it with your body.

I will do my best in the future. Lol

Recommended Posts

[Linux] List of Linux commands used in practice
List of frequently used Linux commands
[Linux] Review of frequently used basic commands 2
Summary of frequently used commands in matplotlib
[Linux] Review of frequently used basic commands
Frequently used Linux commands
Frequently used Linux commands
Frequently used linux commands
[Linux command] A memorandum of frequently used commands
[Linux] Command to get a list of commands executed in the past
[Linux] A list of Linux commands that beginners should know
List of nodes in diagrams
A collection of commands frequently used in server management
List of Python code used in big data analysis
Frequently used commands in virtualenv
Display a list of frequently used commands on Zsh
A memorandum of commands, packages, terms, etc. used in linux (updated from time to time)
8 Frequently Used Commands in Python Django
Linux Frequently Used Commands [Personal Memo]
Handle dates in Linux bash commands
[Linux] Frequently used Linux commands (file operation)
Frequently used Linux commands (for beginners)
Try compiling Linux commands (cross-compilation practice)
[Anaconda3] Summary of frequently used commands
[Linux] Frequently used Linux commands (folder operation)
Linux commands
Linux commands
linux commands
Linux practice
Linux commands
Linux commands
Verify the compression rate and time of PIXZ used in practice
[Understanding in 3 minutes] The beginning of Linux
Summary of methods often used in pandas
(Bad) practice of using this in Python
Disk-related commands often used in Ubuntu (memories)
[Linux] Summary of middleware version confirmation commands
Display a list of alphabets in Python 3
[Bash / linux] Notes in case of trouble
Summary of petit techniques for Linux commands
Summary of built-in methods in Python list
[Linux] Learn the basics of shell commands
[Machine learning] List of frequently used packages
[Python/Django] Summary of frequently used commands (4) -Part 2- <Production operation: Amazon EC2 (Amazon Linux 2)>
[Python/Django] Summary of frequently used commands (4) -Part 1- <Production operation: Amazon EC2 (Amazon Linux 2)>
[Python] Sort the list of pathlib.Path in natural sort
[Python/Django] Summary of frequently used commands (3) <Operation of PostgreSQL>
Network Linux commands
Verbalize Linux commands
List of frequently used built-in functions and methods
Summary of what was used in 100 Pandas knocks (# 1 ~ # 32)
A personal memo of Pandas related operations that can be used in practice
Utilization of recursive functions used in competition pros
Full disclosure of methods used in machine learning
Make a copy of the list in Python
Summary of tools used in Command Line vol.8
Linux user commands
List of main probability distributions used in machine learning and statistics and code in python
Summary of tools used in Command Line vol.5
New Linux commands! !!
Basic LINUX commands