Display only hidden files in Linux. Learn how to show hidden files in terminal Ubuntu and how to show hidden folders in Linux command line.
Display the hidden files and directories
To display the hidden files and directories in Linux Ubuntu, use the ls -a command and joining the command with grep to show only the hidden files (all that start with a . (dot)). See below:
$ ls -a | grep "^\."
Once the command is executed it will only show the result which start with a dot (is hidden).
Note that whne you run the above command it is quite hard to tell which is file and which is the folder. To do so, you can see the hidden files and directories in the long listing format.
When you have the result in long listing format you can easily see which is a file and which is a directory.
To see hidden files and folders in long listing format, run the command:
$ ls -ld .*
Display Only Hidden Files
If you want to display only hidden files and do not wihc to see the hidden directories/folders, run the following command:
$ ls -ld .* |grep -v ^d
The ‘ls’ command lists information about files (of any type, including directories).
When you execute ls -a it looks in directories and it does not ignore file names that start with ‘.’.
‘-d’ is for directory and ‘-l’ is for long format or ‘–format=verbose’ where in addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and the modification time.