Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wish to hide files in Linux without using the dot, since it's possible in Windows.

Is there a way to do this?

share|improve this question
3  
Keep in mind hiding files (obfuscation) is not replacement for security (restricting access) –  uSlackr Nov 21 '11 at 15:32
add comment

5 Answers 5

You cannot. There is a fundamental difference in the way the file systems handle hidden settings. In Windows, the file system stores several attributes for the file in metadata, including the attributes "hidden" and "system" (both of which are kinds of hidden files). In common *nix filesystems, no such attribute is stored. Instead, the information must be put somewhere else, such as in the file name. The convention is thus that files beginning with . (and depending on your system, maybe some others like _) will not be shown by most tools by default.

This is purely for convenience, a . beginning a file name means absolutely nothing but "the user probably doesn't want to see this all the time." To make sure that you know, running e.g. ls -a will show all files.

If you don't want to have a file clutter up your listings in Linux, you should rename it to start with a dot (Bonus: this will work for OS X too, if we're talking about a portable device). If you don't want users to be able to find a file, you're doing it wrong - that's what permissions are for.

Unix permissions as they pertain to directories often confuse people, and maybe understanding it better will help you. The "read" and "execute" permissions (r and x) mean something different for directories than they do for files. For directories, the execute x permission determines whether or not you access the inodes in the directory. The read r permission dictates whether or not you can access the listing of the directory. Functionally, x allows the user to do things in a directory, while the r permission allows them to see what's in it. These are different, and the difference can be confusing. Let's look at an example:


jeanluc@login64: ~ $ mkdir example
jeanluc@login64: ~ $ echo "you can read it" > example/file
jeanluc@login64: ~ $ ls example/
file
jeanluc@login64: ~ $ cat example/file
you can read it

jeanluc@login64: ~ $ chmod -x example/
jeanluc@login64: ~ $ ls example/
ls: cannot access example/file: Permission denied
file
jeanluc@login64: ~ $ cat example/file
cat: example/file: Permission denied
jeanluc@login64: ~ $ cd example/
-bash: cd: example/: Permission denied

jeanluc@login64: ~ $ chmod +x example/
jeanluc@login64: ~ $ chmod -r example/
jeanluc@login64: ~ $ ls example/
ls: cannot open directory example/: Permission denied
jeanluc@login64: ~ $ cat example/file
you can read it
jeanluc@login64: ~ $ cd example/
jeanluc@login64: ~/example $ ls
ls: cannot open directory .: Permission denied
jeanluc@login64: ~/example $ cd ..

So, notice that without execute I can still list the files (although ls shows an error because it cannot get the file properties), but I can't change in to the directory or read the files in it. Without read I cannot list the files, but I can still change in to the directory and if I know the name of a file I can still access it.

Do note, though, that removing the read permission only gives you security by obscurity. If the user guesses the file name, they will be able to read its contents.

This may not have really been relevant to your question, I just wanted to make sure you understood directory permissions.

share|improve this answer
add comment

A dot is used to hide files in linux, and that can not be changed.

However, you could play with the file permissions to prevent users from being able to have access to given folder/file. Try experimenting with chmod command.

share|improve this answer
add comment

You can 'hide' the contents of a directory by taking away 'x' perms for the group, or other: chmod go-x directoryname. You could no longer list files, though you could access a file if you knew the exact path. This does not sound like what you want.

Keep in mind the dotfile thing is a convenience, not really to hide the file for security sake, but to reduce clutter for files during file listing. It's baked into ls and the other tools.

share|improve this answer
add comment

Are you only trying to hide files from your graphical user interface's file manager and/or desktop environment? If so, there might be options beyond simply prefixing the filename with a dot.

I believe the only additional files hidden by any Linux file manager are backup files, i.e. those ending in a tilde ~ or .bak or whatever they believe is the backup extension. In any case, you are probably in luck if all you wish to do is hide backup files from the file manager.

Do not give your files a backup extension to hide them or they might get accidentally deleted!!

As an aside, you can hide files from the Finder in Mac OS X using the command SetFile -a V [file] or editing /.hidden but obviously this won't hide the file from the command line's ls program.

share|improve this answer
2  
In OS X you can also hide files by chflags hidden filename. –  slhck Nov 21 '11 at 19:02
add comment

You can actually hide files in Linux without adding a dot. This actually hides then in Nautilus; an ls from the command line will still list the files.

  1. Create a text file named .hidden in the folder where you want to hide the files.
  2. Add the names of the files or folders you want to hide, one per line, to the file.
  3. Refresh your file browser.
share|improve this answer
1  
does not work here with "ls" in debian 5.0. Is it specific to nautilus or dolphin or ...? –  Tim Haegele Feb 4 '13 at 20:40
1  
Files are hidden in Nautilus; not in ls lists. –  To Do Feb 4 '13 at 21:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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