Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux Commands: chattr command

Monday, June 21, 2021

Linux Commands: chattr command

 The chattr command in Linux is one of the more useful commands that you've probably used but have no idea what it's use is, it just works!  That's probably the most dangerous phrase in IT.  Well just from the command you can tell that controls the file modify attribute of the file.  Well not really I mean how is chattr related to file attributes.  I guess it's change attribute.  It's pretty easy to use + means to add an attribute, - means to remove an attribute, and = means you want to assign an attribute.  You can also add attributes with the -R option to reclusively on a directory.

One of the senario I used often is when I want to make a file immutable, I'll just type chattr +i filename.  For instance if I and setting a DNS server and I don't want the DHCP scripts to change the resolv.conf file every time I restart the NetworkManager.service I would just type chattr +i /etc/resolv.conf to make the file immutable.  If I try to modify the file I would get the following error message saying I can't modify the file.



It's just as easy to make it writable again, it would just be chattr -i /etc/resolv.conf

6 comments:

  1. Hello! This is my first visit to your blog! We are a group of volunteers and starting a
    new initiative in a community in the same niche. Your blog provided us
    valuable information to work on. You have done a marvellous
    job!
    스포츠토토티비

    ReplyDelete
  2. Excellent site you've got here.. It's hard to find high-quality writing like yours nowadays. 바카라사이트
    I seriously appreciate individuals like you! Take care!!

    ReplyDelete
  3. I’m not that much of a online reader to be honest but your sites really nice, 스포츠토토 keep it up!
    I’ll go ahead and bookmark your site to come back down the road.
    Cheers

    ReplyDelete
  4. I like the efforts you have put in this, appreciate it for all the great blog posts. 경마사이트

    ReplyDelete
  5. Nice information. I’ve bookmarked your site, and I’m adding your RSS feeds to my Google account to get updates instantly.
    파친코사이트

    ReplyDelete

Search This Blog