≡ Menu

Unix LS Command: 15 Practical Examples

Ls Command for Ubuntu, Debian, Fedora, Red Hat, AIX, SUSE, CentOSls – Unix users and sysadmins cannot live without this two letter command. Whether you use it 10 times a day or 100 times a day, knowing the power of ls command can make your command line journey enjoyable.

In this article, let us review 15 practical examples of the mighty ls command.

1. Open Last Edited File Using ls -t

To open the last edited file in the current directory use the combination of ls, head and vi commands as shown below.

ls -t sorts the file by modification time, showing the last edited file first. head -1 picks up this first file.

$ vi first-long-file.txt
$ vi second-long-file.txt

$ vi `ls -t | head -1`
[Note: This will open the last file you edited (i.e second-long-file.txt)]

2. Display One File Per Line Using ls -1

To show single entry per line, use -1 option as shown below.

$ ls -1
bin
boot
cdrom
dev
etc
home
initrd
initrd.img
lib

3. Display All Information About Files/Directories Using ls -l

To show long listing information about the file/directory.

$ ls -l
-rw-r----- 1 ramesh team-dev 9275204 Jun 13 15:27 mthesaur.txt.gz
  • 1st Character – File Type: First character specifies the type of the file.
    In the example above the hyphen (-) in the 1st character indicates that this is a normal file. Following are the possible file type options in the 1st character of the ls -l output.

    • Field Explanation
    • – normal file
    • d directory
    • s socket file
    • l link file
  • Field 1 – File Permissions: Next 9 character specifies the files permission. Each 3 characters refers to the read, write, execute permissions for user, group and world In this example, -rw-r—– indicates read-write permission for user, read permission for group, and no permission for others.
  • Field 2 – Number of links: Second field specifies the number of links for that file. In this example, 1 indicates only one link to this file.
  • Field 3 – Owner: Third field specifies owner of the file. In this example, this file is owned by username ‘ramesh’.
  • Field 4 – Group: Fourth field specifies the group of the file. In this example, this file belongs to ”team-dev’ group.
  • Field 5 – Size: Fifth field specifies the size of file. In this example, ‘9275204’ indicates the file size.
  • Field 6 – Last modified date & time: Sixth field specifies the date and time of the last modification of the file. In this example, ‘Jun 13 15:27’ specifies the last modification time of the file.
  • Field 7 – File name: The last field is the name of the file. In this example, the file name is mthesaur.txt.gz.

4. Display File Size in Human Readable Format Using ls -lh

Use ls -lh (h stands for human readable form), to display file size in easy to read format. i.e M for MB, K for KB, G for GB.

$ ls -l
-rw-r----- 1 ramesh team-dev 9275204 Jun 12 15:27 arch-linux.txt.gz*

$ ls -lh
-rw-r----- 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz

5. Display Directory Information Using ls -ld

When you use “ls -l” you will get the details of directories content. But if you want the details of directory then you can use -d option as., For example, if you use ls -l /etc will display all the files under etc directory. But, if you want to display the information about the /etc/ directory, use -ld option as shown below.

$ ls -l /etc
total 3344
-rw-r--r--   1 root root   15276 Oct  5  2004 a2ps.cfg
-rw-r--r--   1 root root    2562 Oct  5  2004 a2ps-site.cfg
drwxr-xr-x   4 root root    4096 Feb  2  2007 acpi
-rw-r--r--   1 root root      48 Feb  8  2008 adjtime
drwxr-xr-x   4 root root    4096 Feb  2  2007 alchemist

$ ls -ld /etc
drwxr-xr-x 21 root root 4096 Jun 15 07:02 /etc

6. Order Files Based on Last Modified Time Using ls -lt

To sort the file names displayed in the order of last modification time use the -t option. You will be finding it handy to use it in combination with -l option.

