How to Show Hidden Files in Linux

In this article, I will show you how to show hidden files and folders in Linux/Unix Operating Systems. Mostly our favorite 'ls' command doesn't display hidden files or folders in Linux.

If any file's name starts from '.' prefix (for ex: .test) then that will call as hidden file and 'ls' or 'll' command will not display these hidden files and directories in output. We use other options (-a) or (-A) with 'ls' and 'll' command. In linux, the hidden file's name started from '.' prefix. We can also hide already created files and directories.

How to show hidden files

We will use 'ls' and 'll' commands to show hidden files or directories with options (-a, -A)

$ ls -a

. .. .DIR .hiddndir .test.txt

or

$ ls -al

total 20
drwxr-xr-x. 4 root root 4096 May 3 18:59 .
drwxr-xr-x. 3 root root 4096 May 3 18:52 ..
drwxr-xr-x. 2 root root 4096 May 3 18:59 .DIR
drwxr-xr-x. 2 root root 4096 May 3 18:47 .hiddndir
-rw-r--r--. 1 root root 11 May 3 18:35 .test.txt

$ ll -a

total 20
drwxr-xr-x. 4 root root 4096 May 3 18:59 .
drwxr-xr-x. 3 root root 4096 May 3 18:52 ..
drwxr-xr-x. 2 root root 4096 May 3 18:59 .DIR
drwxr-xr-x. 2 root root 4096 May 3 18:47 .hiddndir
-rw-r--r--. 1 root root 11 May 3 18:35 .test.txt

'-a' displays hidden files and directories with current directory (.) and parent directory (..), and '-A' doesn't display current directory (.) and parent directory (..) as below:

$ ls -A

.DIR .hiddndir .test.txt

or

$ ll -A

total 12
drwxr-xr-x. 2 root root 4096 May 3 18:59 .DIR
drwxr-xr-x. 2 root root 4096 May 3 18:47 .hiddndir
-rw-r--r--. 1 root root 11 May 3 18:35 .test.txt

How to create hidden files

Just like regular files, we can create hidden files with touch command or vim tool.

Create a single hidden file

$ touch .testfile.txt

Create multiple hidden files

$ touch .file1 .file2 .file3

or

$ vim .test.txt

Create a hidden directory

$ mkdir .hiddndir

Hide already created file and directory

Let's see how to hide an existing file/directory

$ ll

total 4
-rw-r--r--. 1 root root 0 May 3 19:11 info.txt
drwxr-xr-x. 2 root root 4096 May 3 19:11 nike

let suppose we have already created file 'info.txt' and directory 'nike' and we will hide this file and folder as below

$ mv info.txt .info.txt

$ mv nike .nike

$ ll -A

total 12
-rw-r--r--. 1 root root 0 May 3 19:11 .info.txt
drwxr-xr-x. 2 root root 4096 May 3 19:11 .nike

Read Also:

Bobbin Zachariah 9:37 am

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.

Comments

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.