- [Instructor] Hi and welcome to the fifth video
of section three; Making Files Immutable.
In the previous video, we've learned about working
with permissions, ownerships and the sticky bit.
Let's move on to the topic.
In this video, we'll see how to make files immutable
and make them mutable when required.
When a file is made immutable, any user or superuser
cannot remove the file until the immutable attribute
is removed from the file.
Making a file immutable is one of the methods for securing
files from modification.
An example would be to use it for the /etc/resolv.conf file
which stores a list of DNS servers.
A DNS server is used to convert domain names
such as packtpub.com to IP addresses.
However, some people prefer to use a third party server
and they can modify /etc/resolv.conf to point to that DNS.
However, the next time you get connected to your ISP
/etc/resolv.conf will revert back to point
to your ISP's DNS.
To prevent this, we can make it immutable.
The chattr command can be used to make files immutable.
In addition to this chattr has other useful options as well.
A file can be made immutable using the following command.
The file is therefore made immutable.
Now try the following command.
In order to make it writable,
remove the immutable attribute as follows.
Awesome, in this video we've successfully learned
about making files immutable.
Hope you enjoyed watching this video.
In the next video, we'll see
how to generate blank files in bulk.