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.
It seems to be an abbreviation for List Segments. It displays the files and directories in the current directory at once.
$ 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.
Abbreviation for Make Directory Literally a command to create a directory.
$ mkdir test_directory $ ls test_directory
It seems to be an abbreviation for Change Directory, This is a command to move the directory.
$ 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.
It seems to be an abbreviation for Positioning Work Directory. The command is to display the path of the current directory.
$ 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.
I think it stands for Remove. This is a command for deleting files.
$ 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.
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.
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
I don't know what it stands for. Lol This command displays the processes running on Linux.
$ 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.
$ 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
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.
$ 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.
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?
$ 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.
Abbreviation for Change Mode, a command that changes the permissions given to a file or directory.
$ 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.
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.
$ 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