Linux/Unix: Quick Guide / Useful Commands (ls, pwd, date, cal)
Introduction β Why Master Basic Linux/Unix Commands?
If you’re new to Linux or Unix systems, the terminal may seem intimidating. But a handful of essential commands can make navigation, file management, and daily tasks incredibly efficient. Commands like ls, pwd, date, and cal form the foundation of shell interaction.
In this quick-start guide, youβll learn:
- What each command does and when to use it
- Syntax and examples for basic Linux/Unix commands
- Real-time terminal output and usage tips
ls β List Directory Contents
Syntax:
ls [options] [path]
Description:
The ls command lists files and directories in the current location or the specified path.
Examples:
ls
ls -l # Long listing with permissions, size, date
ls -a # Include hidden files (dotfiles)
ls -lh # Human-readable sizes
Output:
drwxr-xr-x 2 user user 4096 Jun 15 10:00 Documents
-rw-r--r-- 1 user user 102 Jun 15 09:59 notes.txt
pwd β Print Working Directory
Syntax:
pwd
Description:
Displays the absolute path of the current directory you’re in.
Example:
pwd
Output:
/home/user/Documents
Useful when youβre lost in the file system and want to confirm your current location.
date β Display Current Date and Time
Syntax:
date [options]
Description:
Prints the system’s current date and time.
Example:
date
Output:
Sat Jun 15 12:45:30 IST 2025
Format the Output:
date +"%d-%m-%Y %H:%M:%S"
Output:
15-06-2025 12:45:30
Great for logging events or displaying time in shell scripts.
cal β Display Calendar
Syntax:
cal [month] [year]
Description:
Shows a calendar view of the current month or any month/year you specify.
Examples:
cal # Show current month
cal 12 2025 # Show December 2025
Output:
June 2025
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Handy for quick date lookups without leaving the terminal.
Combine Commands for Productivity
Use chaining and redirection to combine basic commands:
Example:
echo "Today is: $(date)" > today.txt
ls -l >> today.txt
This saves the date and file listing into today.txt.
Summary β Recap & Next Steps
These four commandsβls, pwd, date, and calβare your essential tools for navigating and interacting with a Linux/Unix system. With just these, you can view files, check your location, see the date/time, and plan with a calendar.
Key Takeaways:
lslists files and supports many useful options like-l,-a, and-h.pwdshows your exact current directory path.datehelps in tracking time, formatting timestamps, or logging.caloffers an instant calendar without opening apps.
FAQs
How can I list hidden files in Linux?
Use ls -a. Hidden files begin with a . and wonβt show with just ls.
What does pwd stand for?
pwd means Print Working Directory, showing your current location in the file system.
How do I display time in a specific format?
Use:
date +"%d-%m-%Y %I:%M %p"
Can I use cal on any Linux distro?
Yes. If it’s not pre-installed, you can install it using:
sudo apt install bsdmainutils # Debian/Ubuntu
sudo yum install util-linux # RHEL/CentOS
Share Now :
