How does `ls -ld` work?

QuestionsQuestions8 SkillsProUser Account ManagementSep, 12 2025
0374

The ls -ld command is used to display detailed information about a directory itself rather than its contents. Here's how it works:

  • ls: This is the command used to list files and directories.

  • -l: This option stands for "long format." It provides detailed information about the files or directories, including:

    • File type and permissions
    • Number of links
    • Owner name
    • Owner group
    • File size
    • Last modification date and time
    • File or directory name
  • -d: This option tells ls to show information about the directory itself rather than listing its contents. Without this option, ls -l would display the contents of the directory.

Example Usage

ls -ld /path/to/directory

Example Output

drwxr-xr-x 2 user group 4096 Jan 1 12:00 directory

Breakdown of the Output

  • drwxr-xr-x: Indicates the file type and permissions (in this case, it's a directory).
  • 2: Number of links to the directory.
  • user: Owner of the directory.
  • group: Group associated with the directory.
  • 4096: Size of the directory in bytes.
  • Jan 1 12:00: Last modification date and time.
  • directory: Name of the directory.

This command is useful for checking the properties of a directory, such as permissions and ownership, without displaying the files contained within it.

0 Comments

no data
Be the first to share your comment!