Linux commands-ls commands and linux commands ls
Today, we will introduce common commands in Linux. First, we will introduce the most frequently used commands in Linux-the ls command.
For more information about Linux commands, see the quick query manual for Linux commands.
The linux ls command is used to display the content in the specified working directory (list the files and subdirectories contained in the current working directory), and to view the permissions of files (including directories, folders, and files ), viewing directory information is a very powerful and useful command.
I. ls command syntax
ls [-alrtAFR] [name...]
Ii. ls Command Parameters
The following describes some common parameters of ls commands.
-A: all files and directories are displayed. (The names of files or directories must start ". "is considered as a hidden file, not listed)-l except for the file name, the file type, permission, owner, file size, and other information are also listed in detail-r displays the file in reverse order (originally in alphabetical order) -t lists the files in the order of creation time-A is the same as-a, but not ". "(current directory) and ".. "(parent directory)-F adds a symbol after the listed file name. For example, if the executable file is added with" * ", the directory is added with"/"-R if there is a file under the directory, the following files are listed in sequence.
Iii. Examples of ls commands
The following is an example of how to use 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 starting with B in the current working directory:
$ls -lrt b*backupfile:total 76-rw-r--r-- 1 root root 23376 Sep 6 2015 date-rw-r--r-- 1 root root 23376 Sep 6 2015 20150906144055.tar.gz-rw-r--r-- 1 root root 1168 Sep 6 2015 backup.log-rw-r--r-- 1 root root 23376 Sep 6 2015 20150906.tar.gzbaktars:total 18272-rw-r--r-- 1 root root 11754834 Jun 11 2011 Python-2.7.2.tar.bz2-rw-r--r-- 1 root root 1407934 Aug 30 2011 sqlite-amalgamation-3.6.20.tar.gz-rw-r--r-- 1 root root 253351 Mar 12 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--- 18 1000 1002 4096 Mar 1 18:51 Python-2.7.2-rw-r--r-- 1 root root 370026 Apr 16 18:25 master.zipdrwxr-xr-x 9 root root 4096 Apr 16 18:46 mod_python-master
List all directories and files in the ShellTest Folder:
$ls -lR ShellTest/ShellTest/:total 52-rwxr-xr-x 1 root root 1282 May 30 17:41 case2.sh-rwxr-xr-x 1 root root 512 May 30 18:59 case3.sh-rwxr-xr-x 1 root root 20 Jun 2 15:33 date.txt-rwxr-xr-x 1 root root 119 Jun 2 16:53 echo.sh-rwxr-xr-x 1 root root 224 Jun 1 21:11 fun1.sh-rwxr-xr-x 1 root root 197 Jun 1 21:30 fun2.sh-rwxr-xr-x 1 root root 14 Jun 2 17:55 num1.sh-rwxr-xr-x 1 root root 123 Jun 2 17:57 num2.sh-rwxr-xr-x 1 root root 18 Jun 2 17:06 num.txt-rwxr-xr-x 1 root root 276 May 30 20:50 select1.sh-rwxr-xr-x 1 root root 350 May 30 20:56 select2.sh-rwxr-xr-x 1 root root 182 May 30 16:14 test.sh-rwxr-xr-x 1 root root 5 Jun 2 17:02 who.txt
Lists the absolute paths of all files (including hidden files) in the current directory without recursion.
#find $PWD -maxdepth 1 | xargs ls -lddrwxr-xr-x 5 root root 4096 May 31 20:48 /root/testdrwxr-xr-x 14 root root 4096 Feb 18 09:24 /root/test/cpptestdrwxr-xr-x 2 root root 4096 May 31 21:21 /root/test/lnTstdrwxr-xr-x 2 root root 4096 Jun 2 17:57 /root/test/ShellTest-rw-r--r-- 2 root root 0 Dec 25 21:30 /root/test/linuxdaxue.com
List all files and directories under the current working directory. Add "/" after the directory name, and add "*" after the executable file name "*"
#ls -AFcpptest/ lnTst/ ShellTest/ linuxdaxue.com
Now, let's talk about Linux ls commands first. For more information about Linux commands, see the quick query manual for Linux commands.
- Copyright:This site's original article, published three months ago by the Linux University (Linuxdaxue.com), contains 2366 words.
- Reprinted Please note:Linux Command explanation-ls command | Linux University