The Linux operating system consists of hundreds of files and folders that are hidden by default. These files are called hidden files or dot files because they always start with a dot (.). Let’s explore how you can show these hidden files on your Linux system.
Why do we have hidden files?
The concept of hidden files is simple but very important in Linux. They are mainly used to store configuration files or user settings. Typically, these files are used by your system services, scripts, or other programs. For example, the .bash_logout The script is executed whenever you log out of your Bash sessions. Another great example is the .gitignore file used by Git to exclude certain files from being pushed to your remote repository.
Sometimes the concept of hidden files can be used to hide certain files from the prying eyes of mostly non-advanced users.
Showing hidden files with the ls command
The ls command is a widely used Linux command. In its simplest form, the command lists the files and folders in a directory. However, ls does not list hidden files by default.
To show hidden files you need to use the -a option, which commands ls to list “all” files and folders (including hidden ones).
Go to your home directory with the cd command and list all the files using ls.
As you can see, several files start with a dot (.). If you just run the ls order without -a option, the output will not include hidden files.
If you don’t have any hidden files in your home directory, you can create one using the touch command as follows:
You can also create hidden folders with the mkdir ordered. You just need to make sure to use the dot at the beginning of the folder name.
You can tell the ls command not to list a certain file or folder. For example, given that you are in your home folder, you can run the following command to not list the Desk directory in the command output:
Finding Hidden Files Using Finder
In addition to ls, you can use the find command as another way to list hidden files and folders in Linux. The find command searches for files in a hierarchy of folders.
To list or find all hidden files, you must explicitly tell the find command to list all files whose names begin with a period (.).
find . -name ".*" -maxdepth 1 2> /dev/null
Run the following command to find and list only hidden folders or directories:
find . -name ".*" -maxdepth 1 -type d 2> /dev/null
Showing Hidden Files Using the GUI
You can also show hidden files from the GUI using your default file manager. GNOME Files is the default file manager on Ubuntu Desktop. Previously the Files program was known as Nautilus.
You can launch Files by pressing the Great key and then typing “Files” into the search entry that appears. Click on the Files program and it will show the files in the default Home folder.
By default, your file manager does not show all hidden files. Click on the Menu icon located in the upper right corner and select Show hidden files. Your hidden files and folders will now be visible.
Alternatively, you can use the keyboard shortcut CTRL+H to also show hidden files in Linux.
Although you cannot view hidden files and folders by default, you can still interact with them like other normal files. In fact, at some point you may need to make configuration changes in a hidden file.
Finding Files and Folders on a Linux System
Knowing how to list and show all files, including hidden files and folders, is beneficial if you’re considering Linux as your daily driver. dot files play an important role in the Linux operating system as they are generally used to store configuration settings for programs.
In addition to files, the find command can also efficiently locate directories in Linux. But there are a few flags and options you’ll need to learn how to do.