πŸ“‚ Mastering Linux Basics: Navigating, Listing & Managing Files Like a Pro (Day 2)

πŸ“‚ Mastering Linux Basics: Navigating, Listing & Managing Files Like a Pro (Day 2)

Basic Linux Commands (File Listing, Navigation, and Directory Management)

Welcome to Day 2 of the 90 Days of DevOps journey! πŸš€ Today, we dive into some essential Linux commands that will help you navigate the file system, list directories, and manage files efficiently. Whether you’re a beginner or just need a refresher, this guide will make Linux more approachable.


πŸ— 1. Understanding the Linux File System

Before jumping into commands, let’s understand how files and directories are organized in Linux:
πŸ“ Everything in Linux is structured in a tree-like hierarchy with the root directory (/) at the top.
πŸ“‚ Inside the root, there are standard directories like:

  • /home ➝ Stores user files

  • /etc ➝ Configuration files

  • /bin ➝ System binaries (commands)

  • /var ➝ Logs and variable data

Now, let's learn how to list files, navigate directories, and create folders! 🎯


πŸ“œ 2. Listing Files & Directories (ls Command)

The ls command is used to list files and directories inside a folder.

πŸ”Ή Basic Usage:

ls
  • This will display all visible files and directories in the current folder.

πŸ”Ή Common ls Options:

CommandDescription
ls -lπŸ“‹ Detailed list (permissions, size, date, owner)
ls -aπŸ‘€ Show all files, including hidden ones (.filename)
ls -iπŸ”’ Show inode numbers (unique ID for each file)
ls -d */πŸ“‚ List only directories (not files)
ls *.shπŸ” List only .sh files (pattern matching)

πŸ”Ή Example Output of ls -l

drwxr-xr-x  2 user user  4096 Feb 22  10:30 Documents
-rw-r--r--  1 user user  1234 Feb 22  11:00 script.sh
  • d β†’ Directory

  • rwx β†’ Permissions (Read, Write, Execute)

  • 1234 β†’ File size (bytes)

  • Feb 22 11:00 β†’ Last modified date

  • script.sh β†’ File name

πŸ“Œ Real-life Example: Imagine ls as opening a folder on your computer and seeing all the files inside! πŸ—‚οΈ


πŸš€ 3. Navigating Directories (cd Command)

The cd (change directory) command helps move between folders.

πŸ”Ή Basic Usage:

cd folder_name
  • Moves into folder_name.

πŸ”Ή Common cd Commands:

CommandDescription
cd /home/userπŸšΆβ€β™‚οΈ Go to a specific path
cd ..πŸ”™ Move one level back
cd ../..πŸ”™πŸ”™ Move two levels back
cd ~ or cd🏠 Go to home directory
cd -πŸ”„ Go back to the previous directory

πŸ“Œ Real-life Example: cd is like clicking through folders on a Windows/Mac file explorer.


πŸ“‚ 4. Finding Your Current Location (pwd Command)

Want to check which folder you're in? Use:

pwd

πŸ” Output Example:

/home/user/Documents

This means you’re inside the Documents folder of user user.

πŸ“Œ Real-life Example: Think of pwd as looking at the address bar in Windows Explorer.


πŸ— 5. Creating Directories (mkdir Command)

The mkdir command is used to create new folders.

πŸ”Ή Basic Usage:

mkdir folder_name
  • Creates a new directory named folder_name.

πŸ”Ή Advanced mkdir Options:

CommandDescription
mkdir NewFolderπŸ“‚ Create a new folder
mkdir .HiddenFolderπŸ•ΆοΈ Create a hidden folder (prefix .)
mkdir Folder1 Folder2πŸ“¦ Create multiple folders at once
mkdir -p Parent/Child/Grandchild🌳 Create nested directories

πŸ“Œ Real-life Example: Creating a folder in File Explorer by right-clicking ➝ New Folder.


🎯 Summary: What We Learned Today

βœ… ls – List files and directories
βœ… cd – Navigate between folders
βœ… pwd – Show current directory path
βœ… mkdir – Create new folders

These commands are essential for managing files in Linux, especially for DevOps, scripting, and system administration. Master these basics, and you'll navigate Linux like a pro! πŸ’ͺ🐧


πŸ’‘ What’s Next?
Stay tuned for Day 3, where we'll explore more advanced file handling and permissions in Linux! πŸš€

πŸ”” Challenge: Try these commands on a Linux system and see the results for yourself! πŸ’»πŸ”₯

Would you like a hands-on practice assignment? Let me know! 😊

Β