Logo

3 Ways of Working With Hidden Files in Linux

Try this guide with our instant dedicated server for as low as 40 Euros

hidden files in linux

Ever wondered how your Linux system remembers your preferred settings or how applications preserve operational configurations?

Hidden files play a crucial role in ensuring smooth operations for the core OS components and applications They store configuration settings, preferences, and other data that personalize your experience and keep things running smoothly. 

All Linux distributions keep these essential files out of sight to prevent accidental changes that could affect system performance. 

This comprehensive tutorial will help you through finding and creating hidden files on your system. You’ll also learn to mark files as hidden and create password-protected hidden files.

Table Of Contents

  1. The Prerequisites
  2. How to Make Hidden Files Visible
    1. View Hidden Files Using the Command Line
    2. View Hidden Files in the Graphical Interface (GUI)
  3. How to Make Files Invisible
    1. Hide Files and Directories Using the Command Line
    2. Make Files Invisible in the Graphical Interface (GUI)
  4. Creating Password-Protected and Hidden Files
    1. Make a Hidden and Secure File via the Command Line
    2. Create a Hidden, Password-Protected File in the GUI
  5. Conclusion
  6. FAQs

The Prerequisites

Before you find and create hidden files, ensure you have the following:

  • You’ll need a system running a mainstream Linux distribution.
  • A user account with root or sudo privileges. 

Important: You will need root permission to access and work with some files and directories, especially those in system directories. In these situations, we recommend using sudo or log in as a root user.

How to Make Hidden Files Visible

Changing the visibility of hidden files is a common activity for system administrators who work with system config files. 

Here are two ways of viewing and accessing the hidden files on your Linux system. 

View Hidden Files Using the Command Line

To display all files in a directory, including the hidden ones, you can run this command:

# ls -a

The ls (list) command displays all the files and subdirectories in the directory you’re currently in. The -a flag instructs the command to include all the hidden files in the current directory.

ls -a

You can also use this command to list the files and directories of other directories by specifying the directory path after the ls command in the following format:

# ls -a /etc

Replace /etc with the name of your desired directory. 

The command displays both the hidden and regular files.

View Hidden Files in the Graphical Interface (GUI)

If you prefer using the system’s graphical interface, follow these  steps to see hidden files:

  1. Navigate to the desired directory.
  2. Press Ctrl+H to toggle the hidden files.

If you are using an older version of Linux distributions, this shortcut may not do the trick. If that’s the case with your system, we recommend the following alternative method:

Look for the View menu and select the Show hidden files option.

How to Make Files Invisible

System administrations may often need to mark files as hidden to protect them from unintentional changes that can disrupt system performance and operations. Let’s see two methods of making files and directories invisible. 

Hide Files and Directories Using the Command Line

We recommend the following steps that use the mv (move) to make a file or directory invisible:

  1. Make a new empty file named test.txt by using the touch command:

# touch test.txt

touch test file1.txt

  1. Now, you can hide this file by renaming it so that the filename starts with a period (.). The addition of the period makes the file invisible in the Linux filesystem:

# mv test.txt .test.txt

  1. It is always a good idea to verify that the file is hidden. Use the ls command to view the contents of the current directory:

# ls

The previously visible file or directory (test.txt  in this example) won’t be visible anymore.

  1. You can further confirm your file is still there but hidden by using the following command that lists all files in the directory: 

# ls -a

As you can see, the .test.txt should now appear in the list, showing that it was successfully hidden.

touch test.txt

Note: Just as you hide files, you can hide directories too. Simply use the mv command to rename the folder by adding a period (.) at the start of its name.

Make Files Invisible in the Graphical Interface (GUI)

Hiding a file isn’t just a command-line trick; you can do it easily using the graphical interface. Follow these steps to execute it:

  1. First, navigate to the target file you wish to hide and right-click on it to bring up the context menu.
  2. Choose Rename from the menu.
  3. Add a period (.) at the beginning of the file name to hide it.

Make Files Invisible in the Graphical Interface

Adding a period at the beginning of the file name hides it in the Linux file system. The same steps apply if you want to hide a directory.

