How To Create or Display Hidden Files / Folders in Linux

May 7, 2013 | By
| Reply More

Here we will discuss how to create and display 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. For this we use other options (-a) or (-A) with 'ls' and 'll' command. In linux hidden file's name started from '.' prefix. We can also hide already created files and directories.

Let starts from creating hidden files and folders

How to create hidden files

Just like regular files we can create hidden files with 'touch' and 'vim'. 'touch' will create new file and exit but vim create new file and open to modify.

Create single hidden file

[root@srv test]# touch .testfile.txt

Create multiple hidden files

[root@srv test]#touch .file1 .file2 .file3

or

[root@srv test]# vim .test.txt

How to create hidden directory

[root@srv test]# mkdir .hiddndir

Display hidden files

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

[root@srv test]# ls -a

. .. .DIR .hiddndir .test.txt

or

[root@srv test]# 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

[root@srv test]# 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:

[root@srv test]# ls -A

.DIR .hiddndir .test.txt

or

[root@srv test]# 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

Hide already created file and directory

[root@srv test]# 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

[root@srv test]# mv info.txt .info.txt

[root@srv test]# mv nike .nike

[root@srv test]# 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

Filed Under : FILE SYSTEM, LINUX HOWTO

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.