4

How to View Hidden Files and Folders on Linux

 1 year ago
source link: https://www.makeuseof.com/view-hidden-files-and-folders-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to View Hidden Files and Folders on Linux

Published 17 hours ago

Linux has a good deal of files that are hidden by default. To interact and edit such files and folders, you need to learn how to view them first.

people viewing hidden files on linux

The Linux operating system consists of hundreds of files and folders that are hidden by default. Such files are known as hidden files or dot files because they always begin with a 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 yet very important in Linux. They are mainly used for storing configuration files or user settings. Usually, these files are used by your system services, scripts, or other programs. For example, the .bash_logout 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.

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 within a directory. However, ls doesn't list hidden files by default.

To show hidden files you must use the -a option, which commands ls to list "all" files and folders (including hidden ones).

Navigate to your home directory with the cd command and do a listing of all files using ls.

ls -a

Output:

ls command showing hidden files and folders

As you can see, there are several files that start with a dot (.). If you just run the ls command without the -a option, the output will not include hidden files.

If you do not have any hidden files in your home directory, you can create one using the touch command as follows:

touch .sample_hidden_file.txt

You can also create hidden folders with the mkdir command. You just have to make sure you 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 Desktop directory in the command output:

ls --hide=Desktop

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 on Linux. The find command searches for files within a folder hierarchy.

To list or find all hidden files, you have to explicitly tell the find command to list all files whose names start with a dot (.).

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

Viewing Hidden Files Using the 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. Previously, the Files program was known as Nautilus.

You can launch Files by pressing the Super key and then typing "Files" in the search input 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 display 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.

viweing hidden files and folders on Linux

Alternatively, you can use the keyboard shortcut Ctrl + H to view hidden files on Linux as well.

Although you can't view hidden files and folders by default, you can still interact with them just like other normal files. In fact, at some point, you might have to make configuration changes in a hidden file.

Finding Files and Folders on a Linux System

Knowing how to list and view 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're usually used to store configuration settings for programs.

In addition to files, the find command can also efficiently locate directories on Linux. But there are a few flags and options that you'll have to learn to do so.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK