Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic operations of the ls command in linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the basic operations of ls commands in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Ls command

Basic operation of directory

The ls command is used to display a list of targets and is a highly used command in Linux. The output of the ls command can be highlighted in color to partition different types of files.

Grammar

Ls (option) (parameter) option

-a: displays all files and directories (ls internally calls the file name or directory name "." Is regarded as a shadow collection and will not be listed);-A: display the shadow collection file. " And ".." List of all files except;-C: multiple columns display the output. This is the default option;-l: contrary to the "- C" option function, all output information is output in a single-column format, not as multiple columns;-F: append the type identifier of the file after each output item, the specific meaning: "*" indicates the ordinary file with executable permissions, "/" represents the directory, "@" represents the symbolic link, "|" represents the command pipeline FIFO, "=" represents the sockets socket. When the file is a normal file, no identifiers are output;-b: output the non-exportable characters in the file with a backslash "" plus character encoding;-c: when used with the "- lt" option, sort the output directory contents according to the file status time, sorting according to the ctime field in the file's index node. When used with the "- l" option, the sorted sentence is when the state of the file changes;-d: only the directory name is displayed, not the list of contents under the directory. Displays the symbolic link file itself instead of the list of directories it points to;-f: the effect of this parameter is the same as that of specifying the "aU" parameter at the same time, and the effect of turning off the "lst" parameter;-I: displays the file index node number (inode). An Inode represents a file;-- file-type: has the same function as the "- F" option, but does not display "*";-k: displays the file size in KB (kilobytes);-l: displays the list of contents in the directory in a long format. The output information includes file name, file type, permission mode, number of hard connections, owner, group, file size and last modification time of the file from left to right;-m: separate the name of each file and directory with ",";-n: replace its name with user identification code and group identification code;-r: reverse the file name and output the list of directory contents -s: display the size of files and directories in blocks;-t: sort by the change time of files and directories;-L: if you encounter a file or directory with a symbolic link, directly list the original file or directory that the link points to;-R: recursive processing, processing all files and subdirectories under the specified directory together;-full-time: list the complete date and time -- color [= WHEN]: highlight different types with different colors. Parameters.

Directory: specify the directory where you want to display the list, or it can be a specific file.

Example

Show non-shadow files and directories in the current directory

[root@localhost ~] # lsanaconda-ks.cfg install.log install.log.syslog satools

Displays a list of all files in the current directory, including shadow files

[root@localhost] # ls-a. Anaconda-ks.cfg .bash _ logout .bashrc install.log .mysql _ history satools .tcshrc .vimrc.. .bash _ history .bash _ profile .cshrc install.log.syslog .rnd .ssh .viminfo

Modify the last edited file

The most recently modified file is displayed at the top.

[root@localhost /] # ls-ttmp root etc dev lib boot sys proc data home bin sbin usr var lost+found media mnt opt selinux srv misc

List the details of files and folders

[root@localhost /] # ls-ltotal 254drwxr-xr-x 2 root root 4096 Jun 12 04:03 bindrwxr-xr-x 4 root root 1024 Jun 15 14:45 bootdrwxr-xr-x 6 root root 4096 Jun 12 10:26 datadrwxr-xr-x 10 root root 3520 Sep 26 15:38 devdrwxr-xr-x 75 root root 4096 Oct 16 04:02 etcdrwxr-xr-x 4 root root 4096 Jun 12 10:26 homedrwxr-xr-x 14 root root 12288 Jun 16 04:02 libdrwx- 2 root root 16384 Jun 11 22 lost+found

List readable files and folder details

[root@localhost /] # ls-lhtotal 254Kdrwxr-xr-x 2 root root 4.0K Jun 12 04:03 bindrwxr-xr-x 4 root root 1.0K Jun 15 14:45 bootdrwxr-xr-x 6 root root 4.0K Jun 12 10:26 datadrwxr-xr-x 10 root root 3.5K Sep 26 15:38 devdrwxr-xr-x 75 root root 4.0K Oct 16 04:02 etcdrwxr-xr-x 4 root root 4.0K Jun 12 10:26 homedrwxr-xr-x 14 root root 12K Jun 16 04:02 libdrwx- 2 root root 16K Jun 11 22:46 lost+founddrwxr-xr-x 2 root root 4.0K May 11 2011 media

Display folder information

[root@localhost /] # ls-ld / etc/drwxr-xr-x 75 root root 4096 Oct 16 04:02 / etc/

List files and folder details by time

[root@localhost /] # ls-lttotal 254drwxrwxrwt 3 root root 98304 Oct 16 08:53 tmpdrwxr-xr-x 75 root root 4096 Oct 16 04:02 etcdrwxr-x--- 4 root root 4096 Oct 15 14:43 rootdrwxr-xr-x 10 root root 3520 Sep 26 15:38 devdrwxr-xr-x 14 root root 12288 Jun 16 04:02 libdrwxr-xr-x 4 root root 1024 Jun 15 14:45 bootdrwxr-xr-x 11 root root 0 Jun 15 11:04 sys

List file and folder details by modification time

[root@localhost /] # ls-ltrtotal 254drwxr-xr-x 2 root root 4096 Nov 8 2010 miscdrwxr-xr-x 2 root root 4096 May 11 2011 srvdrwxr-xr-x 2 root root 4096 May 11 2011 selinuxdrwxr-xr-x 2 root root 4096 May 11 2011 optdrwxr-xr-x 2 root root 4096 May 11 2011 mntdrwxr-xr-x 2 root root 4096 May 11 media

Show recursive files

[root@localhost ~] # ls-R.:anaconda-ks.cfg install.log install.log.syslog satools./satools:black.txt freemem.sh iptables.sh lnmp.sh mysql php502_check.sh ssh_safe.sh "what are the basic operations of ls commands in linux"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report