How to view hidden files and folders on Linux
Let's explore how you can view these hidden files on your Linux system.
Why are there hidden files?
The concept of hidden files is simple but very important in Linux. Hidden files are mainly used to store configuration files or user settings. Typically, system services, scripts, or other programs use these files to store and read configurations.
For example, the .bash_logout script executes whenever you log out of your Bash session. Another great example is the .gitignore file , which is used by Git to exclude certain files from being pushed to your remote repository.
You can also use the concept of hidden files to hide certain files from the prying eyes of most non-expert users. A good example is the ~/.ssh directory or directory used to store SSH keys and configuration files.
View hidden files with 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 must use the -a option. This requires the ls command to list "all" files and directories including hidden files and directories, i.e. files that begin with a dot (.).
Navigate to your home directory with the cd command and check for hidden files using ls as follows:
ls -a
Output:
As you can see, there are some files that start with a dot. If you just run the ls command without the -a option, the output will ignore hidden files.
If you don't have any hidden files in your home directory, you can create one with the touch command as follows:
touch .sample_hidden_file.txt
You can also create hidden directories with the mkdir command. You just need to make sure you use a period at the beginning of the folder name. For example, to create a hidden folder named secret in your home directory, run the command:
mkdir ~/.secrets
You can tell the ls command not to list a certain file or directory. For example, if you are in your home directory, you can run the following command to unlist the Desktop directory in the command output:
ls --hide=Desktop
Find hidden files on Linux with the find . command
In addition to ls, you can use the find command as another way to list or check for hidden files and directories on Linux. The find command searches for files in the specified directory hierarchy.
To list or find all hidden files, you must ask the find command to list all files whose names start with a period (.).
find . -name ".*" -maxdepth 1 2> /dev/null
Run the following command to find and list only hidden folders or folders:
find . -name ".*" -maxdepth 1 -type d 2> /dev/null
View hidden files using the GUI
You can also view hidden files from the GUI using your default file manager. GNOME Files is the default file manager on Ubuntu. Previously, the file program was called Nautilus.
You can launch the file by pressing the Super key and then typing the file into the search input that appears. Click on the default Files program , the files in the Home folder will be displayed.
By default, your file manager does not show 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.
You can also use the keyboard shortcut Ctrl + H to view hidden files on Linux.
Although you can't view hidden files and folders by default, you can still interact with them just like any other normal file. In fact, at some point you may have to change the configuration in a hidden file.
Knowing how to list and view all files, including hidden files and folders, will come in handy if you use Linux every day. Dot files play an important role in the Linux operating system because they are often used to store configuration settings for programs.
In addition to files, the find command can also efficiently locate directories on Linux. But there are some flags and options that you will have to learn to do this.
You should read it
- How to Show Hidden Files and Folders on a Mac
- File Management in Unix / Linux
- How to hide files and folders on Windows / Linux / Mac OS X operating systems
- How to hide files, show hidden files, view hidden folders and file extensions on Windows 7/8/10?
- Restore hidden folders in Windows when infected
- How to show hidden files, hidden folders in Windows 10, Windows 7
- How to display protected operating system files in Windows 11
- How to create hidden folders on Windows 10
- How to Show Hidden Files in Windows 7
- How to synchronize files and folders on Linux
- Software to open hidden files in USB, computer
- How to Show Hidden Files in Linux
Maybe you are interested
9 ways to fix the error of not being able to save files as JPEG or PNG in Photoshop
How to use the file search command on Windows, find saved files
How to split sheet into multiple separate Excel files
How to merge PDF files, merge and join multiple PDF files into a single file
How to clean up iPhone junk, delete junk files to free up iPhone storage
Microsoft officially supports sharing files from iPhone to Windows using Phone Link application