Creating Password-Protected and Hidden Files

In addition to working with existing files and directories, you can create hidden files and directories and add a password for additional protection. Here are two methods you can try. 

Make a Hidden and Secure File via the Command Line

  1. Create a blank text file named test2.txt with the touch command:

# touch test2.txt

  1. Now, you can compress and encrypt this file with the zip command:

# zip --encrypt test2.zip test2.txt

  1. When prompted, set a password to protect the file.
  2. Use the ls command to see the newly created test2.zip in the list of files and subdirectories:

touch test2_file.txt

  1. You can now mark this zip file as hidden by renaming it:

mv test2.zip .test2.zip

  1. Use ls and then the ls -a to check that your file is now hidden but present on the system.

test2_file.zip

Create a Hidden, Password-Protected File in the GUI

Encrypting a file in the graphical interface takes a few more steps but is still straightforward.

  1. Open the File Manager and go to the home directory.
  2. Right-click and select Create New Folder from the context menu. Alternatively, you can use mkdir command to do this from a command prompt.
  3. Name the directory as test3.
  4. Click on Activities, search for Archive Manager, and open it.

archieve manager

  1. Add the directory to Archive Manager by dragging the test3 directory into the Archive Manager window.
  2. You might be prompted to confirm creating an archive. Click  Create Archive.

new archieve

  1. Make sure the file name is test3 in the dialog box. Use the format dropdown to select .zip.
  2. Add Password: Click Other options, enter a password for the archive, and save it.
  3. After closing the Archive Manager, you’ll find test3.zip in the home directory. 

test folder.zip

 

  1. Right-click it, select Rename, and add a period at the start to hide it.

documents

Conclusion

Understanding the techniques to find hidden files in Linux demystifies much of the operating system’s underlying structure. Whether delving into troubleshooting tasks, executing system administration duties, or simply exploring the system’s architecture, the ability to access hidden files opens a gateway to a realm of possibilities.

For those administrating Linux servers or seeking robust hosting solutions, particularly in environments where precision and security are paramount, partnering with reputable hosting providers like RedSwitches is imperative.  RedSwitches offers a suite of bare metal hosting solutions tailored to meet the demands of Linux servers, ensuring optimal performance, reliability, and security.

At RedSwitches, we’re dedicated to helping you discover the perfect server solutions to drive your business to new heights. So, if you’re looking for a robust server, we offer the best dedicated server pricing and deliver instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.

FAQs

Q. How can I display hidden files in Linux?

You can display hidden files in Linux by using the ‘-a’ option with ‘ls’ command, like “ls -a” or   “ls -al“. Hidden files in Linux start with a dot (.) at the beginning of their names.

Q. How do I create a hidden directory or file in Linux?

To create a hidden file or directory in Linux, simply name the file or directory with a dot character (.) at the beginning of its name. For example, you can use the command # mkdir .hidden_directory to create a hidden directory.

Q. How can I find hidden files in Linux using the terminal?

You can find hidden files in Linux using the terminal by using the “find” command with the appropriate options. For example, you can use the command “# find . -type f -name ‘.*’” to find all hidden files in the current directory.

Q. Can I hide files and directories in Linux?

Yes, you can hide files and directories in Linux by renaming them with a dot (.) at the beginning of their names. These hidden files and directories will not be displayed by default when using the “ls” command.

Q. How can I exclude hidden files using the “ls” command?

You can exclude hidden files when using the “ls” command by using the “# ls -a | grep -v ‘^.’” option. This will list all files and directories except those starting with a dot (.), which are considered hidden.

Q. What is the significance of hidden files in a Linux system?

Hidden files in a Linux system are typically configuration files or files not meant to be directly accessed or modified by users. They are important for properly functioning various applications and the operating system.

Q. How can I show hidden files and directories using a file manager in Linux?

In file managers like GNOME Files, you can usually show hidden files and directories by toggling an option in the settings menu. Look for an option like “Show Hidden Files” or “Show Hidden Items” to display all files and directories, including hidden ones.

 

Try this guide with our instant dedicated server for as low as 40 Euros