Starting today to introduce you to the common Linux commands, first of all, we introduce the most frequently used command--ls command in Linux.
For more information on Linux commands, see: Linux Command Quick check manual
The Linux ls command is a powerful and useful command for displaying the contents of a specified working directory (which lists the files and subdirectories in the current working directory), as well as viewing the file's permissions (including directories, folders, file permissions), viewing directory information, and so on.
First, ls command syntax
LS [-ALRTAFR] [name ...]
Second, ls command parameters
Here are some common parameters of LS command.
-a displays all files and directories (LS default starts the filename or directory name as ".") As hidden files, will not be listed)-l In addition to the file name, but also the file type, permissions, owner, file size and other information in detail-R to display the file in reverse order (originally in alphabetical order)-T list the file according to the order of establishment time-A and a, but not listed "." (current directory) and ".." (parent directory)-F adds a symbol after the listed file name, for example, the executable file is added "*", the directory is added "/"-R if the directory has files, the following files are also listed in sequence
Three, ls command use example
The following is a few examples to give you a detailed description of the use of the LS command.
List all directories under the root directory (\):
$ls/bin boot dev etc Home Lib lib64 lost+found media mnt opt Proc Root sbin selinux SRV sys tmp usr var
List all files in the current working directory that have the name beginning with B, and the newer the more the following:
$ls-lrt b*backupfile:total 76-rw-r--r--1 root root 23376 Sep 6 date-rw-r--r--1 root root 23376 Sep 6
2015 20150906144055.tar.gz-rw-r--r--1 root root 1168 Sep 6 backup.log-rw-r--r--1 root root 23376 Se P 6 20150906.tar.gzbaktars:total 18272-rw-r--r-- 1 root root 11754834 June 2011 python-2.7.2.tar.bz2-rw-r--r-- 1 root root 1407934 2011 sqlite-amalgamation-3.6.20.tar.gz-rw-r--r-- 1 root root 253351 Mar 2015 monitorix-3.7.0-1.noarch.rpm-rw-r--r-- 1 root root 332005 Jan 8 07:35 setuptools-0.6c11-py2.7.egg-rw-r--r-- 1 root root 4563244 Jan 8 15:25 Twisted-15.2.1.tar.bz2drwxr-xr-x 8 root root 4096 Mar 1 15:18 twisted-15.2.1drwxrwxrwx 4 1000 Users 4096 Mar 1 17:49 sqlite-3.6.20drwxr-x--- 1002 4096 Mar 1 18:51 python-2.7.2-rw-r--r-- 1 root root 370026 Apr 18:25 master.zipdrwxr-xr-x 9 root root 4096 Apr 16 1 8:46 Mod_python-master
List all directories and file details under the Shelltest folder:
$ls-LR shelltest/shelltest/:total 52-rwxr-xr-x 1 root root 1282 May 3 17:41 case2.sh-rwxr-xr-x 1 root root 0 18:59 case3.sh-rwxr-xr-x 1 root root 2 June 2 15:33 date.txt-rwxr-xr-x 1 root root 119 June 16:53 Echo. Sh-rwxr-xr-x 1 root root 224 June 1 21:11 fun1.sh-rwxr-xr-x 1 root root 197 June 1 21:30 fun2.sh-rwxr-xr-x 1 Root root June 2 17:55 num1.sh-rwxr-xr-x 1 root root 123 June 2 17:57 num2.sh-rwxr-xr-x 1 root root
18 June 2 17:06 num.txt-rwxr-xr-x 1 root root 276 may 20:50 select1.sh-rwxr-xr-x 1 root root 20:56 select2.sh-rwxr-xr-x 1 root root 182 may 16:14 test.sh-rwxr-xr-x 1 root root 5 June 2 17:02 who. Txt
Lists the absolute path to all files (including hidden files) in the current directory, without recursion to the directory
#find $PWD-maxdepth 1 | Xargs ls-lddrwxr-xr-x 5 root root 4096 may 20:48/root/testdrwxr-xr-x root root 4096 Feb 09:24/ROOT/TEST/CP Ptestdrwxr-xr-x 2 root root 4096 21:21/root/test/lntstdrwxr-xr-x 2 root root 4096 June 2 17:57/root/te st/shelltest-rw-r--r-- 2 root root 0 Dec 21:30/root/test/linuxdaxue.com
List all the files and directories under the current working directory; add "/" to the name, and the file name to add "*"
#ls-afcpptest/ lntst/ shelltest/ linuxdaxue.com
Well, for the introduction of the Linux LS command, let's talk about here, more Linux command details, see: Linux Command Quick check manual
- Copyright Notice: original article, 3 months ago, published by the University of Linux (linuxdaxue.com), a total of 2366 words.
- reprint Please specify: Linux command – ls command | Linux University
Linux command – ls command