1. File directory processing command
1. Directory processing commands;
(1) Command name: ls
The original meaning of the command in English: list
The path where the command is located: bin/ls
Execute permission: all users
Function description: Display directory files
Syntax: ls option [-ald] [file or directory]
-a show all files, including hidden files
-i show info display
-d View directory properties
-h humanize
Note: options can be followed by different options at the same time after '-'
-rw-r—r—
- Common file types that appear (- binary file d directory l soft link file)
-rw-r—r—
User/group/others
r read w write x execute
(2) Command name: mkdir
The original meaning of the command in English: makedirectories
The path where the command is located: /bin/mkdir
Execute permission: all users
Syntax: mkdir -p [directory name]
Function description: Create a new directory
-p recursive creation can be created continuously
Example: mkdir -p /tmp/Japan/boduo
mkdir /tmp/japan
Note: Directory creation has to make sense
(3) Command name: cd
The original meaning of the command in English: changedirectories
The path where the command is located: shell built-in command
Execute permission: all users
Syntax: cd + directory
Function description: direct search and switch directory
Example: cd /tmp/boduo
Note: . represents the current directory.. represents the previous directory
(4) Command name: pwd
The original meaning of the command in English: print workingdirectoriy
The path where the command is located: bin/pwd
Execute permission: all users
Syntax: pwd + directory
Function description: Display the current directory
Example: pwd /tmp/boduo
(5) Command name: rmdir
The original meaning of the command in English: remove emptydirectories
The path where the command is located: bin/rmdir
Execute permission: all users
Syntax: rmdir [directory]
Function description: delete empty directory
Example: rmdir /tmp/boduo
(6) Command name: cp
The original meaning of the command in English: copy
The path where the command is located: bin/cp
Execute permission: all users
Syntax: cp -rp[original file or directory][target directory (can be renamed directly)]
-r copy directory
-p preserve file attributes
Function description: Copy files or directories
(7) Command name: mv
The original meaning of the command in English: move
The path where the command is located: bin/mv
Execute permission: all users
Syntax: mv[source file or directory][target directory]
Function description: cut file or rename
(8) Command name : rm
The original meaning of the command in English: remove
The path where the command is located: /bin/rm
Execute permission: all users
Syntax: rm -rf + the directory to be deleted
-r delete directory
-f delete file (force delete, don't ask)
Function description: delete files
CTRL+c to terminate this operation, be careful not to delete it by mistake
Two: file processing command
(9) Command name: touch
Note: If no path is added, it will be placed in the current file
Linux is a valid filename except "/"
If you add a file and a space after touch , you actually create two files, forexample : programfiles actually creates two files, if you create one file, you need to add double quotes "program files"
The path where the command is located: /bin/touch
Execute permission: all users
Syntax: touch[filename]
Function description: Create empty file
Example: touchJapanlovestory.list
(10) Command name: cat
The path where the command is located: /bin/cat
Execute permission: all users
Syntax: cat[filename]
Function description: Display file content
-n show line numbers
Example: cat -n /etc/services
(11) Command name : tac
The path where the command is located: usr/bin/tac
Execute permission: user used
Syntax: tac[filename]
Function description: Display file content (reverse column format)
Example: tac/etc/issue
(12) Command name: more
The path where the command is located: bin/more
Execute permission: all users
Syntax: more [filename]
- (space) or f to turn the page
- (enter) newline
- Q or q to quit
(13) File processing command: less
The path where the command is located: /usr/bin/less
Execute permission: all users
Syntax: less [filename]
Function description: Paging display the file content ( more multi-function can turn up the page pageup page up , " up arrow " to new line up, you can search for keywords "/ add keywords ", n ( next ) can then search down the pan white display )
Example: less/etc/services
(14) Command name: head
The path where the command is located: /usr/bin/head
Execute permission: all users
Syntax: head[filename]
Function description: Display the first few lines of the file
-n specifies the number of lines to see the first seven lines -n 7 displays the first ten lines by default
Example: head -n20/etc/services
(15) Command name : tail
Function description: Display the following lines of the file
-n specifies the number of lines
-f Dynamically display the content at the end of the file ()
Example: tail -f /var/log/messanges
Ifconfig sets the network card Ip address
(16) Link command: link
The original meaning of the command in English: link
The path where the command is located: /bin/ln
Execute permission: user used
Syntax: ln -s [source file][target file]
-s create soft link
Function description: Generate link file
example:
ln -s/etc/issue /tmp/issue.soft
Create a soft link to the file /etc/issue /tmp/issue.soft()
ln /etc /issue /tmp/issue.hard
Create a hard link /tmp/issue.hard to the file /etc/issue
Soft link features: similar to Windows shortcuts
Permissions are determined by the original file
1. Lrwxrwxrwx starts with high permissions and can be used by all users
2. File size: just symlinks
3. Hard links do not have arrows pointing to
Hard Link Features:
1. Like copy cp-p + synchronous update ( cp does not have this function)
The original file can still be opened if the hard link is lost
2. Through i - node identification, i -node can have only one i- node for each file for multiple files
3. Cannot cross partitions (soft connections can)
4. Cannot be used for directories
2. Privilege management commands
1.chmod
English original meaning: change the permission mode of a file
The path where the command is located bin/chmod
Execute permissions for all users
Syntax: chmod [{ugoa}{+-=}{rwx}[file or directory]
Used when doing multiple authorizations, separated
Function description Change file or directory permissions Permissions can only be granted to root or administrator
1. Digital representation of permissions
r 4
w 2
X 1
For example rwxrw-r--
764
chmod digital file
2. Changing the permissions of the current directory will not change his subdirectories
-R recursive modification can change their permissions
useradd creates a normal user
Files created by root can also be deleted by other users
$ stands for normal user
w write permission can modify the content of the file can create and delete files in the directory
x execute permission can execute the file can enter the directory
file
r:cat/more/head/tail/less //These are read permissions
w:vim
x:script command
dictionary
r: ls
w:touch/mkdir/rmdir/rm
x: cd
The prerequisite for deleting a file is to have write permission to the directory where the file is located.
If you have r permission, you must have x permission
2. chomn
The original meaning of the command in English: change file ownership
The path where the command is located: bin/chown
Execute permission: all users
Syntax: chown [user][file or directory]
Description: Change the owner of a file or directory
Example: $chownshen temp
Change the owner of the file temp to shen
3.chgrp
The original meaning of the command in English: changefile group ownership
The path where the command is located: bin/chgrp
Execute permission: all users
Syntax: chgrp[usergroup][file or directory]
Function description: Change the group of a file or directory
Example: $chgrplambrother fengjie
Change fengjie's group to lambrother
Add the group the file belongs to groupadd
Whoever creates the file is the owner of the file, and the group of each file is the owner's default group
4.umask
The original meaning of the command in English: the userfile-creation mask
Command path: shell built-in command
Execute permission: all users
Syntax: umsk[-S]
-S Displays the default permissions of new files in the form of rwx
Function description: Display the default permissions of the settings file
Example $ umask -S
All are rwxr-x . If you enter umask directly , it will come out 0022 0 is the special permission 022 ----w--w- permission mask 777-022 is the default permission value
If you want permissions to be created every time after
r --that is, 754 can use umask [777-754]
The default is 755. Any new file in Linux will remove the executable file permission ( x ) The directory has more executable permissions than the file.
3. File search command
Try to reduce the search command because it takes up a lot of space, the smaller the search range, the better
Windows everthings software search tool works great
1.find
Command name: find
The path where the command is located: bin/find
Execute permission: all users
Syntax: find [search scope] [match condition]
Search by what; size; time attribute
Function description: file search
1.find /etc -name init
Find the file init in the directory /etc (exact search) If you want a fuzzy search you should find /etc -name*init*
find /etc -name init??? means to find files with three characters after the file name init (regular expression)
-iname is not case sensitive
2.find / -size +204800
Find files larger than 100M in the root directory, a data block of 512 bytes, 0.5k 1k is two data blocks
+n is greater than -n is less than n is equal to
3.find /home -user zhang
Find files with owner shencaho in the root directory
-group Find according to the group you belong to
4. Find by time attribute
find /etc -cmin -5
Find files and directories whose attributes have been modified within 5 minutes under /etc. More than 5 minutes +5
-amin access time
-cmin file attribute change
-mmin file content modify
-a both conditions are met at the same time and
-0 two conditions satisfy an or
find /etc -size +163840 -a -size -204800
Find files larger than 80M and smaller than 100M under /etc
-type Find by file type
f file d directory l soft link
$find/etc -name inittab -exec ls -l {} \;
-exec/ok command{} \; operate on search results
-inum Find according to i-node (different i-node for each file, same hard-link i-node)
2.locate
The path where the command is located: /usr/bin/locate
Execute permission: all users
Syntax: locate filename
Function description: Find files in file data
Example: $locateinittab
Use updatedb to update the file database, and then use locate to find it. The files in /tmp cannot be found with locate because they are not included.
3.which
Command name: which
The path where the command is located: /usr/bin/which
Execute permission: all users
Syntax: which command
Function description: Search command directory and alias information
Example: which ls
where is can view the help documentation
4.grep
The path where the command is located: /bin/grep
Execute permission: all users
Syntax: grep -iv specifies the string file
Function description: Search the file for the line matching the string and output
-I is not case sensitive
-v exclude the line where the specified string is located
Example: #grep mysql/root/isntall.log
# means comment ^# means remove the line starting with #