I'm trying to hide some files with some command, I tried the rm command, but it did not work and also tried to rename but did not understand how it works. The files that I want to hide have spaces in their names and I just want to put the dot in front of the names to let them hidden. Can anyone help me?

  • Post the command you used or an example of the files. In general, hiding the files is not considered to be overly secure. I suggest you use unique login for each user. See askubuntu.com/questions/46501/… . If that is not sufficient, honestly I suggest you use encryption. – Panther Nov 12 '13 at 19:04

Try this in the terminal

    $ for i in *
    > do
    > mv "$i" ".$i"
    > done

It hides all the files in the current directory. I hope that's what you're looking for. EDIT: Added the quotes around $i.

  • That will not work for files with spaces. You would need to quote the variable. Also the "*" is very non-specific. find is, IMO, a better tool. If all the files are in a single directory, why not just hide the directory? – Panther Nov 12 '13 at 19:07
  • It worked!. I put quotes in the variables "$i" ".$i" and it worked. Thank you. – Patterson Nov 12 '13 at 19:13
  • @PattersonSilva If an answer solves your problem, please accept it as the correct one by clicking the little tick mark next to the answer. – evilsoup Nov 12 '13 at 21:11
  • * is just an example. One could be more specific as well with something like *.py or you know, whatever criteria one has for hiding the files. – sayantankhan Nov 13 '13 at 3:10

You can use mmv:

mmv -v "*" ".#1"

Simple and to the point!

To un-hide them back:

mmv -v ".*" "#1"
rename 's/^/./' file1.txt 'file with spaces' 'third file.mkd'

You can of course use globs. The following will add a dot to the beginning of every file that ends with .txt:

rename 's/^/./' *.txt

Or you could hide every file beginning with foo and ending with .mkd:

rename 's/^/./' foo*.mkd

rename is using a substitute command: s/foo/bar/ replaces the first foo with bar. Instead of foo, you can also use a regular expression, and in regexes ^ means 'the beginning of the line'. So s/^/./ tells rename to 'replace the beginning of the line with a .'. That is: it places the dot before the first character.

You can also use the -n option to do a 'test run' -- with that, rename will not actually rename the files, but will list all the files that it would have changed, were you not using the -n flag.

rename -n 's/^/./' *.txt

To quickly hide all files of the current directory from display in Nautilus:

ls * > .hidden

This will create a list of hidden files in the file .hidden within the current directory. It will of course not hide these files on the command line, and if we chose to display hidden files from Nautilus they will show up again (as will . files).

To only hide a subset of files use appropriate wildcards, or edit the .hidden file with an editor.

To show all files again, just remove the .hidden file.


My prefered method is using "nautilus-hide" in "Nautilus-Actions-Extra" package:

sudo add-apt-repository ppa:nae-team/ppa
sudo apt-get update
sudo apt-get install nautilus-actions-extra nautilus-hide
nautilus -q

After selecting files/folders in Nautilus, choose (Un)Hide > Hide from the context menu.

This creates a file named ".hidden" containing a list of files/folders to be hidden.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.