1. File operation
- touch command
- Create a file. If the file name does not exist, create it directly. If it exists, change the access time
- touch [option] filename1 filename2...
root@ubuntu:~/Test# touch hello.c root@ubuntu:~/Test# ls hello.c
-
rm command: delete file or directory
- Parameter - r recursively delete subdirectories
- rm -rf * delete all contents in the current directory (mandatory deletion, use with caution)
-
cp and mv commands, equivalent to Windows platform copy and cut
- cp [option] srcpath despath
- Despath is a directory. Copy srcpath to the despath directory
- Despath is not a directory. Create a XXX file under... / in the superior directory (... / xxx) of despath, and copy the contents of srcpath
-
cat command
- Cat file name: display file information directly to the screen
-
more and less, display file information by screen
-
more:
- Enter line by line
- Space, page by page display
-
less:
- Enter or up and down arrow keys can repeatedly view the contents of the file
-
-
head and tail commands
- head view file header, default display 10 lines of content
- head -n the number of rows that can be specified
- tail view the end of the file, default display 10 lines of content
- -n can specify a function
- -f can trace the end of the file
- head view file header, default display 10 lines of content
2. Statistical information related
- wc command: the English word is word cout, which is the content of the statistics file
- -l) display line
- -w word
- -c bytes
root@ubuntu:~/Test# wc hello.c 8 10 91 hello.c root@ubuntu:~/Test# wc -l hello.c 8 hello.c root@ubuntu:~/Test# wc -w hello.c 10 hello.c root@ubuntu:~/Test# wc -c hello.c 91 hello.c
- df displays disk space information
root@ubuntu:~# df -h //File system capacity used% mount points available udev 973M 0 973M 0% /dev tmpfs 199M 9.0M 190M 5% /run /dev/sda1 21G 9.2G 11G 48% / tmpfs 992M 256K 992M 1% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 992M 0 992M 0% /sys/fs/cgroup tmpfs 199M 60K 199M 1% /run/user/1000
3. File permissions and user attributes
- Explain the corresponding fields
root@ubuntu:~/Test# ls -l //Total dosage 4 -rw-r--r-- 1 root root 91 10 Month 27 14:16 hello.c
-
-Represents the file type and d represents the directory file
-
rw - the permission of the user who has read and write permission
-
The group has read only permissions
-
r -- other user permissions, which are also readable only
-
We can also use octal digits to represent permission bits
- rw - --- > 110 --- > 6 user bits
- r -- - > 100 -- > 4 group permission bits
- r -- - > 100 -- > 4 other permission bits
- Finally, they are combined 0664
-
Oh, by the way, there is also a 1, which represents the count of hard links. There will be a command to demonstrate below
-
Create hard link - ln src des
root@ubuntu:~/Test# ln hello.c hello.c.hard root@ubuntu:~/Test# ls hello.c hello.c.hard root@ubuntu:~/Test# ln hello.c hello.c.hard1 root@ubuntu:~/Test# ls -l //Total dosage 12 -rw-r--r-- 3 root root 91 10 27 14:16 hello.c -rw-r--r-- 3 root root 91 10 27 14:16 hello.c.hard -rw-r--r-- 3 root root 91 10 27 14:16 hello.c.hard1
At this point, the hard link count changes to 3. When our hard link count changes to 0, the file will also be deleted
- Create a soft link -- ln -s file or directory
root@ubuntu:~/Test# ln -s hello.c hello.c.soft root@ubuntu:~/Test# ls -l //Total dosage 12 -rw-r--r-- 3 root root 91 10 Month 27 14:16 hello.c -rw-r--r-- 3 root root 91 10 Month 27 14:16 hello.c.hard -rw-r--r-- 3 root root 91 10 Month 27 14:16 hello.c.hard1 lrwxrwxrwx 1 root root 7 10 Month 27 14:43 hello.c.soft -> hello.c
- Remove soft and hard links: unlink
4. Change document authority
-
chmod command
- chmod [u|g|o|a] [+|-][r|w|x] filename
- Change the file permission in numerical way, for example: chmod 0664 main.c
-
chown and chgrp change users and change groups
- If the current user is not root, you need to use the administrator to modify the file ownership
- chown user: Group filename | directory
- chgrp group filename directory