• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Linux-Ubuntu | ls -- list directory contents
  1. Notes
  2. Examples
  3. Command Help (man ls)

  1. Notes

    • For files, ls displays the name and information of each file.

    • For directories, ls displays the names and information of files/directories contained within each directory.

    • If no file/directory is given, the contents of the current directory is displayed.

    • If more than one file/directory is given, files are displayed first.
  2. Examples
    • (Option -1) List the name of each file and directory in one line:

    • List the name and information of each file and directory (including ".", "..", and files and directories starting with "."):

      Note: for a directory, the number of bytes (for example: 4096) represents the size of the meta file that contains information about the directory. It doesn't give any information about the real size of files and directories within that directory.

    • List files and sub-directories information with their contents (including ".", "..", and files and directories starting with "."):

    • (Option -d) List files and sub-directories information without their contents (excluding ".", "..", and files and directories starting with "."):

    • (Option -S) Sort files and directories by size:

    • (Option -t) Sort files and directories by time modified:
  3. Command Help (man ls)
    The following options can be used:

    Option "-l" (long display):
    The "-l" provides more information about files and directories.
    The first line of the output display the total number of blocks contained within the directory.
    The following lines list details of each file and directory.
    Each line provides the following information:
    - The type of the file.
    - Permissions of the file.
    - The Number of file hard links.
    - The user name of the owner of the file.
    - The group name of the primary group of the file.
    - The byte size of the file.
    - The last time the file was modified.
    - The file name.

    • The option "-l" shows the following characters for the type of the file:

    • The option "-l" shows the following characters for the permissions of the file:

      For a specific command file, you might see the s character instead of the x character (-rwsrwsr--). The s character can be set for the user permissions (setuid: set user id on execution) or/and group permissions (setgid: set group id on execution). This allow a user to execute the command but the ownership of the running command will be hold by the user or group owning the command.

      For some directories, you might see the t character instead of the x character in other's permissions (drwxrwxr-t). This indicate that the sticky bit was enabled for them, which means that users can add or delete files in those directories but they cannot delete each other's files.

      For some files and directories, you might see the + character at the end of the permissions bits (-rwsrwsr--+). This means that those files and directories have extra attributes assigned to them (i.e. ACLs).
© 2025  mtitek