$ ls -lt
total 76
drwxrwxrwt  14 root root  4096 Jun 22 07:36 tmp
drwxr-xr-x 121 root root  4096 Jun 22 07:05 etc
drwxr-xr-x  13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x  13 root root  4096 Jun 20 23:12 root
drwxr-xr-x  12 root root  4096 Jun 18 08:31 home
drwxr-xr-x   2 root root  4096 May 17 21:21 sbin
lrwxrwxrwx   1 root root    11 May 17 20:29 cdrom -> media/cdrom
drwx------   2 root root 16384 May 17 20:29 lost+found
drwxr-xr-x  15 root root  4096 Jul  2  2008 var

7. Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr

To sort the file names in the last modification time in reverse order. This will be showing the last edited file in the last line which will be handy when the listing goes beyond a page. This is my default ls usage. Anytime I do ls, I always use ls -ltr as I find this very convenient.

$ ls -ltr

total 76
drwxr-xr-x  15 root root  4096 Jul  2  2008 var
drwx------   2 root root 16384 May 17 20:29 lost+found
lrwxrwxrwx   1 root root    11 May 17 20:29 cdrom -> media/cdrom
drwxr-xr-x   2 root root  4096 May 17 21:21 sbin
drwxr-xr-x  12 root root  4096 Jun 18 08:31 home
drwxr-xr-x  13 root root  4096 Jun 20 23:12 root
drwxr-xr-x  13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x 121 root root  4096 Jun 22 07:05 etc
drwxrwxrwt  14 root root  4096 Jun 22 07:36 tmp

8. Display Hidden Files Using ls -a (or) ls -A

To show all the hidden files in the directory, use ‘-a option’. Hidden files in Unix starts with ‘.’ in its file name.

$ ls -a
[rnatarajan@asp-dev ~]$ ls -a
.                             Debian-Info.txt
..                            CentOS-Info.txt
.bash_history                 Fedora-Info.txt
.bash_logout                  .lftp
.bash_profile                 libiconv-1.11.tar.tar
.bashrc                       libssh2-0.12-1.2.el4.rf.i386.rpm

It will show all the files including the ‘.’ (current directory) and ‘..’ (parent directory). To show the hidden files, but not the ‘.’ (current directory) and ‘..’ (parent directory), use option -A.

$ ls -A
Debian-Info.txt               Fedora-Info.txt
CentOS-Info.txt               Red-Hat-Info.txt
.bash_history                 SUSE-Info.txt
.bash_logout                  .lftp
.bash_profile                 libiconv-1.11.tar.tar
.bashrc                       libssh2-0.12-1.2.el4.rf.i386.rpm
[Note: . and .. are not displayed here]

9. Display Files Recursively Using ls -R

$ ls  /etc/sysconfig/networking
devices  profiles

$ ls  -R /etc/sysconfig/networking
/etc/sysconfig/networking:
devices  profiles

/etc/sysconfig/networking/devices:

/etc/sysconfig/networking/profiles:
default

/etc/sysconfig/networking/profiles/default:

To show all the files recursively, use -R option. When you do this from /, it shows all the unhidden files in the whole file system recursively.

10. Display File Inode Number Using ls -i

Sometimes you may want to know the inone number of a file for internal maintenance. Use -i option as shown below to display inone number. Using inode number you can remove files that has special characters in it’s name as explained in the example#6 of the find command article.

$ ls -i /etc/xinetd.d/
279694 chargen      279724 cups-lpd  279697 daytime-udp
279695 chargen-udp  279696 daytime   279698 echo

11. Hide Control Characters Using ls -q

To print question mark instead of the non graphics control characters use the -q option.

ls -q

12. Display File UID and GID Using ls -n

Lists the output like -l, but shows the uid and gid in numeric format instead of names.

$ ls -l ~/.bash_profile
-rw-r--r--  1 ramesh ramesh 909 Feb  8 11:48 /home/ramesh/.bash_profile
$ ls -n ~/.bash_profile
-rw-r--r--  1 511 511 909 Feb  8 11:48 /home/ramesh/.bash_profile

[Note: This display 511 for uid and 511 for gid]

13. Visual Classification of Files With Special Characters Using ls -F

Instead of doing the ‘ls -l’ and then the checking for the first character to determine the type of file. You can use -F which classifies the file with different special character for different kind of files.

