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

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  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.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

25 Responses

  1. Rohit Dhyani says:

    Under Linux what simple thing can I do to make a file not appear in a standard ls directory listing

  2. naresh says:

    Super awesome interview questions and answers on Linux Commands.

  3. 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.
  4. Asif Ali Rizvan says:

    show only files and not directories

    ls -F |grep -v ‘/’

  5. 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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.