Navigating the Linux Terminal: Key Prompts, Directory Structure, and Commands for Beginners

Khushal MalikKhushal Malik
3 min read

When using a Linux terminal, the command prompt provides essential information that helps users understand their current environment. Let's break down the components of a typical terminal prompt and the hierarchical structure of Linux directories.

The Terminal Prompt

The prompt often includes:

  • Username: Shows the user executing commands.

  • Hostname: Indicates the machine being used.

  • Special Symbols:

    • @: Separates the username from the hostname.

    • : or ~: Follows the hostname, indicating the current directory.

    • $ or #: Denotes user type: $ for a regular user, # for the root user.

Example Prompt:

username@hostname:~$
  • username: Current user.

  • hostname: Machine name.

  • ~: Home directory (changes to the actual path if in another directory).

  • $: Regular user (changes to # for root).

The Linux Directory Structure

Linux organizes files in a hierarchical structure, starting from the root directory (/). Here’s an overview of common directories:

  1. /bin: Essential binaries.

  2. /boot: Boot loader files and kernel.

  3. /dev: Device files (e.g., /dev/sda).

  4. /etc: Configuration files and scripts.

  5. /home: User home directories (e.g., /home/username).

  6. /lib: Shared libraries.

  7. /media: Mount point for removable media.

  8. /mnt: Temporary mount point for filesystems.

  9. /opt: Optional and third-party software.

  10. /proc: Virtual files for system and process information.

  11. /root: Root user’s home directory.

  12. /sbin: System binaries for administration.

  13. /srv: Data for services (e.g., web servers).

  14. /tmp: Temporary files.

  15. /usr: User programs and data, where most application binaries are stored.

  16. /var: Variable data files like logs and databases.

Navigating Directories

Here are some basic commands:

  • pwd: Print Working Directory

      $ pwd
      /home/username
    
  • ls: List directory contents

      $ ls
      Documents  Downloads  Pictures
    
  • cd: Change Directory

      $ cd /home/username/Documents
    
  • mkdir: Make Directory

      $ mkdir new_directory
    
  • rmdir: Remove Directory (empty)

      $ rmdir empty_directory
    
  • rm -r: Remove Directory and contents

      $ rm -r directory_name
    

Path Types

  • Absolute Path: Full path from the root

      $ cd /home/username/Documents
    
  • Relative Path: Path relative to the current directory

      $ cd Documents
    

Special Directory Symbols

  • . (dot): Current directory

  • .. (double dot): Parent directory

  • ~ (tilde): Home directory of the current user

Examples

  • Move to the parent directory:

      $ cd ..
    
  • Move to the root directory:

      $ cd /
    
  • Move to the home directory:

      $ cd ~
    

Understanding these basics will help you effectively navigate and manage the filesystem in Linux.

Note:-B4 is blog post 4 of this series

B1 link :- khushalmalik.hashnode.dev/the-rise-of-linux

Make sure you subscribe to Newsletter and Do follow !!!!!!!

Linux is all about Directory 📂

#Khushal_Malik #Devops #Cloud #LinuxTerminalCommands #LinuxDirectoryStructure #LinuxTerminalForBeginners #LinuxCommandPrompt #BasicLinuxCommands #NavigatingLinuxTerminal #LinuxFilesystem #LinuxDirectoryNavigation #LinuxTerminalTutorial #LinuxBeginnerGuide #UnderstandingLinuxDirectories #LinuxCommandLineBasics #LinuxUserCommands #LinuxTerminalTips #LinuxCommandLineForBeginners

1
Subscribe to my newsletter

Read articles from Khushal Malik directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Khushal Malik
Khushal Malik

I am an Devops Cloud Eng. with 2 years of experience