ls of command in linux

The ls command in Linux is used to list information about files and directories in the terminal. Here are some common usage examples and options for the ls command:

  1. List all files and directories:
   ls
  1. List all files, including hidden ones:
   ls -a
  1. Long format listing (permissions, number of links, owner, group, size, and time of last modification):
   ls -l
  1. Long format listing with file access times:
   ls -l --time=access
  1. Display file sizes in human-readable format (e.g., K, M, G):
   ls -lh
  1. Sort by file extension:
   ls -lX
  1. Sort by modification time, newest first:
   ls -lt
  1. Sort by size, largest first:
   ls -lS
  1. List only directories:
   ls -d */
  1. List files and directories excluding the current and parent directory:
   ls -lX --hide='*/.*'
  1. Recursively list all files and directories in a directory and its subdirectories:
   ls -R
  1. Use color to distinguish file types:
   ls --color
  1. Include inode number in the listing:
   ls -i
  1. Show block usage of files:
   ls -s
  1. List only files with the ‘f’ extension:
   ls *.f
  1. List files and directories and show tilde for hidden files:
   ls -lF
  1. List only directories and show details:
   ls -ld */
  1. List files and directories sorted by version (if version sort is supported by your system):
   ls -v
  1. List files and directories sorted by extension:
   ls -X
  1. List files and directories sorted by modification time, newest first, and show detailed information:
   ls -lt

The ls command is a fundamental part of navigating and managing files and directories in Linux. The options can be combined to provide the desired output for various tasks.

This entry was posted in Ls Command and tagged , , , , . Bookmark the permalink.