How to list hidden files and folders in linux/unix

In linux/unix, when it comes to listing files and folders, everyone will think of the ls command

Yes, there are many options for the ls command, and we can use different options to meet various needs.

For example, the “-a” option will show all files and folders, including hidden ones.

Let us try the following commands:

ls -a

At this time, we saw more files and folders, most of which are files or directories beginning with “.”. These are hidden files or directories.

Here we can see two special ones, namely “.” and “..”, which represent the current directory and the upper directory respectively.

We can use the cd command to test:

cd .
➜  ~ pwd
➜  ~ cd .
➜  ~ pwd
➜  ~

cd ..
➜  ~ pwd
➜  ~ cd ..
➜  /Users pwd
➜  /Users

In addition, if you are using a mac computer like me, you will see a “.DS_Store” file, which is a metadata file created by the Mac operating system in each directory and contains information about the directory and its contents. Windows computers also have a similar file, which is a “.hiddenfile” file.

If you feel that using ls -a is inconvenient to browse, you can also use the -l long format option, which will display more information, including permissions, owner, group, size, last-modified date, etc.

ls -la

Add a Comment

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