Linux hidden files directory

Linux show hidden files and folders with simple commands

The commands from this article to view hidden files and folders can be used across any Linux platform such as Ubuntu, Debian, Linux Mint, RHEL, CentOS, SuSE etc or any Unix node such as HP-UX, Solaris, etc.

I am using RHEL/CentOS 8 node installed on Oracle VirtualBox . Please do let me know via comment section if you face any issues following the commands from this article to view hidden files or folders in Linux or Unix.

I would recommend to configure one click installation using Network PXE Boot Server. Using PXE server you can install Oracle VirtualBox Virtual Machines or KVM based Virtual Machines or any type of physical server without any manual intervention saving time and effort.

Create hidden Files

To create hidden files you just need to make sure the filename starts with dot character ( . ). In Linux any filename which starts with dot ( . ) character is considered as hidden file. For example here I create a normal file using touch command

Linux show hidden files

You can also create your own man page with a list of instructions for a script or a custom tool which you have created. In real time production environment it is always recommended to also create and release a man page for every script or tool we develop.

To list the file, as you see since the filename does not starts with dot ( . ) character, it is not hidden

# ls -l total 0 -rw-r--r--. 1 root root 0 Jan 21 18:51 hidden_file

Next we rename the file and make it .hidden_file starting with (.)

# mv hidden_file .hidden_file

Next if you try to list the available files, we don’t see hidden_file anymore.

In some Linux or Unix environment it is possible that ls command has an alias to » ls -a «, so in such case even if you execute ls or ls -l , this will show hidden files. For example here ls command without -a will show hidden files
In such case execute alias command from the terminal

# ls -l total 68 drwxr-xr-x. 3 root root 4096 Jan 21 19:05 . dr-xr-x---. 6 root root 4096 Jan 21 18:51 .. drwxr-xr-x. 2 root root 4096 Jan 21 19:51 .hidden_directory -rw-r--r--. 1 root root 54894 Jan 21 19:28 .hidden_file -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_directory -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_file

As you see there is an alias for ls command so by default it is configured to hidden files and folders. To remove this temporarily execute » unlias ls «

Next show hidden files and folders using ls , now this works as expected as we don’t see hidden folders or files.

# ls -l total 0 -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_directory -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_file

This is temporary fix only for the current session, you need to check where this setting is configured for alias , it may be /etc/profile or /etc/bashrc some other system file based on your distribution.

Читайте также:  Virtualbox linux забыл пароль

Similarly to create hidden files you can just put a ( . ) infront of the filename, for example to create hidden files with filename » my_file «:

Create hidden folder or directory

Linux create hidden folders and directories

The steps to create hidden folder or directory in Linux or Unix is similar to create hidden files. We just need to make sure the folder name starts with dot ( . ) character.

[root@server3 test]# mkdir .hidden_directory

Now list the available files in current directory, as expected we don’t see any directory/folder since the folder is hidden. So we were able to create hidden folder here.

[root@server3 test]# ls -l total 0

Linux show hidden files and folders with ‘ls’ command

  • In this example we will use ls command in Linux show hidden files and folders.
  • We can use ls command with » -a » to show all files including hidden files and folder.
  • With -a «we do not ignore entries starting with . » that means also Linux show hidden files and folders.
  • For example to show hidden files and folders which we created in above steps, navigate to your directory and execute ls -a
  • We have also used -l to give us a long list so we use ls -al to show all files under test directory in long list format

Linux show hidden files and directories

[root@server3 test]# ls -al total 12 drwxr-xr-x. 3 root root 4096 Jan 21 19:05 . dr-xr-x---. 6 root root 4096 Jan 21 18:51 .. drwxr-xr-x. 2 root root 4096 Jan 21 19:02 .hidden_directory -rw-r--r--. 1 root root 0 Jan 21 18:51 .hidden_file

As you see we were able to show hidden folders and files with » ls -a » which we had created earlier in this article.

[root@server3 test]# ls -al total 8 drwxr-xr-x. 2 root root 4096 Jan 21 18:53 . dr-xr-x---. 6 root root 4096 Jan 21 18:51 .. -rw-r--r--. 1 root root 0 Jan 21 18:51 .hidden_file

Linux show hidden files and folders with ‘find’ command

Now with ls command we were able to show hidden files in one directory or may be multiple directories in Linux and Unix. But with ls it is little tricky to show hidden folders and files across all partitions. Here we can find hidden files using find command in Linux or Unix.

Linux find hidden files and folders with find command

Now from our chapter » create hidden files » and » create hidden directory «, we know that hidden files start with dot ( . ) character. So we can use this trick with find command to find hidden files.

For example to find hidden files use -type f under /etc/ directory we can use below command

# find /etc/ -type f -name '.*' /etc/selinux/targeted/.policy.sha512 /etc/skel/.kshrc /etc/skel/.bash_profile /etc/skel/.bashrc /etc/skel/.bash_logout /etc/.pwd.lock /etc/.updated

Here we are only search of files using » -type f » and any filename starting with dot ( . )

Читайте также:  Samba astra linux orel

