preface
First of all, let’s talk about why we need to learn this. A few days ago, WE encountered the problem of providing docker image. See here for details.
The current problem is solved, I know how to package the front-end code and deploy the Docker image, but I am reflecting, is this really the only knowledge I need to know about Docker? Compared with the tutor, I thought about it carefully, and it seems not to be. Knowing this content may be enough for now, but it will certainly not be enough in the future.
What does this have to do with the basic commands Linux uses?
I opened a docker teaching video with the most clicks on B website, and found that in a few minutes the teacher in the video said that learning Docker must have the basis of Linux basic commands. (Oh, life is not easy, I have to learn more and more, what can I do, learn.)
I thought I had never been exposed to the Linux command line at first, but as I learned, I found that I was wrong. I had been exposed to it in two places, but I had not studied it deeply. (While lamenting that my attitude towards knowledge learning was not thorough enough, I also lamenting that internship is the best learning for graduates.)
Why do you say that?
The reason is that before joining my current company, I worked as an intern in another company for five months. At that time, a very responsible backend guru taught me many things, including publishing projects with Xshell, and the commands used in Xshell are Linux commands.
Another contact is because the current company office for MAC, just converted from Windows to MAC really and not used to, interface, command what are different, now some of the most basic commands can be handy, the original is Linux command 😝
The Linux command line,
Shutdown shutdown
Shutdown [-t seconds] /[-r/k/h/n/c/f/ f] time [message]
- -r: Restart after shutdown
- – h is turned off
- Time Indicates the shutdown time
- The message for the information
The most commonly used
shutdown -r now
Immediately restartshutdown -h now
To turn it off
Change directory CD
Syntax: CD [path/directory name]
Commonly used:
cd ~
The Home directory is displayedcd /
Go to the root directorycd ..
Returns the upper directorycd a/b
Go to the A/B directory in the current foldercd /a/b
Go to the a/ B directory in the root directory folder, which is different from 👆🏻
View directory ls
Syntax: ls [-a/-l/-al]
- -a: All files, including hidden files
- -l: Lists attributes (similar to those on Windows disks)
- -al: hides files + attributes
Create a directory mkdir
Syntax: mkdir [path/filename]
mkdir a
Create file A in the current directorymkdir /b/a
Create file A in file B
Delete the rm
Syntax: rm [-rf] Directory/file
- -r: deletes a directory. Without -r, the directory will not be deleted
- -f: Ignores non-existent files
- -I: prompt/query
Example:
- Rm -rf a: Delete all contents of file A without asking (danger, caution)
- Rmkdir deletes an empty directory
Copy the cp
Syntax: cp [-r/ I /a] file name File replication target
- – I: prompt
- -r: copies all contents of a directory
- -a: The retention time of the newly copied file is the same as that of the original file
Move or change the MV
Syntax: target location/file name to which the MV file is clipped
- The second parameter, for example, directory: mv: move, for example, file name: mv: modify
Example:
mv a.txt b.txt
Rename the a.txt file to b.txtmv a.txt /b
Move the A.txt file to folder B under the root directory
Note 📢 : The first argument can be multiple files separated by Spaces
View file cat
Syntax cat file name
- The cat isOnce upon a time in the futureView the file. If tac is changed toFrom the back forwardTo view
Other view syntax:
- More: page by page display, only after the page
space
Turn the page down,Enter
Scroll down one line
- Less: page by page, backward and forward
- Turn pages by
pageup
andpagedown
Implementation, namely ⌨️ ↑ and ↓,space
Page down can also be realized
- Turn pages by
- Head: view only the first few lines.
Head file name [-n lines]
If the number of rows is negative, go from the back to the front - Tail: Just look at the last few lines
Note 📢 : After entering the editing mode, press q to exit the editing mode
Decompress/compress the tar command
Syntax: tar [-cfruxtzjzv] File name
- -c: Creates a new compressed file
- -f: specifies the compressed file
- -x: extracts files from the compressed package
- -z: supports gzip compression, -j: supports bzip2 compression, and -z: supports compress
- -v: displays the operation process
Commonly used:
Tar -zxvf File name
Unzip the filesTar -cvf Specifies the name of the file
The compressed file
conclusion
Linux a lot of operations, remember commonly used, other use of the time facing Baidu 🔍, if there is omission or error, welcome to leave a message ~