UNIX AND SHELL SCRIPTING
UNIX / LINUX BASIC COMMANDS
1. ls – List Directory Contents
The ls command is used to display the contents of a directory (files and folders).
Basic Usage
ls
Lists files and directories in the current working directory.
Common Options with ls
Command Meaning
ls -l Long listing format
ls -a Shows hidden files
ls -d Lists directories only
ls -i Shows inode numbers
ls -r Reverse order listing
ls -s Shows file sizes
ls -l (Long Listing Format)
ls -l
This displays details in the following format:
drwxr-xr-x 2 user group 4096 Feb 4 10:00 myfolder
-rw-r--r-- 1 user group 1024 Feb 4 10:01 [Link]
Breakdown of first column:
Symbol Meaning
d Directory
- Regular file
r Read permission
w Write permission
x Execute permission
Hidden Files ( . dot files )
In Linux, any file starting with . is hidden.
Example:
ls -a
Might show:
. .. .bashrc .profile [Link]
Name Meaning
. Current directory
.. Parent directory
ls -i (Inode Number)
ls -i
Every file in Linux has a unique inode number, which identifies it internally.
2. man – Manual Command
man shows the official documentation of a command.
Example:
man ls
You can navigate using:
Enter → Next line
Space → Next page
q → Quit manual
3. cd – Change Directory
Used to move between directories.
Syntax
cd path_of_directory
Types of Path
(A) Absolute Path
Starts from root /
Example:
cd /home/student/Downloads
(B) Relative Path
Starts from current directory.
Example:
cd Downloads
Special Symbols
Symbol Meaning
. Current directory
.. Parent directory
Example:
cd ..
This moves one level up.
4. pwd – Present Working Directory
Shows your current location in the filesystem.
pwd
Example output:
/home/student/Downloads
5. mkdir – Make Directory
Creates a new folder.
Basic Syntax
mkdir directory_name
Example:
mkdir newdir
Create inside another folder:
mkdir ./Downloads/newdir
Create multiple directories at once:
mkdir dir1 dir2 dir3
6. cal – Calendar
Displays system calendar.
cal
Show specific month:
cal 2025
Show specific month and year:
cal 2 2025
7. date – Show Current Date & Time
date
Example output:
Tue Feb 4 13:25:10 IST 2025
8. cat – Display File Content
Used to view file content.
Example:
cat [Link]
If used without file:
cat
It waits for input.
To exit press:
Ctrl + D
9. poweroff – Shut Down System
poweroff
Alternative commands:
shutdown now
halt
Additional Useful Commands (Bonus for your notes)
Command Purpose
clear Clears terminal screen
touch [Link] Creates empty file
rm [Link] Deletes file
rmdir folder Deletes empty directory
whoami Shows current user
uname -a Shows system info