How to show Hidden Files and Folders in Ubuntu

show-hidden-files-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
    #! / bin / bash 
      printf  % s " $ NAUTILUS_SCRIPT_SELECTED_FILE_PATHS "  |  while  read  -r line
       do 
              if  grep  -q  " $ {line ## * /} "  ".hidden" 
              Then 
                      sed  -i  '/ ^ $ {line ## * /} / d "  " .hidden " 
              else 
                      echo  " $ {line ## * /} "  >> " .hidden " 
              fi 
      done
  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:

option description
ls -a list all files including hidden file starting with ‘.’
ls –color colored list [=always/never/auto]
ls -d list directories – with ‘ */’
ls -F add one char of */=>@| to enteries
ls -i list file’s inode index number
ls -l list with long format – show permissions
ls -la list long format including hidden files
ls -lh list long format with readable file size
ls -ls list with long format with file size
ls -r list in reverse order
ls -R list recursively directory tree
ls -s list file size
ls -S sort by file size
ls -t sort by time & date
ls -X sort 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 > out.txt

List directories only:

$ ls -d */

List files and directories with full path:

$ ls -d $PWD/*

You May Also Like

About the Author: admin

1 Comment

Comments are closed.