Unix commands - ls

/ #Bash


In this short post, I'll explain how and what you can do with the unix command "ls"

Explanation

"ls" is used for listing out the contents of a directory (or folder). It's much more powerful than just giving you a list, you can also change the order, get extra information and similar.

Examples

# Basic example
ls

# This will give you a list of the files and folders.
# One file/folder per line
ls -l

# This will give you a list of the files and folders, but listed out one item per line.
# Include hidden files and folders
ls -a

# This will give you a list of the files and folders, including the hidden ones.
# Combining options
ls -la

# This will give you a list of the files and folders, including the hidden ones. The items will be listed out one per line.
# All files in descending orders
ls -larth

# -l = one item per line
# -a = include hidden files and folders
# -r = reversed order
# -t = sort by time (modified)
# -h = include the size of the files

Comments

No comments yet...

Add comment

Info

Please log in to comment!

Newsletter

Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.