Skip to main content

Command Palette

Search for a command to run...

#Day 4 -Navigating Linux: File System Hierarchy & Essential Commands Part-1 🌲πŸ–₯️

Unveiling the Structure and Power of Linux

Updated
β€’5 min read
#Day 4 -Navigating Linux: File System Hierarchy & Essential Commands Part-1  🌲πŸ–₯️

Introduction :-

Linux, a powerful and widely used operating system, organizes its file system in a hierarchical structure. Everything in Linux is treated as a file, and this organized tree-like structure is crucial for managing the system efficiently. Let's explore the key directories in the Linux File System Hierarchy and delve into some essential commands for navigating and manipulating files and directories.

πŸ“‚πŸŒ²Linux File System Hierarchy -

Linux File System Hierarchy In Linux everything is represented as a file including a hardware program, the files are stored in a directory, and every directory contains a file with a tree structure. That is called File System Hierarchy. Linux uses single rooted, inverted tree-like structure.

  1. Root Directory (/) 🌳:

    • Top-level directory.

    • Starting point of the File System Hierarchy.

    • All directories arise from the root directory.

  2. /root πŸ‘‘:

    • Home directory for the root user (superuser).
  3. /bin πŸ“¦:

    • User Binaries.

    • Common Linux commands for all users.

    • Contains binary executables.

  4. /sbin πŸ› οΈ:

    • System Binaries.

    • Commands for system administrators.

    • Used for system maintenance.

  5. /dev πŸ–₯️:

    • Device Files.

    • Contains hardware device files.

    • Includes terminal devices, USB, etc.

  6. /var πŸ“‚:

    • Variable Files.

    • Contains log files, databases, emails, and temporary files.

    • Growing file contents.

    • Subdirectories:

      • /var/log πŸ“œ: System log files.

      • /var/lib πŸ’½: Database and package files.

      • /var/mail πŸ“§: Email storage.

      • /var/tmp πŸ—‘οΈ: Temporary files for reboot.

  7. /mnt πŸ”οΈ:

    • Mount Directory.

    • Used to mount a file system temporarily.

  8. /media πŸ“°:

    • Removable Media Devices.

    • Subdirectories for mounted removable media devices.

  9. /usr πŸ§‘β€πŸ’»:

    • User Binaries.

    • Applications and files used by users.

  10. /etc βš™οΈ:

    • Configuration Files.

    • Core configuration files for the system and applications.

    • Contains startup and shutdown scripts.

  11. /boot πŸ‘’:

    • Boot Loader Files.

    • Contains files needed to boot the system.

    • GRUB boot loader and Linux kernels stored here.

  12. /opt 🌐:

    • Optional Applications.

    • Used for third-party software not in the distribution.

    • Software code stored here, binary code linked to bin directory.

  13. /home 🏑:

    • Home Directory.

    • Secondary users' home directories.

  14. /tmp ☁️:

    • Temporary Files.

    • Contains temporary files created by the system and users.

    • Files deleted on system reboot.

🐧Basic Linux Commands -

  1. #pwd🧭:

    • Shows the present working directory.
  2. #lsπŸ“‚:

    • Lists available files and directories in the present working directory.
  3. #unameπŸ–₯️:

    • Displays the name of the kernel (OS).
  4. #uname -rπŸ”„:

    • Shows the version of the kernel.
  5. #cdπŸ“:

    • Changes the current directory.
  6. #clearπŸ“Ί:

    • Clears the terminal screen for a fresh start.
  7. #whoamiπŸ‘€:

    • Reveals the currently logged-in username.
  8. #historyπŸ“œ:

    • Displays a list of previously used commands.
  9. #dateπŸ“…:

    • Shows the current time and date.

πŸ“Create Directory using Commands -

1) Create Single Directory :

  • Command:mkdir directory_name πŸ“‚

  • Example:mkdir docs πŸ“

2) Create Multiple Directories :

  • Command:mkdir dir1 dir2 dir3 πŸ“πŸ“πŸ“

  • Example:mkdir images videos music πŸ–ΌοΈπŸ“ΉπŸŽ΅

3) Create Directory Path :

  • Command:mkdir -p path/to/directory πŸ›€οΈπŸ“‚

  • Example:mkdir -p project/docs πŸ“πŸ“

4) Create Number of Directories :

  • Command:mkdir dir{1..5} πŸ“πŸ“πŸ“πŸ“πŸ“

  • Example:mkdir week{1..7} πŸ“πŸ“πŸ“πŸ“πŸ“πŸ“πŸ“

πŸ“Create File using Commands -

1) Create Single File :

  • Command:touch filename πŸ–‹οΈ

    • Example:touch file.txt πŸ“‘

2) Create Multiple Files :

  • Command:touch file1 file2 file3 πŸ“„πŸ“„πŸ“„

    • Example:touch doc1.txt doc2.txt πŸ“‘πŸ“‘

3) Create Number of Files :

  • Command:touch file{1..5}.txt πŸ“„πŸ“„πŸ“„πŸ“„πŸ“„

    • Example:touch note

  • πŸ“‹πŸ”„πŸ—‘οΈCopy, Move, and Remove Files using Commands -

πŸ’‘
πŸ“‹Copy Commands -
  • Copy File :

    • Command:cp sourcefile destination πŸ“‚

    • Example:cp file.txt backup/ πŸ“„πŸ“‚

  • Copy All Data Starting with 'D' :

    • Command:cp D* destination πŸ“‚

    • Example:cp D* backup/ πŸ“„πŸ“‚

πŸ’‘
πŸ”„Move Commands-
  • Move File or Directory :

    • Command:mv source destination πŸ”„

    • Example:mv file.txt documents/ πŸ”„πŸ“‚

  • Rename File or Directory:

    • Command:mv oldname newname πŸ”„

    • Example:mv data.txt newdata.txt πŸ”„πŸ“„

πŸ’‘
πŸ—‘οΈRemove Commands -
  • Delete File :

    • Command:rm filename πŸ—‘οΈ

    • Example:rm old.txt πŸ—‘οΈ

  • Delete Directory and File :

    • Command:rm -r directory_name πŸ—‘οΈ

    • Example:rm -r docsπŸ—‘οΈ

Note :
"-r" : for recursive.

Conclusion :

Understanding the Linux File System Hierarchy and basic commands is essential for effective system administration and user interaction. Whether creating directories, managing files, or navigating through the system, these commands form the foundation for efficient Linux usage. With a clear hierarchy and powerful commands, Linux provides a robust environment for both beginners and experienced users. πŸš€πŸ§


🌟Thank you for taking the time to read this blog. I hope you gained valuable insights today! If you found the content helpful, please consider liking, sharing, and following for more insightful posts in the future. Your support means a lot. 🌟 Looking forward to sharing more knowledge with you! πŸš€

πŸŽ‰πŸŒ Let's bridge the distance and connect πŸ”—πŸ€Anup DeshmukhπŸŽ‰πŸ˜Š

DevOps-Tech

Part 1 of 4

In this #DevOpsJourney, I am sharing DevOps-related technological knowledge. Stay connected with #DevOpsSeries. Thank you! 😊

Up next

Day 3 - Creating Your First AWS EC2 Instance: A Comprehensive Guide for Virtual Servers in the AWS Cloud

Embark on Cloud Excellence with Amazon's Elastic Compute Cloud (EC2)