One of the basic command in Linux is ls. Without this command, we may find difficulties to explore the content if directories. This command must known by everyone who want to learn Linux.
### What is ls ###
ls command is used to list files and directories. By default, it will be list the content of current directory. With some parameters, we can do more using ls. Here are the samples of ls usage in day-to-day operation
#### 1. Run ls without parameter ####
Running ls without parameter will display a list of files and or directories only. No other information can be seen from the output
Using -l character (small L letter), will display a long listing of the content of current directory. On the next examples, we will combine -l parameter (mostly) to get better result.
The first letter **d** does the content is directory or file. On the screenshot above, Desktop, Documents, Downloads and lynis-1.3.8 are directories. If it - (**minus sign**) it means that the content is file. While if it equal with l (**small L character**), means the content is link file.
The next 9 character is about file permission. With the **first 3 rwx** characters are for Owner of the file, **the second 3 characters** are for Group owner of the file and **the last 3 characters** are for worldwide access to the file.
**2nd column**
This tell us about how many link to this file
**3rd column**
This tell us about who is the owner of the file / directory
**4th column**
This tell us about who the group owner of the file / directory
**5th column**
This tell us about the size of the file / directory in bytes unit. Except for directories, the size will always count as 4096 bytes
**6th column**
This tell us about the last time and date the file is modified
**7th column**
This tell us the filename or directory name
#### 3. Show the size of file ####
Reading size in bytes unit can confuse us. To read 6,5 M is easier compare with reading 6727680 byte. To do this, we can use -hcombine with **-l** parameter. **-h parameter means human readable**
After we can show the file size, we may want to sort it by file size. We can use -S parameter to to this. The list will be sort by the largest file size first.
From the example above, we know that **user pungki has UID** = 1000 and **GID = 1000**. While **root group has GID = 0**
#### 11. Print with no color ####
Some Linux distribution is enable color options to ls command. This will make ls print the list in color. If you don’t want it, you can use **--color=never** parameter.
For listing your home directory, we can short the directory using “~” (**tilde sign**). So you don’t have to type your full directory name. Let say if the home directory name is **/home/pungki**, then **~** sign have the meaning with /home/pungki.
That’s some parameters which can be used on day-to-day operation. Of course you can always consult with ls manual page by typing **man ls** or **ls --help** on your console to explore more detail.