πŸ—ƒοΈ Linux/Unix: File & Directory Operations
Estimated reading: 3 minutes 26 views

🧭 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 :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

πŸ”΅ Linux/Unix: Quick Guide / Useful Commands (ls, pwd, date, cal)

Or Copy Link

CONTENTS
Scroll to Top