How to use the linux ls command

王林
Release: 2023-06-02 22:10:39
forward
2636 people have browsed it

ls command is the most commonly used command under Linux. The ls command is the abbreviation of list. By default, ls is used to print out the list of the current directory. If ls specifies another directory, the list of files and folders in the specified directory will be displayed. Through the ls command, you can not only view the files contained in the Linux folder, but also view file permissions (including directory, folder, file permissions), view directory information, and so on. The ls command is used a lot in daily Linux operations!

1. Command format:
ls [option] [directory name]

2 . Command function:

List all subdirectories and files in the target directory.

3. Commonly used parameters :

-a, –all lists all files in the directory, including implicit files starting with .
-a Same as -a, but do not list "." (indicating the current directory) and ".." (indicating the parent directory of the current directory).
-c With -lt: Sort by ctime and display ctime (the time when the file status was last changed) With -l: Display ctime but sort by name Otherwise: Sort by ctime
-c Each column is listed from top to bottom Item
–color[=when] Controls whether color resolution files are used. when can be one of 'never', 'always' or 'auto'
-d, –directory will display the directory as a file, rather than displaying the files below it.
-d, –dired produces results suitable for the dired mode of emacs
-f does not sort the output files, the -au option takes effect, and the -lst option fails
-g is similar to -l, but does not List owners
-g, –no-group Do not list any information about groups
-h, –human-readable List file sizes in an easy-to-understand format (e.g. 1k 234m 2g)
–si Like -h, but the file size is taken to the power of 1000 instead of 1024
-h, –dereference-command-line uses the real destination
–indicator-style= method indicated by the symbolic link in the command line Specify the indicator symbol after each project name: none (default), classify (-f), file-type (-p)
-i, –inode prints the inode of each file No.
-i, –ignore=style does not print out any items that match the shell wildcard character