π§ 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:
ls
lists files and supports many useful options like-l
,-a
, and-h
.pwd
shows your exact current directory path.date
helps in tracking time, formatting timestamps, or logging.cal
offers 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 :