15 Interview Questions on Linux “ls” Command – Part 1

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Linux BASH Programming Cookbook
Getting Started with Ubuntu 16.04
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

23 Responses

  1. In-correct bit of information: on Question #5, the 2nd bullet point says that “Number ‘5‘ represents Symbolic Link.”

    (a) The numeric field(2) between permission & file owner is the LINK_COUNT, but only includes direct/hard links.

    (b) Symbolic links do NOT change/increment the link count for a regular file or directory.

    (c) Unix/Linux allows the same exact file to have multiple names.

    1. These are not copies of file, but exact same file can be called red and blue at the same time,
    2. and both names will be listed in directory ‘ls’ listing… the names can be in different DIRs also.

    (d) Link_Count shows count for “How Many simultaneous hard-link Names does this File HAVE?”

    1. You can also have “Symbolic or ‘soft’ links; but those are re-direction pointers and not counted the same.”

    (e) Rule: You are NOT allowed to add hard-links (extra names) for a Directory… just normal files and programs.

    (f) For a DIR, both the “dir-name” in parent dir, and the “.” dot-name in child dir are part of Link_Count,

    1. so Dirs have Link-Count 2 when created… All “normal files” have a Link_Count of 1 when created.

    (e) Link count on Dirs goes UP as sub-dirs are created, since “..” entry in sub-dirs is a link pointing to parent dir.

    (f) So… if you see a DIR with Link_Count above 2, you can subtract 2, and know number of child sub-dirs

    (g) Thus, in Question#2 above, the Link_Count=5 means that dir “Binary” contains three sub-dirs.

    1. but the Link_Count does not tell you if there are Symbolic_Links, as noted in the example answer.
  2. Asif Ali Rizvan says:

    show only files and not directories

    ls -F |grep -v ‘/’

  3. Anonymous Coward says:

    I do like the contents of the post, as I learned new things. But if a company was interviewing me from man pages, I’d run screaming and never look back, no matter how good the pay they’d offer. I do value my sanity, you know.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?