Tag Archive: Chattr


The ‘Recent’ item under places in nautilus sidebar can be handy for accessing recent files on the system. However it can also be a privacy breach. There seems no easy setting to hide the ‘recent’ entry under places. Hiding the sidebar option will hide it completely. Here is a way to hide the ‘recent’ places under the file manager. Actually this does not hide the recent places, but does not allows any files to be listed there in the first place. After doing the following, you’ll see the ‘recent’ under places but there won’t be files listed in there.

The items shown under the recent are stored in a file which is dynamically modified as the user access the files over the system. Simply delete the file containing the recent items history using the following command.

$rm -rf ~/.local/share/recently-used.xbel

Now you’ll need to logout & relogin for changes to take effect. However this is only a one time solution. You’ll need to manually run this command from time to time to clear the recent items.

If you want to save this hassle, you can do the following changes to clear the recent items from not showing up at all. A permanent fix would be to first delete the above file. Now immediately before you open any of your documents(audio, video, text or any file), open a terminal & do the following.

$cd ~/.local/share/

$touch recently-used.xbel

$su

#chattr +i recently-used.xbel

That’s it & you’re done. Now ‘recent’ items under the sidebar will always be empty. To know more about the chattr command, read this post.

Regular users do not have permissions to alter files, however the super user can do any changes to the critical system files. For most of the times, one must avoid logging as a root user but at times one needs to login as a root user itself. Here, a small mistake could potential cause irreversible damage to the system. Take an example you are deleting a file & enter the following;

# rm -rf / etc/sysconfig/network-scripts/ifcfg-eth0:0

Noticed the space after ‘/’? That’s not intentional & it got mistyped in haste. Now, if the root user hits enter without correcting his mistake, it will lead to deletion of the entire root directory. You wouldn’t want that. However there is a simple command which prevents root user from deleting files or directories. You can set it on files or directories which you perceive to be important.

The command sets a certain attribute onto a file. These are special attributes over the regular file permissions. The attribute can be only set & unset by a root user.

# chattr +a filename

Now try doing,

# rm -rf filename

You will get,

rm: cannot remove ‘filename’ : Operation not permitted

You can do same on directories.

# chattr +a directory

This will also have an effect on the subsequent sub-directories in the specified directory. However, with the append(a) option, the file can still be altered using the append command. So to avoid that, use the immutable(i) switch instead of (a).

# chattr +i filename

The file can be now deleted nor written to(cannot be appended too).

To unset any of these attributes, simply use minus(-) along with the attribute you specified & file name/directory name.

# chattr -i filename

# chattr -a /directory/

Set this attribute on critical files & directories and you may avoid a potential doom’s day.

Follow

Get every new post delivered to your Inbox.

Join 81 other followers

%d bloggers like this: