What does `ls -ld` show?

QuestionsQuestions8 SkillsProDec, 18 2025
0125

The command ls -ld is a specific combination used to look at a directory itself, rather than looking at the files inside it.

Here is the breakdown:

1. What the flags mean:

  • -l: Uses the Long format (showing permissions, owner, size, and date).
  • -d: Stands for Directory. It tells ls to list the directory itself, not its contents.

2. Why is this useful?

Normally, if you type ls -l testdir, Linux thinks you want to see a detailed list of all the files inside testdir.

By adding the d, you are saying: "Don't show me what's inside. Show me the details of the folder itself."

3. Example Output:

If you run ls -ld testdir, you will see something like this:

drwxr-xr-x 2 labex labex 4096 Dec 18 10:00 testdir

What this tells you about the directory:

  • d: Confirms it is a directory.
  • rwxr-xr-x: Shows the permissions of the directory (who can enter it or modify it).
  • 2: The number of hard links.
  • labex labex: The Owner and the Group.
  • 4096: The size of the directory file itself.
  • Dec 18 10:00: When the directory was last modified.

Try it now:
Compare the two commands to see the difference:

  1. ls -l testdir (Shows files inside)
  2. ls -ld testdir (Shows the folder's own permissions)

0 Comments

no data
Be the first to share your comment!