Linux Commands: ls
ls is the Linux command to list the content of a directory. You can list all the files and folders inside a directory. Let's try it in your terminal.
You can pass arguments to
ls to change the output. Let's take a look at
It has more detailed information as compared to
ls. It uses two flags
a is used to show all the files even if the files are hidden(Hidden files are the one which starts with a dot at the beginning).
l is used to show details about each file and folder. Let me explain to you what exactly are those. We will take one of the lines from output.
drwxr-xr-x 12 umesh staff 384 Dec 11 2018 .git
- drwxr-xr-x: This defines the permission of the file.
- 12: It tells the number of links to that file.
- umesh: This signifies the username of the owner of the file
- staff: This signifies the group of the file.
- 384: file size in bytes.
- Dec 11 2018: file created/updated datetime.
- .git: filename.
There are a bunch of flags available that can be used to modify the output of the
ls command. I am listing a few of them down below try them out in your terminal and let me know your experience and which one is your favorite in the comments.
- l - List files and directories in the long format
- a - Include directory entries whose names begin with a dot (.).
- d - Directories are listed as plain files (not searched recursively).
- i - For each file, print the file's file serial number (inode number).
- G – Enable colorized output.
- h – List the size of the files and directories in Human Readable format.
- S - Sort files by size
If you liked this blog please feel free to share with others, if you are sharing it on twitter please tag @imumesh18 . If you are interested in more of these please subscribe to my newsletter.
Interested in reading more such articles from Umesh Yadav?
Support the author by donating an amount of your choice.