In Linux, files and directories that begin with a period (.) are hidden by default. These hidden files are typically used for configuration purposes or system-level functions. They are not displayed when you use file managers or standard command-line tools without specific options.

To view hidden files, you need to use the ls command in the terminal, which offers the option to reveal all items, including those that begin with a period. This method is essential for users managing system files or troubleshooting issues that require interaction with hidden files.

Once revealed, hidden files and folders will appear alongside regular ones, with the period indicating their hidden status. Using the right command option is the fastest way to access these files, and you can also view them in graphical file managers by adjusting settings to show hidden items.

Steps to show hidden files and folders in Linux:

  1. Open the terminal.
  2. Navigate to the desired directory.
    $ cd temp/
  3. List regular files in the directory.
    $ ls
    file  folder
  4. Display hidden files along with regular files.
    $ ls -a
    .  ..  file  folder  .hidden-file  .hidden-folder

    ls option:

    -a, --all
           do not ignore entries starting with .
  5. List only hidden files and folders.
    $ ls -d .?*
    .hiddenfile1  .hiddenfolder1
    -d .?*

    lists files and folders that start with a period.

  6. Show detailed information about all files, including hidden ones.
    $ ls -la
    total 16
    drwxrwxr-x 4 user user 4096 Oct 31 09:27 .
    drwxr-xr-x 5 user user 4096 Oct 31 09:26 ..
    -rw-rw-r-- 1 user user    0 Oct 31 09:27 file
    drwxrwxr-x 2 user user 4096 Oct 31 09:26 folder
    -rw-rw-r-- 1 user user    0 Oct 31 09:27 .hidden-file
    drwxrwxr-x 2 user user 4096 Oct 31 09:26 .hidden-folder

    . and .. are special folders which refers to current and one-up folder respectively

  7. List all files using an absolute path.
    $ ls -la /home/user/temp/
    total 16
    drwxrwxr-x 4 user user 4096 Oct 31 09:27 .
    drwxr-xr-x 5 user user 4096 Oct 31 09:26 ..
    -rw-rw-r-- 1 user user    0 Oct 31 09:27 file
    drwxrwxr-x 2 user user 4096 Oct 31 09:26 folder
    -rw-rw-r-- 1 user user    0 Oct 31 09:27 .hidden-file
    drwxrwxr-x 2 user user 4096 Oct 31 09:26 .hidden-folder

    . refers to the current directory, and .. refers to the parent directory.

Discuss the article:

Comment anonymously. Login not required.