System O & M skills (I) -- chattr and lsattr commands

Source: Internet
Author: User

System O & M skills (1) -- chattr and lsattr commands we have the requirement that a file cannot be modified, deleted, or added only, so we can use the chattr command. [Plain] [root @ serv01 test] # cat note.txt 1. don't be late 2. do not leave early 3. do not smoke [root @ serv01 test] # chattr + I note.txt # root users cannot edit [root @ serv01 test] # vim note.txt [root @ serv01 test] # cat note.txt 1. don't be late 2. do not leave early 3. do not smoke # root users cannot delete and modify [root @ serv01 test] # rm-f note.txt rm: cannot remove 'note.txt ': operation not permitted [root @ serv01 test] # echo "this is test"> note.txt-bash: note.txt: Permission denied # ll view the file owner Can not be seen, you need to use lsattr to view [root @ serv01 test] # ll note.txt-rw-r --. 1 root 45 Sep 21 note.txt [root @ serv01 test] # lsattr note.txt ---- I -------- e-note.txt # It's only a relative concept that root users cannot modify, root users can modify file attributes, you can modify [root @ serv01 test] # chattr-I note.txt [root @ serv01 test] # lsattr note.txt ------------- e-note.txt [root @ serv01 test] # vim note.txt [root @ serv01 test] # cat note.txt 1. don't be late 2. do not leave early 3. do not smoke 4. don't come to work # Message Board: You cannot delete [root @ serv01 test] # vim note.txt [root @ serv01 test] # cat note.txt 1. don't be late 2. do not leave early 3. do not smoke 4. hello [root @ serv01 test] # chattr + a note.txt [root @ serv01 test] # lsattr note.txt ----- a ------- e-note.txt [root @ serv01 test] # vim note.txt [root @ serv01 test] # ls note.txt ~ Note. txy ~ Note. txz ~ # Delete the file and find that you do not have the permission [root @ serv01 test] # rm-rf * rm: remove regular file 'note.txt '? Y rm: cannot remove 'note.txt ': Operation not permitted [root @ serv01 test] # ls note.txt upload [root @ serv01 test] # echo "hello world"> note.txt-bash: note.txt: operation not permitted # Only content can be appended [root @ serv01 test] # echo "hello world"> note.txt [root @ serv01 test] # cat note.txt 1. don't be late 2. do not leave early 3. do not smoke 4. hello world [root @ serv01 test] # chattr-a note.txt [root @ serv01 test] # lsattr note.txt ------------- e-note.txt

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.