Linux Daily use commands/commonly used shortcut keys commands
Switch command
1. shutdown -h now: shut down immediately
2. shutdown -r now: restart the computer now
3. Reboot: Now restart the computer
4. su -: switch user; passwd: modify user password
5. logout: user logout
Common shortcut commands
1, tab = completion
2. ctrl + l -: clear the screen, similar to the clear command
3. ctrl + r -: search history command (history); ctrl+c = terminate
4. ctrl+k = delete everything from here to the end
5. ctrl+u = delete everything from here to the beginning
Common tool commands
man: help command
wc: text statistics
wordcount
3 5 29 a.txt
Number of lines Number of words Number of characters File name
Common parameters:
-l: only view the number of rows
-w: only view the number of words
-c: only view the number of characters
du: file size statistics
Format: du [option parameter] dir_path
Common parameters:
-s: only count the size of the file directory, not recursive
-h: Humanized display unit
find: file retrieval command
grammar
find judges path and expression according to the following rules. The first part before-(),! on the command line is path, and the following is expression. If path is an empty string, use the current path, if expression is an empty string, use -print as the default expression.
There are as many as 20 or 30 options available in expression, and only the most commonly used parts are introduced here.
-mount, -xdev: Only check files in the same file system as the specified directory, avoid listing files in other file systems
-amin n: has been read in the past n minutes
-anewer file: file that has been read later than file file
-atime n: files that have been read in the past n days
-cmin n: has been modified in the past n minutes
-cnewer file: file newer than file file
-ctime n: files that have been modified in the past n days
-empty: empty file -gid n or -group name: gid is n or group name is name
-ipath p, -path p: files whose path name matches p, ipath will ignore case
-name name, -iname name: The file whose name matches the name. iname ignores case
-size n: The file size is in units of n, b represents a block of 512 bytes, c represents the number of characters, k represents kilobytes, and w represents two bytes. -type c: The file type is c.
d: directory
c: Font device file
b: Block device file
p: named storage
f: General documents
l: symbolic link
s: socket
-pid n: file whose process id is n
You can use () to separate expressions and use the following operations.
exp1 -and exp2
! expr
-not expr
exp1 -or exp2
exp1, exp2
Instance
List all files with extension c in the current directory and its subdirectories.
# find. -name "*.c"
List all general files in the current directory and its subdirectories
# find. -type f
List all files in the current directory and its subdirectories that have been updated in the last 20 days
# find. -ctime -20
Find ordinary files in the /var/log directory whose change time is 7 days ago, and ask them before deleting them:
# find /var/log -type f -mtime +7 -ok rm {} \;
Find files in the directory where the owner of the file has read and write permissions, and users of the group to which the file belongs and other users have read permissions:
# find. -type f -perm 644 -exec ls -l {} \;
In order to find all ordinary files with a length of 0 in the system, and list their full paths:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.