Home > Hosting > Server

What is the command to view all files in a directory in linux

2023-06-06 10:23:29

This article mainly explains the command of Linux to view all files in the directory. The content of the explanation in the article is simple and clear, easy to learn and understand. Next, please follow the editor's ideas and study and learn Linux together. Which is the command to view all files in the directory!

Linux command to view all files in the directory is ls; ls command is the abbreviation of list, is the most common directory operation command, its main function is to display the current directory The basic format of this command is [root@localhost ~]# ls [xuanxiang] muluming.

What is the command for Linux to view all files in the directory?

The ls command, short for list, is the most common directory operation command, and its main function is to display the contents of the current directory. The basic format of this command is:

[root@localhost ~]# ls [options] directory name

Note that when the ls command does not use any options , by default, only the names of non-hidden files will be displayed, and they will be sorted by file name. At the same time, the file name will be colored according to the specific type of the file (blue shows the directory, and white shows the general file). In addition, if you want to use the ls command to display more content, you need to use the corresponding options in Table 1.

Example:

[root@www ~]# ls -al ~ total 156 drwxr-x--- 4 root root 4096 Sep 24 00:07 . drwxr-xr-x 23 root root 4096 Sep 22 12:09 .. -rw------- 1 root root 1474 Sep 4 18:27 anaconda-ks.cfg -rw------- 1 root root 955 Sep 24 00:08 .bash_history -rw-r--r-- 1 root root 24 Jan 6 2007 .bash_logout -rw-r--r-- 1 root root 191 Jan 6 2007 .bash_profile -rw-r--r-- 1 root root 176 Jan 6 2007 .bashrc drwx------ 3 root root 4096 Sep5 10:37 .gconf -rw-r--r-- 1 root root 42304 Sep 4 18:26 install.log -rw-r--r-- 1 root root 5661 Sep 4 18:25 install.log.syslog

By using -a, you will see several files and directories starting with . Files (.), (..), .gconf, etc. These are hidden directories and files. Among them, the directory file name is displayed in blue, and the general file is displayed in white.

Note that in the Linux system, hiding files is not to hide the files from other users to find them, but to tell users that these files are important system files, if not necessary, don't mess around! Therefore, whether it is Linux or Windows, you can view hidden files very simply, but most viruses and Trojans in Windows will turn themselves into hidden files, giving users the illusion that hidden files are to prevent users from user discovery.

Not only that, the ls command here also uses the -l option, so the detailed information of the file is displayed. The meanings of the 7 columns displayed by this option are:

The first column: specifies the permissions that different users have on the file, and the meaning of specific permissions will be explained in subsequent chapters.

The second column: reference count, the reference count of the file represents the number of hard links of the file, and the reference count of the directory represents how many first-level subdirectories the directory has.

The third column: owner, that is, which user this file belongs to. The default owner is the user who created the file.

The fourth column: the group to which it belongs, the default group is the effective group of the file creation user, generally it is the group of the creation user.

The fifth column: size, the default unit is byte.

The sixth column: file modification time, file status modification time or file data modification time will change this time, note that this time is not the creation time of the file.

The seventh column: file name or directory name.

Thank you for reading. The above is the content of the command for viewing all files in the directory in linux. After studying this article, I believe everyone has a question about the command for viewing all files in the directory in linux. With a deeper understanding, the specific usage needs to be verified by everyone in practice. This is Yisu Cloud, the editor will push more articles about relevant knowledge points for you, welcome to pay attention!


Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us