File and directory operations (40 commands)
1.ls
"Command Action" lists the contents of a file or directory
"Command Syntax" ls [options] [parameters]
"Common Options"
-C Multi-column displays the listed files and content (default option)
1 single-column display of listed files and directories
-a displays all files and directories including hidden (". "The files and directories that begin with are hidden)
-a displays all files and directories including hidden, but does not show '. ' and '. .‘‘ ('. ' means the current directory ': ' indicates the parent directory)
-l Display files and directories in long format (output information is file type, file permissions, number of hard links, owner, all groups, file size, file last modified time, filename)
-D Displays the directory and the file itself, usually in conjunction with '-l '
"Parameter description" file or directory
"Command Example"
Displays the contents of the current file or directory in a single column
Ls-1
Show all files or directories including hidden
Ls-a or Ls-a
Long format display
Ls-l
View the specified file or directory
Ls-ld file or directory
2.pwd
"Command action" to see your current path
"Command Syntax" pwd
"Command Example"
See where you are at your current path
Pwd
3.cd
"Command function" into the directory
command syntax CD [options] [parameters] (default to enter the home directory of the currently logged in user)
"Common Options"
Absolute or relative path to the parameter description directory (the absolute path is from the root directory to the destination file or directory, and the relative path starts from the current directory to the destination file or directory)
"Command Example"
Back to previous level
Cd. .
4.touch
"Command function" to create a file
"Command Syntax" Tuoch [options] (parameters)
"Common Options"
"Parameter description" Create file name
"Command Example"
Create a file called files
Touch file
5.echo
"Command function" prints the value of a variable
command syntax echo [options] (parameters)
"Common Options"
Parameter Description Print variables
"Command Example"
6.mkdir
"Command function" to create a directory
"Command Syntax" mkdir [options] (parameters)
"Common Options"
-P When the parent directory does not exist, you can create it together
Parameter description Create the name of the directory
"Command Example"
Create/test/1/,/test/not created
Mkdir-p/TEST/1
7.cp
"Command action" to copy a file or directory
"Command Syntax" CP [option] (parameter 1) (Parameter 2)
"Common Options"
-p Copy preserves the original permissions of the file
-R/R recursive replication, copying all directories or files under the source directory
Parameter Description parameter 1 is the source file (directory) name parameter 2 is the copied file (directory) name (the parameter can be written as an absolute path or a relative path)
"Command Example"
Rename file/1234 after copy to/4567 and retain original permissions
Cp-p/1234/4567
Copy all files in Directory/000 to a new directory called/999
Cp-r/000/999
8.mv
"Command action" to move a file or directory
"Command Syntax" MV [options] (parameter 1) (Parameter 2)
"Common Options"
Parameter Description parameter 1 is the source file (directory) name, parameter 2 is the moved file (directory) name (parameter can be written as absolute or relative path)
"Command Example"
Rename/1123 to/123
Mv/1123/123
9.rmdir
"Command function" Delete directory
command syntax rmdir[options] (parameters)
"Common Options"
-P deletes the specified directory if the parent directory of the specified directory is empty
"Parameter description" directory name (can write multiple, but space between directory names)
"Command Example"
When directory/1 is the only directory/2, delete them together
Rmdir-p/1/2
10.rm
"Command action" to delete a file or directory
command syntax rm [options] (parameters)
"Common Options"
-I ask the user when deleting (default option)
-R Recursive Delete, add this option to delete directory
-F Skip Query during delete (force delete)
"Parameter description" the file and directory name to delete (can write multiple, but a space between multiple files or directory names)
"Command Example"
Delete your Linux operating system directly
RM-RF/* ("*" means all files and directories)
11.nano
Text editor for "command function" of a character terminal
"Command Syntax" nano [options] (parameters)
"Common Options"
"Parameter description" file name
"Command Example"
Edit File/100
nano/100
12.vi/vim
"Command function" opens a file with VI or VIM editor (VIM is the most commonly used text editor in a Linux system)
"Command Syntax" Vi/vim [options] (parameters)
"Common Options"
"Built-in common commands"
ESC: Switching from edit mode to command mode
: line number: The cursor jumps to the line number of the specified line
DD: Deletes the cursor as it moves forward
NDD: Deletes the current line and its subsequent n-1 rows
YY: Copy when moving forward
Nyy: Copy the current row and its next n rows
P: Paste Text action
A: Add text after the current character
A: Add text at the end of A row
I: Inserting in the current word match either
I: Inserting at the beginning of the line
o: Insert after current line
O: Insert in front of the current line
: Wq: In command mode, save exit
: w: in command mode, save
: w! : In command mode, Force save (administrators can execute)
: Q: In command mode, exit
: q! : Forced exit in command mode
"Parameter description" the file name to create or open
"Command Example"
Open a file called/etc/23 with VI or VIM
VI/ETC/23 or VIM/ETC/23
13.shred
"Command function" re-writes random information to a file
"Command Syntax" shred [options] (parameters)
"Common Options"
"Parameter description" target file name
"Command Example"
Prevent someone from stealing a company's secrets by recovering deleted files/001来
shred/001
RM-F/001
14.cat
"Command function" to view the contents of a file
"Command Syntax" cat [options] (parameters)
"Common Options"
-N Adds the number of rows to the file contents
-B adds the number of rows to the contents of the file, not rows in blank lines
"Parameter description" file name
"Command Example"
View the contents of a file/etc/passwd and line up the content
Cat-b/etc/passwd
15.nl
"Command function" to view the contents of a file (default with line number)
"Command Syntax" NL [options] (parameters)
"Common Options"
"Parameter description" file name
"Command Example"
View the contents of the file/inittab
Nl/inittab
16.tac
"Command function" to view files in reverse order
"Command Syntax" TAC [options] (parameters)
"Common Options"
"Parameter description" file name
"Command Example"
To view the contents of/etc/inittab in reverse order
Tac/etc/iniittab
17.more
"Command function" text filter, full screen display of the File content by page, the display will show the percentage of the file that has been shown so far
"Command Syntax" more [options] (parameters)
"Common Options"
-< number > Specify the number of lines to display each time
+< number > Starting from the specified number of lines
-C to refresh the entire screen without scrolling on each page
"Built-in common commands"
Space: Show Next page
Enter: Show Next line
Q: Exit
"Parameter description" file name
"Command Example"
Start with more from line 10th of file/etc/inittab
More-<10>/etc/inittab
18.less
The "command function" is almost identical to the more, except that more can only be viewed down to the file content, but less may be seen up and down
"Command Syntax" less [options] (parameter)
"Built-in common commands"
Space: Show Next page
Enter: Show Next line
PageUp: Page Up
PageDown: Page Down
Q: Exit
"Common Options"
-e file automatically exits after display,
-N Each row shows the number of rows
"Parameter description" file name
"Command Example"
Use less to view the file/etc/inittab with line numbers and automatically exit after viewing
Less-en/etc/inittab
19.head
"Command Action" displays the number of lines at the beginning of the file, showing the first 10 rows by default
"Command Syntax" head [options] (parameters)
"Common Options"
-n< number > Specify the number of rows to display
"Parameter description" file name
"Command Example"
Show only the first 3 lines of the file/etc/inittab
Head-n<3>/etc/inittab
20.tail
"Command action" displays the end of a file
"Command Syntax" tail [options] (parameters)
"Common Options"
-n< number > Specifies the number of lines to display at the end of a file
"Parameter description" file name
"Command Example"
See the last 7 lines of file/etc/inittab
Tail-n<7>/etc/inittab
21.grep
"Command Function" filters the search filter in a file or directory to search for targets that match the parameters
"Command Syntax" grep [options] (parameter 1) (Parameter 2)
"Common Options"
-C calculates the number of columns that conform to the template
-D when you want a directory, you must add this option
-I ignores case
-V Reverse Lookup
-W displays only all-word compliant columns
-S does not display error messages
-P does not display any information
"Parameter description" parameter 1 filters the contents, parameter 2 searches the file or the directory
"Command Example"
Find a line that starts with a file/etc/inittab the non-sign #
Grep-v "#"/etc/inittab
Find the number of lines in the file/etc/inittab that begin with the # number
Grep-c "#"/etc/iniittab
22.cut
"Command Action" displays the content specified in the file
"Command Syntax" cut [options] (parameters)
"Common Options"
-B displays only the contents of the specified range
"Parameter description" files that need to be filtered
"Command Example"
View only the first 3 columns of the file/etc/passwd per line
Cut-b 1-3/etc/passwd
23.sort
Command function to sort the contents of a file output
"Command Syntax" cat [options] (parameters)
"Common Options"
-B ignores spaces at the beginning of each line
-n Sort by numeric size
-I sort in reverse order
"Parameter description" the file name that needs to be sorted
"Command Example"
Sort display the contents of a file/etc/passwd
sort/etc/passwd
24.tr
Command function can be used to replace, compress, and delete input characters
"Command Syntax" tr [options] (parameter 1) (Parameter 2)
"Common Options"
Parameter Description parameter 1 The original character set to be converted or to be deleted, no parameter 2 is required for deletion, and parameter 2 specifies the target character set to be converted
"Command Example"
echo "11111111" | TR "0-9" "A-Z"
bbbbbbbb
25.wc
"Command function" is used to calculate numbers
"Command Syntax" WC [options] (parameters)
"Common Options"
The number of bytes in the-C file
The number of columns in the-l file
-W File Count
"Parameter description" the file name that needs to be counted
"Command Example"
Calculate the total number of words in a/etc/inittab
Wc-w/etc/inittab
26.uniq
"Command function" to find or ignore duplicate rows in a file
"Command Syntax" Uniq [options] (parameters)
"Common Options"
-D Show only duplicate rows
-U displays only rows that are not duplicated
"Parameter description" the file name that needs to be filtered
"Command Example"
View duplicate and non-duplicated rows in File/001
UNIQ-D/001
Uniq-u/001
27.tee
"Command action" redirects data to a file
"Command Syntax" tee [options] [parameters]
"Common Options"
"Parameter description" specifies the output redirected file
"Command Example"
28.diff
"Command function" compares the differences of two files
command syntax diff [options] (parameter 1) (Parameter 2)
"Common Options"
-B does not check for whitespace characters
-B does not check for blank lines
-C Show the whole content and mark the difference
-I does not check for differences in case
Parameter Description parameter 1 The first file to compare
Parameter 2 The second file to compare
"Command Example"
diff file/1 differs from File/1.1
Diff-c/1/1.1
29.du
"Command function" to view disk usage space for files and directories
"Command Syntax" du [options] [file]
"Common Options"
-K output in kilobytes
-M output in megabytes
"Parameter description" the file or directory you need to view
"Command Example"
View disk usage space in MB for the file directory under the/root directory
Du-m/root
30.ln
"Command action" creates a soft connection (symbolic link) or hard link for a file
command syntax ln [options] (parameter 1) (Parameter 2)
"Common Options"
-D Create a hard link to a directory
-S creates a soft connection to the file
Parameter description parameter 1 source file parameter 2 target link file
"Command Example"
Soft Connect/etc/to/root/1/
Ln-s/etc//ROOT/1
31.type
"Command function" is used to determine whether the given instruction is an internal or external instruction.
"Command Syntax" type [options] (parameters)
"Judging Type"
Alias: Aliases
Keyword: key word, shell reserved word
Function: Functions, Shell functions
Builtin: Built-in command, Shell built-in command
File: Files, disk files, external commands
Unfound: Not Found
"Common Options"
"Parameter description" command to be judged
"Command Example"
Judging command ll
Type LL
32.file
"Command action" determines the type of file
"Command Syntax" file [options] (parameters)
"Common Options"
-C Display Instruction execution process
-B The file name is not displayed when the identification results are listed
"Parameter description" needs to determine the file name
"Command Example"
Determine the/var/www/html/index.html file type, showing the execution process
File-c/var/www/html/index.html
33.stat
"Command action" displays status information for a file
"Command Syntax" stat [options] (parameters)
"Common Options"
-F Displays File system status
-T output in a concise form
File name you need to see for "parameter description"
"Command Example"
To view the file system status of the root directory
Stat-f/
34.which
Command action displays the absolute path of the command
"Command Syntax" which [options] (parameters)
"Common Options"
"Parameter description" the command to find
"Command Example"
Find the absolute path to the command CD
which CD
35.whatis
Command function shows the function of a command
"Command Syntax" Whatis (Parameters)
"Common Options"
Commands for parameter description lookup
"Command Example"
Find the function of the command pwd
Whatis pwd
36.whereis
"Command function" looks for binary files, source code files and Help files for the specified program
"Command Syntax" Whereis [options] (parameters)
"Common Options"
-B Search binary files only
-M search only man document (Help file)
-S only search source code files
"Parameter description" the program that needs to be searched
"Command Example"
Find binaries for httpd
Whereis-b httpd
37.locate
"Command function" to find a file or directory
"Command Syntax" locate [options] (parameters)
"Common Options"
-I ignores case
"Parameter description" the characters in the file name you need to find
"Command Example"
Find files and directories starting with 00 in/etc
locate/etc/00
38.find
"Command function" locates files under the specified directory
"Command Syntax" find [options] (parameters)
"Common Options"
-name "template style": Specifying a string as a template for finding a file or directory
"Parameter description" find the starting directory of the file
"Command Example"
Find a file called passwd under/etc/
Find/etc-name "passwd"
39.help
"Command action" displays help for internal shell commands
"Command Syntax" help [Options] (parameters)
"Common Options"
"Parameter description" needs to help internal shell command
"Command Example"
40.man
Command function to open the Help document for the appropriate content
"Command Syntax" man [option] [number] (parameter)
"Common Options"
-A search in all man manuals
"Parameter description" digital man manual number
Keywords for parametric search Help
"Command Example"
Help Manual for opening man command
Man Mans
Collection of Linux system commands the first part