Uncategorized

The “ls” command in Linux Ubuntu

In Ubuntu (and most Unix-like systems), the ls command is used to list the contents of a directory.

When you type:

ls

…it shows the names of files and folders in the current working directory.


Common Options:

  • ls -l → Long listing format (shows permissions, owner, size, and modification date)
  • ls -a → Shows all files, including hidden ones (those starting with .)
  • ls -lh → Human-readable file sizes (e.g., 5.2K, 3M instead of just bytes)
  • ls -R → Lists contents recursively (includes subdirectories)

Example:

ls -lha

might output something like:

drwxr-xr-x  5 user user 4.0K Oct 27 10:30 .
drwxr-xr-x 15 user user 4.0K Oct 26 08:12 ..
-rw-r--r--  1 user user  220 Oct 27 09:45 .bashrc
drwxr-xr-x  2 user user 4.0K Oct 27 10:00 Documents
-rw-r--r--  1 user user 1.2M Oct 27 10:20 data.txt

Here’s what each column in -l format means:

  1. File type & permissions
  2. Number of links
  3. Owner
  4. Group
  5. File size
  6. Last modification date/time
  7. File or directory name

Leave a Reply

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.