Command Basic Format
Command Prompt
First: Root
Second: Host name
~: Current directory (home directory)
#: Super User's prompt (Root permission)
$: Prompt for normal user
command Format command "Options" "Parameters"
Note: Individual commands do not follow this format
When you have multiple options, you can connect
The simplified option is the same as the full option-A and--all->
Options: Adjusting command functionality
Parameters: Selecting an Action object
File processing Commands File Directory Differences
Directory processing commands
Directories (folders): Saving files
Files: Saving data to create a directory
mkdir "Options" "Directory"
#mkdir: Make Directory
-P: Creating multi-tier files
-M: Create a custom permission file
attention: Build files do not write/test1/test2, we should all know/is the root directory, then if written in this way is to build files under the root directory, ordinary users do not have permissions ...
Touch "Options" "Document Name"
#建立一个空的文档;
#将某个文档日期修订为目前 (Mtime and Atime)-A: only change access time;
-C: Only modify the time, but not the establishment of documents;
-D: You can follow the date later, or you can use the-date= "date or time"
-M: Modify Mtime only;
-T: can be followed by time, formatted as "YYMMDDHHMM"
Atime File access time
CTime changing file properties
Mtime Modify File Contents
Switching Directories
CD "Options" "Directory"
#cd: Change Directory
#相对路径: Find by referencing the current directory.
#绝对路径: First-level recursive lookup specified from the root directory. In any directory, you can enter the specified location.: This level of directory
.. : Previous level Directory
-: Previous working directory
~: Home folder for current user status
: Back home Directory
Show current directory
PWD "Options"
#pwd: Print working directory
-P: Linked directories
File Content Lookup
Cat
# (view file contents directly)-A: You can list some special characters, not blank; ^t:tab $: Line feed
-B: List line numbers, blank lines do not show
-N: Print travel numbers, along with blank lines also have line numbers
The-t:tab key is displayed in ^i.
TAC
# (reverse display) from the last line to the first line on the screen # NL (add line number to print)
-b:-b A: Blank lines do not show line numbers
-B T: both display line numbers
-n:-n LN: On the leftmost display line number-n RN: On the rightmost line number, no +0
-N RZ: Displays the line number on the rightmost, +0
-W: Controlling the number of line number occupied digits
More "filename"
#可翻页查看 (one page flip)
Space: Next page return: Next line
/string: In this display, query down the "string" keyword
: F: Immediately display the filename and the number of rows currently displayed
Q: Exit
b or [Ctrl]-b: Previous page (operation only useful for files to pipe useless)
less "filename"
#可翻页查看 (one page flip)
Space: Next Page
[PageDown]: Next page
[PageUP]: Previous page
/string: Down query string functionality
? string: query string up function
N: Repeat previous action (related to/?)
N: Echo repeats previous action (with/? related)
Q: Exit Delete Directory
RmDir "Options" "Directory"
#remove Empty Directory
-P: Delete a multiple-layer empty file or it needs to be deleted at one level.
rm "Options" "Directory"
#rm: Remove
#删除文件或目录
-F: Ignore nonexistent file, no warning message
-I: Ask the user for action before deleting
-R: Deleting directory
Copy Directory
CP "original file or directory" "Target directory"
#cp: Copy
#1. Create a linked file (shortcut) 2. Update 3 for both files old and new. Copy Entire Directory
-R: Replicating directory
-P: Joint File property Copy
-D: If the source file is a linked file, copy the link properties
The-a:-pdr property is exactly the same as the original file "Ubuntur the default CP property is the same"
move or rename a directory
MV "original file or directory" "Target directory"
#mv: Move
#原文件和目标文件在同一个目录下: Renaming operation
Not in: Move action
-F: Mandatory, file if present, do not ask for direct overwrite
I: Will ask
-U: Target file exists and source is newer
Link Command
LN "original file" "Target file"
#ln: Link
#硬链接特征: Different doors of a file
1. Have the same I node and storage block blocks, can be considered as the same file
2. Can be identified by I node
3. Cannot cross partitions
4. Cannot be used for directory use
Disadvantages: Too much concealment + too many restrictions
#软链接特征: Similar with pointers
1. Similar Windows shortcuts
2. Soft link has its own I node drink block blocks, but the data block to save only the original file name and I node number, and no actual file data
3.lrwxrwxrwx L Soft Link
Soft link permissions are rwxrwxrwx
4. Modify any file, and the other changes
5. Delete the original file, soft link can not be used
#功能描述: Generating Linked files
Options:-S to create soft links
File Search Command Locate
locate "filename"
#在后台数据库中按文件名搜索, Faster search speed
#locate命令所搜索的后台数据库
#/var/lib/mlocate
#只能按文件名搜索 ...
I didn't find my new TEST3!!!. This is why.
Because the database is updated by default every day, you want to find this new file or find it tomorrow or force the database to be updated
Remember to update the database with root Oh ~
Find
Find "Search scopes" "Options" "Search Criteria"
#搜索文件
#避免大范围搜索, system resources are very expensive
#find是在系统当中所搜符合条件的文件名. If a match is required, wildcard matches are used and wildcard characters are exactly matched.
Wildcard characters
* Match any Content
。 Match any one character
[] Match any one of the characters in brackets
-iname: Case-insensitive
-user: Search by user
-nouser: Find files with no owner
#Linux系统一般都有使用者
#1. Garbage 2. Kernel file 3. foreign files
-mtime symbol N: Find files modified n days ago
#-10 10 days to modify the file
#10 Modify the file on the same day 10 days
#+10 10 days ago Modify file
#清垃圾, many days ago the useless things in the log
Find-size 25k: Find files with a file size of 25KB
#-25k files less than 25KB
#25k equals
#+25k Greater than
#k小写, MB uppercase
Find-inum 262422
#查找i节点是26422的文件
Find/etc-size +20k-a-size-50k
#查找/etc directory, files larger than 20KB and less than 50KB
-A and logic and, two conditions are satisfied
-O or logic or, two conditions to meet one can
Find/etc-size +20k-a-size-50k-exec ls-lh {} \;
#查找 the/etc/directory, files larger than 20KB and less than 50KB, and display detailed information
#exec/-ok command {}\; perform actions on search results
Whereis
whereis "Options" "Command name"
# can only check system commands, Shell Internal command cannot find the type used to determine if the command is inside the shell
#搜索命令所在路径及帮助文档所在位置
-B: Find only executable files
-M: Find only Help files
which
Which "command name"
#ubutnu下只查找可执行文件
#它只是在 the path specified in the $PATH environment variable, which is used to save the default search path for the executable file, to search the location of the executable file
Typically used to verify that the specified software is installed in the system
grep
grep "Options" "string" "filename"
#在文件当中匹配符合条件的字符串
-I: Ignore case
Help Commands Man help
Man "Command"
#获取指定命令的帮助
#man的级别
-F: See what level of command//equivalent to Whatis command
-k: Command//apropos command keyword (you can query only the parts of the command, as long as the included will appear)
Help helps
"Command"--help
#获取命令选项的帮助
#获取shell内部命令的帮助
Help "Shell internal Command"
#例如
#whereis CD
#确定是否是shell内部命令
#help CD
#获取内部命令帮助
detailed command Help info
Info "command"
-Enter: Go to Child help page (with * mark)
-U: Go to top page
-N: Go to the next Help section
-P: Go to the previous Help section
-Q: Exit
compression/Decompression Commands Common compression formats:
. zip. gz. bz2
. tar.gz. tar.bz2
. zip Format
Compression:zip "Options" "Compressed file name" "Source Files"
-R: Compressing directories
Decompression: Unzip "compressed file"
. gz format
Compression:
gzip Options Source files: compressed to. gz format compressed files, the source files will disappear
-C "source Files" > "Compressed Files": compressed to. gz format, source file retention
-R "Directory": Compressed all the subfolders under the directory, but cannot compress the directory
Decompression:
gzip-d "Compressed Files"
Gunzip "Compressed Files"
. bz2 format
#注意 bzip2 command cannot compress a directory
Compression:
bzip2 "Options" source files: compressed to. bz2 format, no source files preserved
-K: Keep source files after compression
Decompression
bzip2-d "Compressed Files": Decompression,-K preserves compressed files
BUNZIP2 compressed file: Decompress,-K Keep compressed file
. tar format
Packaged:
Tar "Options" "Packaged file name" "Source Files"
-C: Packing
-V: Displaying procedures
-F: Specifies the file name after packing
Solution Package:
-X: Unpack
-V: Displaying procedures
-F: Specifies the file name after packing
. tar.gz format
Compression:TAR-ZCVF "Compressed package name. tar.gz" "Source file"
-Z: Compress to tar.gz format
Decompression:TAR-ZXVF "Compressed package name. tar.gz" "Source file"
-X: Uncompressed to tar.gz format
. tar.bz2 format
Compression: TAR-JCVF "Compressed package name. tar.gz" "Source file"
-Z: Compress to tar.bz2 format
Decompression: TAR-JXVF "compressed package name. tar.gz" "Source file"
-X: Uncompressed to TAR.BZ2 format
#压缩多个文件直接空格写在后面 you can write an absolute path in front of this directory if you do not want to generate it. If you only want to see what's inside a compressed file and don't want to decompress, add-t
Shutdown and restart command shutdown Command
shutdown "option" "Time"
-C: Cancel previous shutdown command
-H: Shutdown
-R: Reboot
Other shutdown Commands
*halt
*poweroff
*init 0
Other Restart Commands
*reboot
*init 6
#
System run level (RunLevel)
0 off the machine
1 single users
2 not fully multi-user, no NFS services included
3 Full Multi-user
4 Not assigned
5 graphical interface
6 reboot
#/etc/inittab This file is no longer in Ubuntu. It's not an Ubuntu system that can be opened with a cat command. You can also modify the default settings on your own by running the above level.
Exit Login Command
Logout//To form the habit of quitting. Other common commands mount Command 1. Inquiry and Automatic mount: Mount
#查询系统中已挂载设备
Mount-a
#依据配置文件/etc/fstab content, automatic mount