The Linux operating system has hundreds of files and folders hidden by default. Such files are called hidden files or dot files because they always start with the dot (.). Let’s explore how you can view 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. Generally, 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 good example .Gitignor A file used by Git to exclude certain files that are pushed to your remote repository.
Sometimes the concept of hidden files can be used to hide certain files from the prying eyes of the most advanced users.
Viewing Hidden Files with the ls command
The ls command is a widely used Linux command. In its simplest form, the command lists files and folders in a directory. However, ls does not list hidden files by default.
You should use it to show hidden files -A Option, which commands ls to list “all” files and folders (including hidden ones).
Navigate to your home directory with the cd command and make a list of all the files using ls.
As you can see, there are several files that start with dot (.). If you just run ls Command without -A The option does not include output hidden files.
If you do not have any hidden files in your home directory, you can create one using the touch command as follows:
You can also create hidden folders mkdir Command. You need to make sure you use the dot at the beginning of the folder name.
You can tell the ls command not to list a specific file or folder. For example, if you specify that you are in your home folder, you can run the following command to not list it. Desktop Directory in command output:
Finding Hidden Files Using Find
In addition to Ls, you can use the find command as an alternative way of listing hidden files and folders in Linux. The command that searches for files in the folder hierarchy searches.
To list or search all hidden files, you must specify the find command to list all the files that start with dot (.).
find . -name ".*" -maxdepth 1 2> /dev/null
Run the following command to search and list only hidden folders or directories:
find . -name ".*" -maxdepth 1 -type d 2> /dev/null
Viewing Hidden Files Using the GUI
You can also view files hidden from the GUI using your default file manager. GNOME’s files are the default file manager on the Ubuntu desktop. Previously, The Files The program was called Nautilus.
You can start files by pressing Great Type “files” in the key and the search input that appears later. Click the Files program and it will show files in the home folder by default.
By default, your file manager does not display all hidden files. Click on Menu The icon is in the upper right corner and select Show hidden files. Your hidden files and folders are now visible.
Alternatively, you can use the keyboard shortcut Ctrl + H To view hidden files on Linux as well.
Even if you can’t 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 to the hidden file.
Finding Files and Folders on a Linux System
If you are considering Linux as your daily driver, it is useful to know how to list and view all the files, including hidden files and folders. Dot files play an important role in the Linux operating system because they are commonly used to store configuration settings for programs.
In addition to files, the Find command effectively detects directories on Linux. But there are some flags and options you need to learn to do so.