官术网_书友最值得收藏!

Hidden Files

The current directory . and the parent directory .. exist under each directory in the Linux filesystem. But how come we can't see them when we run the ls command?

elliot@ubuntu-linux:~/Desktop$ pwd
/home/elliot/Desktop
elliot@ubuntu-linux:~/Desktop$ ls
hello.txt
elliot@ubuntu-linux:~/Desktop$ ls -l
total 4
-rw-r--r-- 1 elliot elliot 37 Jan 19 14:20 hello.txt

As you can see, I even tried to run ls -l and still can't see the current directory or the parent directory.

You need to use the -a option with the ls command as follows:

elliot@ubuntu-linux:~/Desktop$ ls -a
. .. hello.txt

Hooray! Now you can see all the files. The -a option shows you all the files, including hidden files and of course you can use the full option name --all, which will do the same thing:

elliot@ubuntu-linux:~/Desktop$ ls --all
. .. hello.txt

It turns out that any filename that starts with . (a dot) is hidden.

Hidden filenames start with .

Any filename that starts with a dot is hidden. That's why current and parent directories are hidden.

To demonstrate further, go to your user home directory and run the ls command:

angela@ubuntu-linux:~$ ls 
Music

Now run the ls -a command:

angela@ubuntu-linux:~$ ls -a
. .. .bash_logout .bashrc Music .profile

You can now see the hidden files in your home directory! Notice all the hidden filenames start with a dot.

主站蜘蛛池模板: 博野县| 晋中市| 什邡市| 凤山县| 开化县| 铁岭市| 顺昌县| 宁城县| 平定县| 葵青区| 上思县| 宁武县| 亚东县| 利辛县| 和田县| 德庆县| 舒兰市| 龙川县| 塘沽区| 裕民县| 河源市| 洛阳市| 金秀| 鹤壁市| 永兴县| 武义县| 东兴市| 鄂托克前旗| 芜湖市| 青神县| 夏津县| 沈丘县| 乌鲁木齐县| 松原市| 梨树县| 北海市| 周口市| 临猗县| 翁牛特旗| 托克托县| 洛浦县|