Skip to content

Hidden files#

So far we've been looking at lists of files using ls -l and ls -lh. But check this out:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
michael@develop:~$ cd ~
michael@develop:~$ ls -la
total 32
drwxr-xr-x 4 michael michael 4096 Mar 18 10:05 .
drwxr-xr-x 4 root    root    4096 Mar 18 08:01 ..
-rw------- 1 michael michael  312 Mar 18 08:46 .bash_history
-rw-r--r-- 1 michael michael  220 Feb 25  2020 .bash_logout
-rw-r--r-- 1 michael michael 3771 Feb 25  2020 .bashrc
drwx------ 2 michael michael 4096 Mar 18 07:24 .cache
drwxrwxr-x 3 michael michael 4096 Mar 18 09:23 .local
-rw-r--r-- 1 michael michael  807 Feb 25  2020 .profile
-rw-r--r-- 1 michael michael    0 Mar 18 07:52 .sudo_as_admin_successful

Wow! That's more files than we had earlier. What's going on?

Notice how the file bash_history has a . in front of it, making it .bash_history? That signals to Linux that the file is to be considered a "hidden" file and simply does not show in normal file listing like ls or ls -l. Instead, we have to use the -a flag to get the invisible items.

We can even create our own hidden files: touch .my_secrets. The touch command is something you can look up using its manpage. Now we have another hidden file:

1
2
michael@develop:~$ ls
michael@develop:~$

Versus

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
michael@develop:~$ ls -la
total 32
drwxr-xr-x 4 michael michael 4096 Mar 18 10:11 .
drwxr-xr-x 4 root    root    4096 Mar 18 08:01 ..
-rw------- 1 michael michael  312 Mar 18 08:46 .bash_history
-rw-r--r-- 1 michael michael  220 Feb 25  2020 .bash_logout
-rw-r--r-- 1 michael michael 3771 Feb 25  2020 .bashrc
drwx------ 2 michael michael 4096 Mar 18 07:24 .cache
drwxrwxr-x 3 michael michael 4096 Mar 18 09:23 .local
-rw-rw-r-- 1 michael michael    0 Mar 18 10:11 .my_secrets
-rw-r--r-- 1 michael michael  807 Feb 25  2020 .profile
-rw-r--r-- 1 michael michael    0 Mar 18 07:52 .sudo_as_admin_successful

Now we can see the .my_secrets file is there.

Note

Please don't consider this is a security mechanism. It's not hiding the file from hackers or other people; it's simply marking the file as one to ignore in general file listings. Don't use it to hide actually sensitive information.

You'll use hidden directories and files from time to time.