1 Creating a directory/data
Mkdir-p/data
-p recursively create a directory to create a multi-level directory
2 tree Displays the table of contents in the shape of the trees
-L 1 shows how many layers are viewed only one level of directory
-D Show only directories
3 LS list lists contents in directory
-L Letter Long long format display details
-D View directory (treats directory as normal file)
-a show hidden information including hidden files
-F Add different flags to different files
-P only adds tags to directories, and other types of files regardless
-R Reverse Flashback display content
-t sort by file modification time
Ls-li Display the index node of the file
Ls-h is displayed in human form.
4 Entering the directory, changing the directory that is currently in use
Cd/data
CD-Back to last catalog
Cd. Current directory
Cd. . Return to the top level directory
CD ~ Current user's home directory
5 pwd Linux compass, show current location, print current working directory
6 Touch, create file (timestamp of modified file)
Touch-d "2016-3-13" + File name modification time of file
Touch-s time to modify the system
7 Vi/vim Vim Editor is a text editor
I/O Insert edit mode
ESC key goes to command mode again
: Wq Save Exit
W Write
Q quit
: Q! Force exit
: Set NU Displays line numbers when editing files in VI
: Set Nonu suppress line numbers
G to end of file
GG to the first line of the file
o Insert a blank line in the next line of the current row and enter edit mode
DG deletes the line of the cursor to the last line of the file
DD deletes the cursor in the row
D Delete cursor position to end of line
Dnd
P Paste
YY copy when moving forward
: 1,15COPY15 copy 1 to 15 rows
8 echo output to the screen
Note: single quotes, double quotes, and no quotation marks are the difference between
Parameter:-n does not output carriage return newline symbol
-E Open Escape symbol
Echo's Special use: Echo can also append multiple lines
Cases:
echo "123
321
456
654
Abc
CBA ">>/xinjia
Cat/xinjia
321
456
654
Abc
Cba
9 Cat Viewing file contents
(1) Multi-line Append
Cat >>/data/oldboy.txt<< EOF
I
Am
Oldboy
Linux
Eof
(2) cat-a displays all contents, including spaces
Cat-n Display Line numbers
CP copy copy files or directories can only copy files by default
-A =-PDR
-p copy files while keeping file attributes intact
-R recursive replication, directory and future generations
-T develop CP format first target cp-t target source
CP Copy file Format:
CP Source File Destination file
This article from "Xiao Xin" blog, declined reprint!
Linux Basic Command 1