1. ls

ls

The ls command in Linux is used to list the contents of a directory (files and folders). It helps you see what's inside a folder.


Basic Syntax:

ls [options] [directory]

Common Examples:

  1. List files in current directory

ls

👉 Shows names of files and folders in the current location.


  1. List with details (-l for long format)

ls -l

👉 Shows detailed information like permissions, owner, size, and modified date.

Example output:

-rw-r--r-- 1 user user  2048 Jul 01 12:30 file.txt
drwxr-xr-x 2 user user  4096 Jul 01 12:15 folder

Include hidden files (-a for all)

ls -a

👉 Shows all files, including hidden files (those starting with . like .bashrc).


  1. Combine options (-la)

ls -la

👉 Shows all files including hidden ones, in detailed format.


  1. List files in a specific directory

ls /etc/sysconfig/network-scripts

👉 Lists contents inside the /etc/sysconfig/network-scripts folder.

Try with Linux Practice