How to show Hidden Files and Folders in Ubuntu

Introduction

The hidden elements are elements that are not visible by default when the user views the contents of a folder. This ability to hide items to protect files from accidental manipulations and reduce the display of folders in which they are stored.
The hidden elements are identified in the previous point name. A file named ” .test ” will be recognized by the system as a hidden file so that a file named “test ” will not be.

How to Show Hidden Files in Ubuntu

There are many situations where it may be useful to display them. However, note that if these files are hidden, it’s for good reason … so be careful with handling.

1. Keyboard shortcut

These shortcuts are valid in most applications.

  • Ubuntu and Xubuntu: Ctrl + h ( “h” for “hidden”)
  • Kubuntu: Alt + .

2. In the file manager

Most file managers have a box-to-box located in the “View” menu. This check is often called “Show hidden files”.
For example, in Thunar , pull down the View menu and check “Show hidden files”.

3. In other graphics applications

In the “Open …” menu or “Save As …” from certain applications, the two previous methods do not work, it may nevertheless be useful to save a file in a hidden folder. He usually just make a right click in the file explorer and select “Show hidden files”.

4. Via a terminal

  • To list a terminal non-hidden items in the current folder, enter the command :

    ls
  • To display all items, including hidden elements, simply add the argument -a ( “all” in English):

     ls -a
  • And to only display hidden files and folders:

     ls -d. *
  • If you add / , you only see hidden folders:

     ls -d. * /

ls , for more information on using the command ls .

Hidden and Displaying Files via Command

file .hidden

If you want to make an invisible element in Nautilus , in each relevant file, create a text file named .hidden and place are the names of items you want to hide.There should only be one item per line.
(This trick makes them invisible files in Nautilus , they remain visible mode console .)

For example, to apply this tip to a set of files with the extension * .pyc, you can use the following commands:

  • ls -1 * .pyc> .hidden #

    if you want to CRUSH the list of hidden files

  • ls -1 * .pyc >> .hidden #

    if you want to ADD new hidden files

Automatic script

For a right click of the menu features hide files or folders you can use a script to Nautilus .
For this you must:

  1. Create a blank file in the folder scripts for Nautilus : /home/<votre_nom_d'utilisateur>/.local/share/nautilus/scripts (If you have followed what is stated above, you must ensure that the hidden elements are displayed to access);
    ::Feature for Precise 12.04 LTS : The folder containing the scripts for Nautilus is /home/<votre_nom_d'utilisateur>/.gnome2/nautilus-scripts.
  2. Name the file with the name of your choice ( “Hide” or “Hide, Show” would be a good choice);
  3. Copy this code to hide / display files (proposed by Nesthid);

    Hide or show
    <span class="co0">#! / bin / bash </span>
      <span class="kw3">printf </span> <span class="sy0">%</span> s <span class="st0">" <span class="es2">$ NAUTILUS_SCRIPT_SELECTED_FILE_PATHS</span> " </span> <span class="sy0">| </span> <span class="kw1">while </span> <span class="kw2">read </span> <span class="re5">-r</span> line
       <span class="kw1">do </span>
              <span class="kw1">if </span> <span class="kw2">grep </span> <span class="re5">-q </span> <span class="st0">" <span class="es3">$ {line ## * /}</span> " </span> <span class="st0">".hidden" </span>
              <span class="kw1">Then </span>
                      <span class="kw2">sed </span> <span class="re5">-i </span> <span class="st0">'/ ^ <span class="es3">$ {line ## * /}</span> / d " </span> <span class="st0">" .hidden " </span>
              <span class="kw1">else </span>
                      <span class="kw3">echo </span> <span class="st0">" <span class="es3">$ {line ## * /}</span> " </span> <span class="sy0">&gt;&gt; </span><span class="st0">" .hidden " </span>
              <span class="kw1">fi </span>
      <span class="kw1">done</span>
  4. To make it work, it must make the script executable. Right-click on this newly created file and “properties” tab → “permissions”, check “Allow executing file as a program” .

A new entry appears when making a right click in Nautilus in the “Scripts” with the name given to the file containing the code. This entry allows you to add or delete the names of the selected files and folders in the file .hidden .

All Ubuntu ls Show Hidden Files Command

ls command in Linux/Unix

ls is a Linux shell command that lists directory contents of files and directories.

ls syntax

$ ls [options] [file|dir]

ls command options

ls command main options:

optiondescription
ls -alist all files including hidden file starting with ‘.’
ls –colorcolored list [=always/never/auto]
ls -dlist directories – with ‘ */’
ls -Fadd one char of */=>@| to enteries
ls -ilist file’s inode index number
ls -llist with long format – show permissions
ls -lalist long format including hidden files
ls -lhlist long format with readable file size
ls -lslist with long format with file size
ls -rlist in reverse order
ls -Rlist recursively directory tree
ls -slist file size
ls -Ssort by file size
ls -tsort by time & date
ls -Xsort by extension name

ls command examples

You can press the tab button to auto complete the file or folder names.

List directory Documents/Books with relative path:

$ ls Documents/Books

List directory /home/user/Documents/Books with absolute path.

$ ls /home/user/Documents/Books

List root directory:

$ ls /

List parent directory:

$ ls ..

List user’s home directory (e.g: /home/user):

$ ls ~

List with long format:

$ ls -l

Show hidden files:

$ ls -a

List with long format and show hidden files:

$ ls -la

Sort by date/time:

$ ls -t

Sort by file size:

$ ls -S

List all subdirectories:

$ ls *

Recursive directory tree list:

$ ls -R

List only text files with wildcard:

$ ls *.txt

ls redirection to output file:

$ ls > out.txt

List directories only:

$ ls -d */

List files and directories with full path:

$ ls -d $PWD/*

ls command examples

You can press the tab button to auto complete the file or folder names.
List directory Documents/Books with relative path:

$ ls Documents/Books

List directory /home/user/Documents/Books with absolute path.

$ ls /home/user/Documents/Books

List root directory:

$ ls /

List parent directory:

$ ls ..

List user’s home directory (e.g: /home/user):

$ ls ~

List with long format:

$ ls -l

Show hidden files:

$ ls -a

List with long format and show hidden files:

$ ls -la

Sort by date/time:

$ ls -t

Sort by file size:

$ ls -S

List all subdirectories:

$ ls *

Recursive directory tree list:

$ ls -R

List only text files with wildcard:

$ ls *.txt

ls redirection to output file:

$ ls &gt; out.txt

List directories only:

$ ls -d */

List files and directories with full path:

$ ls -d $PWD/*

One thought on “How to show Hidden Files and Folders in Ubuntu

Leave a comment

Your email address will not be published. Required fields are marked *