close
close

How to show hidden files and folders on Linux

The Linux operating system consists of hundreds of files and folders that are hidden by default. Such files are called hidden files or dot files because they always start with a dot (.). Let’s explore how to 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. Usually these files are used by your system services, scripts or other programs. For example the .bash_logout The script runs whenever you log out of your bash sessions. Another great example is the .ignore.git File used by Git to exclude specific files from being pushed to your remote repository.

MAKEUSEOF VIDEO OF THE DAY

Sometimes the concept of hidden files can be used to hide specific files from the prying eyes of mostly non-advanced users.

Show hidden files with ls command

The ls command is a widely used Linux command. In its simplest form, the command lists files and folders within a directory. However, ls does not list hidden files by default.

To show hidden files you need to use the -a Option that tells ls to list “all” files and folders (including hidden ones).

Use the cd command to navigate to your home directory and use ls to list all the files.

ls -a

Output:

As you can see there are several files starting with a period (.). If you only run those ls command without the -a option, the output does not contain any hidden files.

If you don’t have hidden files in your home directory, you can create one using the touch command like this:

touch .sample_hidden_file.txt

You can also create hidden folders with mkdir Command. You just have to make sure that you use the period 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 are in your home folder, you can run the following command to get the writing desk Directory in the command output:


ls 

Find hidden files with find

In addition to ls, you can use the find command as an alternative method of listing hidden files and folders on Linux. The find command searches for files within a folder hierarchy.

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

To find and list only hidden folders or directories, run the following command:

find . -name ".*" -maxdepth 1 -type d 2> /dev/null

Show hidden files with GUI

You can also view hidden files from the GUI using your default file manager. GNOME’s Files is the default file manager on Ubuntu Desktop. earlier the files Program became known as Nautilus.

You can launch files by pressing great Press , then type “files” in the search box that appears. Click on the Files program and it will show files in the home folder by default.

By default, your file manager doesn’t show all hidden files. Click on that Menu icon in the top 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 show hidden files on Linux too.

Although you cannot view hidden files and folders by default, you can still interact with them like you would any other normal file. 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 will come in handy when considering Linux as your daily driver. Dot files play an important role in Linux operating system as they are typically used to store configuration settings for programs.

In addition to files, the Find command on Linux can also find directories efficiently. But there are a few flags and options you need to learn in order to do this.

Leave a Comment