With Linux show hidden files and folders we can use the same command with -type d to find hidden folders under /usr

# find /usr/ -type d -name '.*' /usr/java/jre1.8.0_172-amd64/.java /usr/java/jre1.8.0_172-amd64/.java/.systemPrefs /usr/local/avamar/etc/.tmp

Here we could not have used » ls -a » to show hidden files in all these directories without using extra commands, so find is a better alternative to find hidden folder and files in Linux or Unix.

Check size of hidden files and folders

check size of hidden files and folders in Linux

Now once you find hidden files or folders, you may also wish to check size of hidden files or folders.

For example we will find hidden files under our ~/test directory

[root@server3 test]# find . -type f -name '.*' ./.hidden_file ./.hidden_directory/.hidden_file_2

So we have two hidden files, we can use ls with -Sh to check size of hidden files but it again has it’s own challenges.

  • -S means sort by file size
  • -h means print sizes in human readable format (e.g., 1K 234M 2G)

We use ls -lSha to show and check size of hidden file but as you see ls could only identify .hidden_file in the current folder but missed .hidden_file_2 available inside .hidden_directory

[root@server3 test]# ls -lSha total 68K -rw-r--r--. 1 root root 54K Jan 21 19:28 .hidden_file drwxr-xr-x. 3 root root 4.0K Jan 21 19:05 . dr-xr-x---. 6 root root 4.0K Jan 21 18:51 .. drwxr-xr-x. 2 root root 4.0K Jan 21 19:51 .hidden_directory -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_directory -rw-r--r--. 1 root root 0 Jan 21 19:05 normal_file

Alternatively you can use ls -lSha .* which shall also check child directory for hidden files and print it’s size but again this tool is not very convenient.

We will use du command to check size of hidden files in Linux or Unix. du command is used to estimate file space usage. We must combine du with find commands to first we find hidden files and folders and then we check size of hidden files using du command

For example to check size of hidden files under /test folder

[root@server3 test]# find ~/test/ -type f -name '.*' -exec du -ah <> + 56K /root/test/.hidden_file 984M /root/test/.hidden_directory/.hidden_file_2

Similarly to check size of hidden files under /tmp folder

# find /tmp/ -type f -name '.*' -exec du -ah <> + 4.0K /tmp/smem/smem-1.4/.hg_archival.txt 4.0K /tmp/smem/smem-1.4/.hgtags 4.0K /tmp/test1/usr/lib/x86_64-linux-gnu/firmware-cna-emulex-2018.02.01-1.24/.cpq_package.inc 1.6M /tmp/test1/usr/lib/x86_64-linux-gnu/firmware-cna-emulex-2018.02.01-1.24/.setup

Lastly I hope the steps from this article to Linux show hidden files and folders, create hidden files, create hidden folder and find hidden files and folders in Linux and Unix was helpful. So, let me know your suggestions and feedback using the comment section.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

How to View Hidden Files and Folders on Linux

Linux has applications in both personal and professional purposes. In Linux we can hide files and directories. These hidden files and folders are usually not displayed in the user interface, but they can be accessed through the terminal.

Читайте также:  Установка veracrypt kali linux

This can be useful for keeping important configuration files or data hidden from casual users. This write-up will cover steps to view hidden files on Linux.

Before we can continue first, we will create a file then hide it later.

How To View Hidden Files and Directories in Linux

To check the files hidden in Linux system we can use:

1: Command Line

Open terminal and list all files inside a directory using:

Here we can see a test file along with others.

To hide this test file rename it by just adding a dot (.) in the beginning of command like:

After writing this command our test file is now hidden:

Now once again list all the files:

Here we can see test file is no longer displayed:

As our test file is now hidden. The ls command along -a flag will list hidden files. The ls shows us all files of directory, and the -a flag tells the command to show all files, including hidden ones. To view the hidden files run below command:

This will display all files including the hidden ones. Hidden files and folders are usually prefixed with a dot (.) and are not displayed by default in the user interface.

Now we can see that along with other hidden files our test file is also displayed.

2: File Manager Toolbar (GUI)

Second method on the list to view hidden files is by using the file manager toolbar. Open the directory where we want to see hidden files, here we have created a folder with a name test:

First, we will create a hidden folder by renaming it with a name starting with dot (.) and after that this file will be hidden. For example, rename the Test folder as (.Test).

Now we can see the Test folder is hidden:

To unhide select the tool bar option and check the Show Hidden Files option:

It will display all the files that are hidden inside this directory including the Test file. All hidden files are started with a dot(.):

3: Keyboard shortcut (GUI)

Last method on the list is using a keyboard shortcut. Open the directory where you want to read the hidden file. After that press Ctrl+H which will unhide all files and folders, if we press this key again all folders will be hidden again.

Conclusion

Viewing hidden files and folders on Linux can be done through the terminal. The ls command with the -a flag is all you need to display hidden files and folders. Also, we can use a keyboard shortcut or toolbar inside the GUI of file manager. By using these methods, you can gain access to important configuration files and data that are not displayed in the user interface.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.

Источник

Оцените статью
Adblock
detector