Methods of payment Abuse

What does the ls command do in Linux

16.02.2023, 17:34
The ls command in Linux is used to output the contents of the current working directory in the terminal. By default, the ls command displays the names of files and subdirectories in the current directory.

Command Options

Some common options of the ls command include:
-l: displays a long output format that includes additional information about each file, such as access rights, owner, group, size, creation date, etc.
 
-a: displays all files, including hidden files starting with a dot.
 
-h: displays the size of files in human-readable format (for example, "1K", "2M", etc.).
 
-t: displays files in the order of the last modification, starting with the most recent.
 
-r: displays files in reverse order.
Example of using the ls command with the -l option:
$ ls -l
total 0
drwxr-xr-x 2 user user 6 Feb 28 14:25 dir1
-rw-r--r-- 1 user user 0 Feb 28 14:25 file1.txt
-rw-r--r-- 1 user user 12 Feb 28 14:25 file2.txt
In the example above, each line represents information about a file or directory in the current directory, including access rights, number of hard links, owner, group, size, date of last modification and file name.