Skip to main content

Understanding Linux Terminal Shell & Basic Linux Commands

Updated 4 min readMarkdown
Part of seriesDevOps
Understanding Linux Terminal Shell 
                                                 & 
                         Basic Linux Commands

🐧 What is a Terminal Shell? 🖥️

  • A terminal shell is a program that understands and executes commands you type.

  • The Linux terminal shell is a text-based interface that lets you communicate with the system using commands.

  • It acts as a middleman between you and the operating system, making it easier to interact with the system using text.

🐧How does it work 🤯❓

  1. Prompt

    • 📜 When you open the terminal, you'll see a prompt (usually $ or #) waiting for your command.

    • $: Represents Normal User

    • #: Represnts Root User / Super User / Admin

    • 🐚 It means the shell is ready to accept your instructions.

  2. Commands

    • 🖊️ You can type commands after the prompt to perform specific tasks.

    • 🐚 Commands can be simple (like listing files) or complex (like searching for text in files).

    • 🔢 Command parameters or options modify how the command behaves.

  3. Command Execution

    • ▶️ After you press Enter, the shell interprets and executes the command.

    • 🐚 It looks for the command in specific places on the system using the PATH variable.

    • 🚀 When found, it loads the command into memory and runs it.

  4. Output and Error Messages

    • 📤 The command may produce output or error messages, displayed in the terminal.

    • 🐚 Output can be text, data, or even graphical information, depending on the command.

    • ⚠️ Error messages tell you if something went wrong during command execution.

  5. Scripting and Automation

    • 📜 Shell scripting lets you create scripts with multiple commands.

    • 🤖 These scripts automate repetitive tasks, saving time and effort.

    • 🐚 By running a script, you can avoid typing individual commands repeatedly.

🐧 Understanding Using Basic Commands❗

Let's understand it by solving some basic questions:

Part 1:

  1. Check your present working directory

    pwd : present/print working directory

  2. List all the files or directories including hidden files

    ls -a : list files or directories including hidden files or directories

  3. Create a nested directory A/B/C/D/E

    mkdir : used to make directory

    mkdir -p A/B/C/D/E : Creates nested directories

    -p : parent


Let's level up with some more questions :

  1. To view what's written in a file

    cat : read the content of the file

  2. To change the access permissions of files.

    chmod : change the access mode of a file

    • Every file in Linux has one of three permission types: read (r), write (w), or

      execue (x).

    • Three types of users can have these rights set: the file's owner (u), the group to which the file belongs (g), and other users (o), who are neither the owner nor a member of the group.

    • We employ a combination of letters and symbols to alter the permissions. For instance: -

      • The file owner is given read, write, and execute permissions using the

        command "chmod u+rwx example.txt".

      • Removing the group's and others' read permissions using

        "chmod go-r example.txt"

  1. To check which commands you have run till now.

    history : used to view the previously executed command

  2. To remove a directory/ Folder.

    rmdir : used to remove/delete directory

  3. To create a fruits.txt file and to view the content.

    vim filename : creates a file and views the content for read/modify.

    nano can also be used , it works the same.They directly open editors to view and edit the content

    • we can also use "touch" to create empty files

    • To read the content of the file we use "cat"

  1. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

    use nano/vim and edit the content

  2. To Show only top three fruits from the file.

    head : print the top N number of data of the given input

  3. To Show only bottom three fruits from the file.

    tail : prints the last few number of lines of a certain file

  4. To create another file Colors.txt and to view the content.

    use nano or vim to create and view the content

    • we can also use "touch" to create empty files

    • To read the content of the file we use "cat"

  1. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

    use nano or vim to edit the content

  2. To find the difference between fruits.txt and Colors.txt file.

    diff : compares two files and produces a list of the differences between the two.

Other commands will be explored in Advance Linux . Stay tuned :D

Happy Learning :D

About the author

  • Site Reliability Engineer passionate about cloud infrastructure, automation, scalability, and operational excellence. I write about SRE, DevOps, Azure, AWS, Kubernetes, CI/CD, and real-world troubleshooting experiences.

No comments yet. Be the first to comment.

More from this blog