ls
We can use this command to list out all files and directories present in the given directory

If you add a folder name or path, it will print that folder contents:
ls /demo

ls accepts a lot of options
ls -1
List files one per line

ls -a
List all files, including hidden files. The -a flag stands for “all"
Hidden files are files that start with a dot ( . )

. refers to current directory.
.. refers to parent directory.
ls -l
Long Listing: Compared to the plain ls , this returns much more information.

You have, from left to right:
first column: file type and file permissions. Every file row begins with the file type and then specifies the access permissions associated with the files.
Type | Description |
---|---|
d | Directory File |
- | Normal File |
l | Link File |
c | Character Special File |
b | Block Special File |
second column: number of links to that file
third column: owner of the file or the superuser (who has the administrating power)
fourth column: group of owner/superuser
fifth column: file size
sixth column: date and time when the file was created or lastly modified
last column: name of the file or the directory
Below diagram explain what is the meaning of each part of the output(left to right)

ls -d */
Only list directories

Other Useful options:
• -t: Sorts files by modification time, with the most recently modified files appearing first.
• -r: Reverses the order of the sort
• -S: Sorts files by size. By default, it sorts in descending order (largest files first).
• -R: Recursively lists directories and their contents.
• -h: Displays file sizes in a human-readable format, using units like kilobytes (K), megabytes (M), gigabytes (G), etc.
• -F: Appends a character to each file name to indicate the file type:
/ | Directory |
* | Executable File |
@ | Symbolic Link |
| | Named Pipe (FIFO) |
= | Socket |
We can also use multiple options at a time:

