More with the ls command
Once you become a linux user you’ll need some basic commands like the ls command..
Ls command :
Ls is a shell command that list all contents (either files or directories) of the current directory.
So if you want to see the content of your current directory using terminal just type ls and push enter and this is an exemple of the result :
The syntax of Ls :
$ ls [options] [file|dir]
Options of Ls command :
Ls have some usefull options for example :
ls -a
: list all files including hidden file starting with ‘.’ls — color
: colored list [=always/never/auto]ls -d
: list directories — with ‘ */’ls -F
: add one char of */=>@| to enteriesls -i
: list file’s inode index numberls -l
: list with long format — show permissionsls -la
: list long format including hidden filesls -lh
: list long format with readable file sizels -ls
: list with long format with file sizels -r
: list in reverse orderls -R
: list recursively directory treels -s
: list file sizels -S
: sort by file sizels -t
: sort by time & datels -X
: sort by extension name
But what ‘s exactly happens when you type ls -l?
ls -l command:
ls -l
means list content of the current directory in a long format so the option -l means LONG FORMAT, let’s see an example of the output of this command :
Once you push enter the content of the directory shows line per line each line contain :
- Name of a file or a folder
- Date of creation of the item
- The size in bytes
- Name of the createur (name of the current user)
- The permissions of the file
That’s the magic of the command ls and it’s options.
Happy learning , hope you find this article useful.