How To Create or Display Hidden Files / Folders in Linux

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

[[email protected] test]# touch .testfile.txt

Create multiple hidden files

[[email protected] test]#touch .file1 .file2 .file3

or

[[email protected] test]# vim .test.txt

How to create hidden directory

[[email protected] test]# mkdir .hiddndir

Display hidden files

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

[[email protected] test]# ls -a

. .. .DIR .hiddndir .test.txt

or

[[email protected] 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

[[email protected] 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:

[[email protected] test]# ls -A

.DIR .hiddndir .test.txt

or

[[email protected] 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

[[email protected] 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

[[email protected] test]# mv info.txt .info.txt

[[email protected] test]# mv nike .nike

[[email protected] 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

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.