$ ls -F
Desktop/  Documents/  Ubuntu-App@  firstfile  Music/  Public/  Templates/

Thus in the above output,

  • / – directory.
  • nothing – normal file.
  • @ – link file.
  • * – Executable file

14. Visual Classification of Files With Colors Using ls -F

Recognizing the file type by the color in which it gets displayed is an another kind in classification of file. In the above output directories get displayed in blue, soft links get displayed in green, and ordinary files gets displayed in default color.

$ ls --color=auto
Desktop  Documents Examples firstfile Music  Pictures  Public  Templates  Videos

15. Useful ls Command Aliases

You can take some required ls options in the above, and make it as aliases. We suggest the following.

  • Long list the file with size in human understandable form.
    alias ll="ls -lh"
  • Classify the file type by appending special characters.
    alias lv="ls -F"
  • Classify the file type by both color and special character.
    alias ls="ls -F --color=auto"

Awesome Linux Articles

Following are few awesome 15 examples articles that you might find helpful.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • George July 13, 2009, 2:14 am

    I never imagined that I’d value an email subscription more than I do with The Geek Stuff. Honestly, I just did it for the book–but I’m finding that I’m learning enormous amounts from these entries.

  • Francesco Talamona July 13, 2009, 5:00 am

    I couldn’t understand the use of “-q” switch.

  • Gabriel Rodriguez July 13, 2009, 7:05 am

    Very useful!, thanks a lot

  • KaliSurf July 13, 2009, 8:53 am

    Wow!!!! great post…

  • Vince Stevenson July 13, 2009, 10:31 am

    Thanks for this blog post. I wasn’t familiar with ls -A. Rgds Vince

  • Binny V A July 13, 2009, 12:08 pm

    For the recursion command, I’ll recommend ls -R -1

  • José July 13, 2009, 1:53 pm

    yeah!!!….good post…..but, how we make to list files and directories en groups?

  • Gagan Brahmi July 13, 2009, 3:53 pm

    Hi,

    There are other characters which can be seen when using the ls -l command. However, I am not sure what those mean.

    Is there any chance that you can tell me what those character refere to?

    The following are the three additional ones which I need to know:

    crw-r–r–
    brw-r–r–
    prw-r–r–

    So it is c, b & p that I need to know the meaning for.

  • billyduc July 13, 2009, 9:31 pm

    listing directory only : ls -d */

  • Gagan Brahmi July 14, 2009, 1:08 pm

    You can get the list of hidden directory only using the following command:

    ls -d .*/

  • Ramesh Natarajan July 14, 2009, 9:32 pm

    @George, Thanks for those very kind words. I’m very happy to hear that the eBook and these articles are being helpful to you.

    @Francesco, Thanks for reference to the article that explains -q option. To make it easy for others, I’m quoting that example here.

    Another very important switch is –hide-control-chars (or -q). Linux filenames can contain any character, even control characters. It is possible to create a filename with hidden characters in the name. In these cases, you can’t rename or delete the file unless you know what the hidden characters are. Contrary to what the name implies, the –hide-control-chars switch displays any unprintable characters in the filename as question marks, making their locations visible.

    $ rm orders.txt
    rm: orders.txt non-existent
    $ ls –color=never –classify –-hide-control-chars
    archive/ check-orders.sh* orde?rs.txt

    @Gabriel, @KaliSurf, @Vince, Thanks for the nice comment. I’m glad that you found this article helpful.

    @Binny, Combining the item#2 (ls -1) and item#9 (ls -R) mentioned in the article and using it as (ls -R -1) is definitely a good idea that makes the output readable. Thanks for pointing that out.

    @Jose, As Billyduct pointed out, Use ls -d */ to display only the directories and not the files.

    @Gagan,

    c indicates Character devices. For example, do “ls -l /dev/tty*” — you’ll see c in front of all terminal devices as shown below.

    $ ls -l tty*
    crw-rw-rw-  1 root root 5,  0 Jul  4 00:38 tty
    crw-rw----  1 root root 4,  0 Feb  8  2008 tty0
    crw-------  1 root root 4,  1 Feb  8  2008 tty1
    

    b indicates Block Devices. For example, do “ls -l /dev/sda*” (or) hda and you’ll see b in front of all hard disk partitions indicating it is a block device as shown below.

    $ ls -l /dev/sda*
    brw-rw----  1 root disk 8, 0 Feb  8  2008 /dev/sda
    brw-rw----  1 root disk 8, 1 Feb  8  2008 /dev/sda1
    

    p indicates it is a named pipe (FIFO) as shown below.

    $ ls -l | grep ^p
    prw-------  1 root root        0 Feb  8  2008 initctl
    

    @Billyduc, Excellent example to show only directories in the ls output using ls -d */ . Thanks for the suggestion.

  • NARDI July 24, 2009, 7:20 am

    part of my .bashrc file:
    alias la=’ls -lA’
    alias l.=’ls -ld .*’
    alias ld=’ls -ld .’
    alias ll=’ls -lFh’
    alias lt=’ls -lFhtr’
    but i’ll now replace ld wit ls -ld */ for it’s much more usefull. the only new one for me =)

    JFYI notice the numbers that appears instead of ‘file size’ column in ls -l /dev
    These are major and minor numbers of device. You can examine their meanings in
    /usr/src/linux/Documentation/devices.txt
    documentation file (or where you have your kernel documentation located). If you’re really interested this can entertain you for quite a while =))

  • Ramesh Natarajan July 25, 2009, 12:18 am

    @Nardi,

    Thanks for sharing your .bashrc aliases. You got very practical and useful ls aliases setup. Also, thanks for pointing the devices.txt documentation file location that talks about major and minor numbers.

    For those who are interested, we already wrote an article about Linux Major and Minor Device Numbers.

  • Anand babu September 24, 2009, 1:40 am

    changing mode is very critical tochange to root

  • jsonx October 7, 2009, 5:05 pm

    Thanks. Your tutorials are very clear and helpful.

  • Suhrid December 7, 2009, 10:23 pm

    Thanks for this very useful summary of the ls command.

  • Arun January 4, 2010, 4:19 am

    Good Post

    But what is the ls command to list the files by Size wise(Ascending / Descending)

  • nardi January 4, 2010, 10:57 am

    @Arun
    read manual (type: man ls)
    $ ls -S … biggest files first
    $ ls -Sr … smallest files first
    or if you like it long and understandable (I thing this is handy only for aliases in config files):
    $ ls –sort=size –reverse

  • Yasodha January 5, 2010, 1:45 am

    Great !!! Really helpful post…. Thanks a lot……

  • rajesh February 9, 2010, 1:56 am

    List files based on their size.

    ls -l|sort -n

  • santanu February 26, 2010, 9:23 pm

    nice post

  • metrit March 6, 2010, 5:58 am

    when i want to print only the ones starting with t for example wich is the right command ??

  • nardi March 8, 2010, 3:07 am

    @metrit
    use regular expressions
    see man regexp or google “bash regular expressions”

    list files starting with ‘t’:
    $ ls t*

  • Avin March 19, 2010, 7:44 am

    Frankly speaking. I use LS command lots of time but never thought It is as strong command that much.
    Thanks for the cool LS options.

  • Uma Suresh May 6, 2010, 12:30 pm

    I was just looking for a command like ls -1 which prints single file entry per line to be passed into a script and I found this great post. Thanks much for all your tips.

  • Rituraj June 3, 2010, 5:41 am

    Sir I am new user of this site ,and i want to learn linux so plz provide me some notes and tips

    Thanks & Regards
    Rituraj

  • Raj June 4, 2010, 8:32 am

    nice article. I read the grep one – awsome tips. Is there any way to that these settings can be populated to hundreds of servers without modifying bashrc or profile? so i want to hav one .profile/bashrc and want that to be effective whenever i login to any host i manage.

  • Ram July 22, 2010, 3:09 pm

    I just wonder what exactly the size for a directory in the “ls -l” output. Even empty directory show this as 4096! what does that mean?
    Can anyone shed some light?
    Thanks

  • NARDI August 1, 2010, 1:37 am

    @Ram
    the size of “directory” itself depends only on the number of files in it. it’s because directory, as written on hard drive, is just an list of files and adresses of that files on hard drive.

    to see the total size of directory, you should use other utils such as ncdu (which you’d probably need to install, but it’s worth it!) or the ‘du’ command in this form:
    du -hs *
    this counts and prints “total_size filename” pair for all files and directoriess in working directory.

  • Anonymous August 16, 2010, 5:17 am

    Very Very userful for techies

  • pydiramu September 29, 2010, 12:39 am

    Hi, Its very helpful

  • c3rr4t0 October 25, 2010, 12:43 pm

    Hi Ramesh!
    A very handy site.
    I have a question:
    What about |, =, and > in ls -F ?

    Thanks for read me.

  • mnrao December 26, 2010, 11:03 am

    I know that files in current dir starting with “txt” can be listed by
    ls txt*
    but can I use ls to list files starting with txt in all lower level directories as well.

  • NARDI December 26, 2010, 4:45 pm

    @mnrao not ls itself. you can use command like
    ls -R ./* | grep ‘/txt’

  • shahid January 13, 2011, 4:09 am

    Dears!

    pls help to find time command which shows only time .

    T&R
    shahid

  • bhupendra lohnai February 24, 2011, 4:22 am

    What are the advantages of unix OS?
    How can it better to the window operatin system?

  • Adhika March 13, 2011, 11:53 pm

    Hi Ramesh,

    May be you should also give the example to display a year in the ‘ls -ltr’ command.
    I’ve always used this command:
    ls -trh –time-style=’+%d-%b-%Y %H:%M:%S’

    for reference, I looked from: here, here, and here

  • Spoorthi N Gowda March 15, 2011, 12:12 am

    please help me in finding the answer for function of ls -l command in unix

  • Manju Arasaiah April 21, 2011, 10:57 pm

    is there a quick command to get the owner of the file? like ls -o (like this)? thx

  • karthikai April 23, 2011, 7:55 pm

    what is the use of ls -s(small s) command? i was confusing this…

  • jitu May 23, 2011, 2:56 pm

    i could’nt alias lv=”ls -f” please sir clear this topic

  • bala June 13, 2011, 8:26 pm

    really usefull for beginners

  • robinatw June 23, 2011, 4:52 am

    Awsome, i like this article..
    thank Ramesh and everybody…

    Robin

  • jitendra kumar dwivedi June 23, 2011, 1:35 pm

    thanks for deeply suggest for ls command. i want to learn.awk coomand

  • sam1985 July 9, 2011, 6:38 am

    Hi Ramesh, long time follower. Is there a way for ls to display alphabets in language other than English like Russian. I am on Windows and use Cygwin 1.7.10 & Mintty 0.9.9. Files that are in Russian are displayed using question marks ????.mp3. The font is Consolas and echo *.* shows
    file name perfectly making ls the culprit. Any ideas ?? Thanks!

  • gambit August 18, 2011, 7:09 am

    Hi Ramesh,

    ls -lh doesn’t seem to work on AIX 5, any idea how can i view my files in GB format?

    Thanks.

  • Sonika September 8, 2011, 12:28 am

    really good collection of commands

  • Aparna September 16, 2011, 4:34 am

    This website is very good. I am newbee to Unix and was trying to find out how the size of a file/folder is measured, finally i found ls -lh to my rescue in this website.

  • YM September 18, 2011, 8:36 pm

    Does anybody know how to list “one file” that is in each of the sub directories of root?

  • Haoza October 18, 2011, 7:38 am

    Didn’t understand point 14. Visual Classification of Files With Colors Using ls -F

  • kiran varma November 16, 2011, 4:51 am

    thanks for the information provided it is very usefull

  • Prescilla February 7, 2012, 7:27 am

    thanks for this very useful post. but can anyone tell me what the “total” means? that is the first line of every ls -l command and i haven’t figured out what it refers to.

  • Dave February 7, 2012, 9:13 am

    Wow, really you can’t do the equivalent of “dir *.txt /s” without typing something like ls -R | grep “.txt”..??
    Either I’ve missed something or I must have missed out on the decision to make it so the normal user can’t use the operating system without immersing themselves in decades of dedicated training…

  • Kalarani February 10, 2012, 11:11 pm

    pls anyone tell me the difference between regular expression and wildcard expression in unix?

  • Tushar March 5, 2012, 4:03 am

    I want to implement all ls command , How can i do it in inux
    rply please

  • ls March 5, 2012, 11:19 pm

    Hi try using the ‘man’ command.
    type –> man ls

  • nidhi March 6, 2012, 4:52 am

    Same here, this subscription is one which does not hurt after subscribing …its helping a lot in keeping linux fundamentals fresh. Thanks a lot for such a wonderful website and content

  • Shivani March 22, 2012, 3:06 am

    Hi,
    I want to count total number of files(files and directories) in a directory and create a file having this count.

  • Shivani March 22, 2012, 9:17 am

    I want to develop this functionality from a batch file.

  • wannabe March 25, 2012, 6:30 pm

    Thanks!
    I have a question.
    ls -l
    Field 5 – Size: Fifth field specifies the size of file. In this example, ’9275204′ indicates the file size.
    In case of directory, what means of “Field5”?
    If it is file, “Field 5” is file size. and If it is directory?

  • sam March 29, 2012, 8:27 am

    @ Shivani

    this should help set u in right direction -> find . -type f | wc -l
    also you can try ls -R1 but hard to distinguish between files & dirs.

  • Moum April 12, 2012, 6:38 am

    Hello,

    I know to retrieve the last file in a directory I can use this command:
    FIC=`ls -rt ${DIRLOG} | tail -n 1`
    Is it possible to recover all the files except the last one réepertoire with command ls ?

    Thx for your help

  • Root Lee May 24, 2012, 8:23 pm

    Very useful, I shared it over Google+

  • kk May 31, 2012, 9:29 am

    Can I get some some help,

    I need a ls -lrt kind of thing that displayes the year too. its May2012 and I have a file that shows Dec…..I would like to see the year please

  • mukilan June 18, 2012, 6:33 am

    how to seen the links using ls commands????

  • Rajesh July 18, 2012, 2:26 am

    Really it is useful

  • Gnanaprakasam August 24, 2012, 12:21 am

    Hi,
    I need a small help here in using ls with the output of date command. Here is my requirement.
    I need to list all the files that were created the previous day( sysdate -1) .
    I have used the following
    prevdate=`date +”%b %d” –date=”yesterday”`
    ls -lt | grep ‘$prevdate’
    It is not listing any files.
    Could you please help me here.

    Thanks
    Gnanaprakasam R

  • Marzieh August 30, 2012, 8:03 pm

    Hello, I just installed Fedora 17 and when I type ls -l I get:

    -rw-r–r– . 1 marzi marzi 4096 Aug 14 19:05 stuff

    Do you know what is the “.” after the File Permission field? I am confused……
    can you help please?

  • Prashant Tarudkar September 10, 2012, 1:31 am

    Hi ,
    I want to return those file whose third charcter should be a or e or i by ls command.
    Could someone pls help me in that.

    Thank You
    Prashant

  • biswajit December 4, 2012, 8:51 am

    thanks

  • Allan February 18, 2013, 2:30 pm

    @Prashant Tarudkar

    ls | grep -E ‘^..[ie].*’

    ls piped to grep. -E means regex search, see ‘man grep’ for the details.

  • Sss March 19, 2013, 2:47 am

    when we list the content of directory
    using ls -l or ls -ltr
    it displays total 76 as first line
    Can you please explain the meaning of total
    what does it reflects..?

  • Rayudu March 27, 2013, 11:35 am

    Thanks … Great post… Its very help full 🙂

  • cellar.dweller May 12, 2013, 7:36 am

    Great article, as always! I wonder: Where did you find the ls -1 documented?

  • Zahir Hussain October 24, 2013, 11:41 pm

    Very nice explanation with examples ….
    Looking forward more unix command with examples… 🙂

  • Dharmesh November 19, 2013, 7:40 am

    excellent sir…

  • Vamshi Krishna December 16, 2013, 4:27 am

    Very helpful..as a beginner in Linux this site is helping me alot..Thank You

  • Geolin January 16, 2014, 10:45 pm

    really helpful post !

  • Siddhartha May 15, 2014, 3:21 pm

    How can i list 5 files

  • Deepak July 3, 2014, 6:10 am

    Simple. Elegant. Comprehensive.
    Thank you Ramesh.

  • Philippe Petrinko July 16, 2014, 1:30 am

    Hello,

    Nice topic.

    Please note there are two typos:

    “Sometimes you may want to know the _inone_ number of a file for internal maintenance. Use -i option as shown below to display _inone_ number.”

    inone => inode

    –P

  • Ramesh July 18, 2014, 2:03 am

    Is there a way to list files only after a certain date. Eg: want to list all the files only after Jan 1st 2010

    Thanks

  • Rakesh September 9, 2014, 12:04 am

    Very useful, thanks!

  • Margaretha December 19, 2014, 3:12 am

    Thanks so much for the post. How do I display file info with both the full date (including year) as well as the time last modified. It seems to either display full date without time or only the day and time e.g. Feb 8 11:48

    I actually need time created as well as time modified.

    Thanks 🙂
    Margaretha

  • kalyan January 6, 2015, 5:24 am

    sir, what is the purpose of ‘ln’ commnad and ln -s..

  • Helen March 20, 2015, 10:10 am

    what does the “|” mean in “ls | grep D”

  • Anonymous July 27, 2015, 8:50 am

    @sam1985
    Cygwin? Cygwin runs on (Windows) console, so it doesn’t support Russian. It’s not a problem with ls.

  • Priya September 21, 2015, 2:40 pm

    Hi Friends,

    am looking for sorting the files size in GB,The bigger file should be first.

    I have searched on the google for sorting the files by size in GB on solaris.
    I found so many commands,but all the commands are sorting the size nicely bytes wise in order.
    but for the same files when am trying in GB its showing incorrect results,I mean its taking the higer no. first while sorting,its not caring even though its in MB, KB or GB.you can see below example i tried with the command du -sh * | sort -rn | more and its showing below output.

    520 KB
    200 GB
    180 MB
    40 GB

    I should get the output like below

    200 GB
    40 GB
    180 MB
    520 KB

    I would really appreciate if anyone can help me with this

  • Anonymous January 24, 2016, 9:09 am

    thanks bro

  • Aiden Holt March 7, 2016, 9:24 am

    -rwxr-xr-x 1 root root 920788 Mar 28 2013 bash What does this mean chunk by chunk please answer

  • mnk December 13, 2016, 10:18 am

    What does cdrom -> media/cdrom
    mean in lrwxrwxrwx 1 root root 11 May 17 20:29 cdrom -> media/cdrom

  • Aniket January 16, 2017, 5:17 am

    The possible file types you may see are depicted by preceding the permissions by one of these:

    – = Regular File
    d = Directory
    l = Symbolic Link
    b = Block Special Device
    c = Character Device
    s = Unix Socket (local domain socket)
    p = Named Pipe

  • Varun January 26, 2022, 4:11 am

    “`console
    $ ls -l /etc
    total 3344
    -rw-r–r– 1 root root 15276 Oct 5 2004 a2ps.cfg
    -rw-r–r– 1 root root 2562 Oct 5 2004 a2ps-site.cfg
    drwxr-xr-x 4 root root 4096 Feb 2 2007 acpi
    -rw-r–r– 1 root root 48 Feb 8 2008 adjtime
    drwxr-xr-x 4 root root 4096 Feb 2 2007 alchemist
    “`

    What does `total 3344` mean here?