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,3Minstead 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:
- File type & permissions
- Number of links
- Owner
- Group
- File size
- Last modification date/time
- File or directory name