I want to hide, most of the folders in root (/
) using Nautilus. Probably the only folders in /
I want shown are /home
and /tmp
.
In addition to hiding folders, I also want to hide two files: initrd.img
and initrd.img.old
.
I find such a setup to be pro-noob, and looks a lot slicker too. How can I hide those folders and files?
Tested under Nautilus 3.4.2 on Ubuntu 12.04/12.10 (but works in almost all scenarios)
Open
gnome-terminal
(Ctrl+Alt+T).Type
ls -1 /
.Copy the name(s) of the folder(s) you want hidden.
Press Alt+F2, then type in
gedit
.Paste all the names you want hidden like so:
Image excerpted from Another Way to Hide Files Folders in Ubuntu by Meilin
Save the file (Ctrl+S) in the directory
/
with the name.hidden
(no asterisk, as seen in the image above).Refresh the page, and they are gone.
Image from How to hide files and folders - EuroBytes
If you want them unhidden later...
To unhide the folders, you can either:
.hidden
file, orReference:
I doubt you can achieve this easily, this is either all or nothing in the unix model, and there is no permission for "seeing content of directory". Once you have enough access to read a directory, then you can read everything ( ie, the list of folder/files )
chmod o-r / could work for hiding all directories, but I do not recommend to do it without testing first on a vm, and fully understanding what you do.
Using a custom kernel module, you could hide folders, but that's rather complex and error prone.
This is an extension to @blade19899's answer
Motivation
Putting file names in
.hidden
file will hide them but nautilus only checks for exact matches. In some scenarios we want to hide files by pattern, not by exact names—for example I don't like to see latex aux files.Workaround
My workaround is to split the
.hidden
in two sections separated by a line of at least 5 equal signs (i.e.=====
). The patterns should be placed before this separator. Then, an script (see below) completes the file by adding exact filenames after the separator.In practice, you need to run this script manually to update the file with new matches. Maybe adding this file as a FilemanagerActions would be a good idea.
Script
Run with no arguments:
Latest version of the script: https://github.com/m2-farzan/dothidden-patterns/blob/main/refresh_dothidden.py
Example
Put this into
.hidden
file:Execute:
Updated
.hidden
file: