chattr change the extended attributes of the file system, security is useful, usually do not.
lsattr display the extended attributes of a file
mode is +-[]
a append only append data to the file
[root @ localhost ~] # the chattr + A oldboy.txt [root @ localhost ~] # RM - f oldboy.txt RM : Can not delete " oldboy.txt " : do not allow the operation of [root @ localhost ~] #> Oldboy. TXT -bash: oldboy.txt: operation not permitted
File shackles i
[the root @ localhost ~] # the chattr - A oldboy.txt [the root @ localhost ~] # the lsattr oldboy.txt ------------- E- oldboy.txt [the root @ localhost ~] # the chattr + I oldboy.txt [the root @ localhost ~] # the lsattr oldboy.txt ---- -------- I E- oldboy.txt [the root @ localhost ~] #> oldboy.txt - the bash: Oldboy. txt: enough authority [root @ localhost ~] # RM - f oldboy.txt RM : Can not delete " oldboy.txt " : operation not permitted [root @ localhost~] # Echo hahahhaha >> oldboy.txt -bash: oldboy.txt: enough authority
chown change file users and groups
chown user file or directory
chown: User group file or directory
chown user. User group file or directory
[root@localhost ~]# chown :root test.txt [root@localhost ~]# ll test.txt -rw-r--r--. 1 oldboy root 327 9月 24 11:20 test.txt [root@localhost ~]# chown root test.txt [root@localhost ~]# ll test.txt -rw-r--r--. 1 root root 327 9月 24 11:20 test.txt
-R recursively, you can give a whole get rid of all the files in the directory
chmod change file directory permissions
Add suid sgid sticky bit chmod 4xxx chmod 2xxx chmod 1xxx
If that is the All-Canadian chmod 7xxx
After modifying permissions, if you want to delete a file, you need to look at the file level directory permissions on the corresponding
-R recursively
chmod option mode file
mode:+-=
r 4
w 2
x 1 – 0
[root@localhost ~]# chmod u+x test.txt [root@localhost ~]# ll test.txt -rwxr--r--. 1 root root 327 9月 24 11:20 test.txt [root@localhost ~]# chmod g=w,o=rwx test.txt [root@localhost ~]# ll test.txt -rwx-w-rwx. 1 root root 327 9月 24 11:20 test.txt [root@localhost ~]# chmod o-rwx test.txt [root@localhost ~]# ll test.txt -rwx-w----. 1 root root 327 9月 24 11:20 test.txt [root@localhost ~]# chmod 421 test.txt [root@localhost ~]# ll test.txt -r---w---x. 1 root root 327 9月 24 11:20 test.txt
chgrp Change User Group
cat view the file contents
[root@localhost ~]# cat test.txt 124567668 dfgjkllkjhvkl adsfkadsjf 1 2 3 4
cat tac read backwards and the opposite
4 3 2 1 adsfkadsjf dfgjkllkjhvkl 124567668
rev
[root@localhost ~]# echo 123456|rev 654321
more space to view the contents of the file scroll down a screen, b up, go down the carriage return, line by line, type an equal sign will display the current line number / search, q quit
There are more commands or options, plus digital display several lines of each specified
The less pager to view your files, easy to use than more, it can use the arrow keys
-N display file line number
After the display head header files (default ten lines) before the five elements of display -n 5 or directly cut Five -5 -n -5
tail end of the file is displayed (default ten lines) -5 show last five -f dynamic real-time display file contents tailf and tail -f does not matter, but the same function, real-time view
cut cut files and character
[root@localhost ~]# echo "I am shuaige my qq is 123456" >test.txt [root@localhost ~]# cat test.txt I am shuaige my qq is 123456
-b cutting text in bytes
[root@localhost ~]# cut -b 3 test.txt a [root@localhost ~]# cut -b 3-4 test.txt am [root@localhost ~]# cut -b -4 test.txt I am [root@localhost ~]# cut -b -4,4- test.txt I am shuaige my qq is 123456
-c character to cut (eight bytes a character, a Chinese character two bytes)
-d specified default tab delimiter is a delimiter
[root@localhost ~]# head -1 /etc/passwd root:x:0:0:root:/root:/bin/bash [root@localhost ~]# head -1 /etc/passwd | cut -d : -f4 0 [root@localhost ~]# head -1 /etc/passwd | cut -d : -f3 0 [root@localhost ~]# head -1 /etc/passwd | cut -d : -f2 X
Display tab key
[root@localhost ~]# vi test.txt [root@localhost ~]# cat test.txt this is tab line this is space line [root@localhost ~]# sed -n l test.txt this\tis\ttab\tline$ this is space line$ [root@localhost ~]# cut -f 2-3 test.txt is tab this is space line [root@localhost ~]# cut -d ' ' -f 2-3 test.txt this is tab line is space
This cut only supports a single delimiter