Here are some common options for the ls command:
-l: This option displays the files and directories in a long listing format, which includes additional information such as permissions, ownership, file size, and timestamps.
BASH[oracle@bracecoder ~]$ ls -l
total 4
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Desktop
drwxr-xr-x. 2 oracle oinstall 23 Nov 24 11:24 dir1
drwxr-xr-x. 2 oracle oinstall 35 Nov 24 11:24 dir2
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Documents
drwxr-xr-x. 4 oracle oinstall 70 Nov 10 20:20 Downloads
-rw-r--r--. 1 oracle oinstall 22 Nov 24 11:07 file1.txt
-rw-r--r--. 1 oracle oinstall 0 Nov 24 11:01 file2.txt
--w-r-x---. 1 oracle oinstall 0 Nov 24 10:42 file.txt
drwxr-xr-x. 2 oracle oinstall 25 Nov 11 18:34 HR
drwxr-xr-x. 2 oracle oinstall 197 Nov 11 18:27 human_resources
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Music
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Pictures
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Public
drwxr-xr-x. 2 oracle oinstall 62 Nov 10 20:21 scripts
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Templates
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Videos
[oracle@bracecoder ~]$
-a: This option shows hidden files and directories, which are files and directories that have a "." prefix in their names.BASH[oracle@bracecoder ~]$ ls -la
total 36
drwx------. 23 oracle oinstall 4096 Jan 29 19:44 .
drwxr-xr-x. 4 root root 33 Nov 10 20:00 ..
-rw-------. 1 oracle oinstall 3463 Jan 28 10:42 .bash_history
-rw-r--r--. 1 oracle oinstall 18 Aug 2 16:35 .bash_logout
-rw-r--r--. 1 oracle oinstall 174 Nov 10 20:21 .bash_profile
-rw-r--r--. 1 oracle oinstall 376 Aug 2 16:35 .bashrc
drwxr-xr-x. 12 oracle oinstall 269 Nov 10 21:01 .cache
drwx------. 12 oracle oinstall 272 Jan 27 23:57 .config
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Desktop
drwxr-xr-x. 2 oracle oinstall 23 Nov 24 11:24 dir1
drwxr-xr-x. 2 oracle oinstall 35 Nov 24 11:24 dir2
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Documents
drwxr-xr-x. 4 oracle oinstall 70 Nov 10 20:20 Downloads
-rw-------. 1 oracle oinstall 16 Nov 10 20:03 .esd_auth
-rw-r--r--. 1 oracle oinstall 22 Nov 24 11:07 file1.txt
-rw-r--r--. 1 oracle oinstall 0 Nov 24 11:01 file2.txt
--w-r-x---. 1 oracle oinstall 0 Nov 24 10:42 file.txt
drwxr-xr-x. 2 oracle oinstall 25 Nov 11 18:34 HR
drwxr-xr-x. 2 oracle oinstall 197 Nov 11 18:27 human_resources
-rw-------. 1 oracle oinstall 3414 Jan 29 19:44 .ICEauthority
drwxr-xr-x. 3 oracle oinstall 19 Nov 10 21:01 .java
-rw-r--r--. 1 oracle oinstall 172 Sep 13 20:15 .kshrc
drwx------. 3 oracle oinstall 19 Nov 10 20:03 .local
drwxr-xr-x. 4 oracle oinstall 39 Apr 1 2022 .mozilla
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Music
drwxr-x---. 2 oracle oinstall 40 Nov 10 21:18 .oracle_jre_usage
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Pictures
drwxr-----. 3 oracle oinstall 19 Nov 10 20:03 .pki
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Public
drwxr-xr-x. 2 oracle oinstall 62 Nov 10 20:21 scripts
drwx------. 2 oracle oinstall 6 Nov 10 22:48 .ssh
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Templates
drwxr-xr-x. 2 oracle oinstall 6 Nov 10 20:03 Videos
[oracle@bracecoder ~]$
-h: This option shows file sizes in a human-readable format, meaning that the sizes are displayed in a more easily readable format like "1K" or "234M" instead of bytes.BASH[oracle@bracecoder Downloads]$ ls -lh
total 5.6G
drwxr-xr-x. 4 oracle oinstall 55 Nov 10 20:57 19-c
-rw-r--r--. 1 oracle oinstall 2.9G Feb 25 2022 19-c.zip
drwxr-xr-x. 65 oracle oinstall 4.0K Nov 10 20:33 grid-19c
-rw-r--r--. 1 oracle oinstall 2.7G Nov 10 11:45 grid-19c.zip
[oracle@bracecoder Downloads]$-R: This option recursively lists files and directories in subdirectories.
BASH[muthu@bracecoder ~]$ ls -R
.:
Desktop dir1 dir2 Documents Downloads file.txt HR Music Pictures Public Templates Videos
./Desktop:
./dir1:
file1.txt
./dir2:
dir1 file1.txt
./Documents:
./Downloads:
./HR:
hr_main.log
./Music:
./Pictures:
./Public:
./Templates:
./Videos:
[muthu@bracecoder ~]$
-t: This option sorts the files and directories by modification time, with the most recently modified files appearing first.-S: This option sorts the files and directories by size, with the largest files appearing first.
--color: This option highlights the files and directories based on their type or attributes.
-1 : This option display each file on separate line.
These are just a few of the many options available for the ls command, and there are many others available depending on the specific implementation.
That’s it.
INFO
If you would have any questions or concerns, please leave your comments. I would be glad to explain in more details. Thank you so much for all your feedback and support!
Comments (0)
Please sign in to leave a comment.
No comments yet. Be the first to share your thoughts!