Linux ls Command
The ls
command in Linux (short for "list directory contents") is used to display the contents of a specified working directory (list the files and subdirectories contained in the current working directory).
Syntax
ls [-alrtAFR] [name...]
Parameters:
-a: Display all files and directories, including hidden files (those starting with
.
)-l: Display in long format, including file type, permissions, owner, file size, and more
-r: Display files in reverse order (originally sorted by alphabetical order)
-t: Display files sorted by creation time, with the newest first
-A: Similar to -a, but does not list "." (current directory) and ".." (parent directory)
-F: Append a symbol after the file names; for example, executable files are followed by "*", directories by "/"
-R: List files in subdirectories recursively
Examples
List all directories under the root directory ():
# ls /
bin dev lib media net root srv upload www
boot etc lib64 misc opt sbin sys usr
home lost+found mnt proc selinux tmp var
List all files starting with 's' in the current working directory, sorted by modification time, with the newest last:
ls -ltr s*
List all directories and files under the /bin directory with detailed information:
ls -lR /bin
List all files and directories in the current working directory; append "/" to directory names and "*" to executable files:
ls -AF