Linux: Mastering the Linux Terminal

linux logo

Linux Terminal Basics

The Linux terminal, also known as the command line or shell, is a text-based interface for interacting with the Linux operating system. It allows you to execute commands and perform various tasks without using a graphical user interface (GUI).

Here are some key aspects of the Linux terminal:

  • Shell: The shell is a program that interprets your commands and executes them. There are various shell programs available for Linux, with the most common ones being Bash (Bourne-Again Shell), Zsh (Z Shell), and Tcsh (TENEX C Shell). Bash is the default shell on most Linux distributions.

  • Command Prompt: When you open a terminal, you are presented with a command prompt. It typically consists of your username, the hostname of your system, the current directory, and a symbol (often a dollar sign ‘$’ for regular users or a ‘#’ for the superuser, root).

  • Commands: You interact with the system by entering commands at the prompt. Linux provides a vast array of commands for tasks like navigating the file system, managing files and directories, running applications, configuring system settings, and more.

  • File System Navigation:

    • pwd: Print the current working directory.
    • cd: Change the current directory.
    • ls: List files and directories in the current directory.
    • mkdir: Create a new directory.
    • rm: Remove files or directories.
    • cp: Copy files and directories.
    • mv: Move or rename files and directories.
  • Text Editors: You can edit text files from the terminal using text editors like nano, vim, or emacs.

  • Redirection and Pipes: You can redirect the output of commands to files or use pipes to send the output of one command as input to another.

  • Permissions and Users:

    • chmod: Change file permissions.
    • chown: Change file ownership.
    • sudo: Execute a command with superuser (root) privileges.
  • Process Management:

    • ps: List running processes.
    • kill: Terminate processes.
    • top or htop: Display system and process information in real-time.
  • Package Management: Use package managers like apt, yum, or dnf to install, update, and remove software packages.

  • Scripting: The Linux terminal is a powerful environment for writing and executing shell scripts. Shell scripts automate repetitive tasks and can be used for system administration and other purposes.

  • Environment Variables: You can set and use environment variables to store information that commands and scripts can access.

  • Wildcards: Linux supports wildcards like * and ? to match multiple files or characters in file and directory names.

  • Tab Completion: Tab completion is a convenient feature that helps you complete file and command names by pressing the Tab key.

  • History: You can access command history and use the Up and Down arrow keys to navigate and rerun previous commands.

  • Remote Access: You can use the terminal to connect to remote Linux servers through SSH (Secure Shell) for remote administration.

  • Customization: You can customize your terminal environment by modifying shell configuration files, changing the prompt, and using different color schemes.


  • Using the up or down cursor keys to scroll through recent command history.
  • sudo apt update To update repositories.
  • sudo apt upgrade To install new updates.
  • sudo reboot To reboot system.
  • sudo apt update && sudo apt upgrade -y && sudo reboot You can chain commands together with && also by adding -y you will automatically install any updates.
  • sudo shutdown Will begin the shutdown timer sudo shutdown now will instantly shutdown system.
  • sudo shutdown now Will instantly shutdown the system.
  • apt install To install a program.

File and Directory Operations:

  • ls: List files and directories in the current directory.
  • pwd: Print the current working directory.
  • cd: Change the current directory.
  • mkdir: Create a new directory.
  • rmdir: Remove an empty directory.
  • rm: Remove files or directories.
  • cp: Copy files and directories.
  • mv: Move or rename files and directories.
  • touch: Create an empty file.
  • cat: Concatenate and display file contents.
  • more or less: Display file contents one screen at a time.
  • head: Display the beginning of a file.
  • tail: Display the end of a file.
  • ls -a Lists all, including hidden files.
  • cd ../ Takes you up one directory level.
  • cd ../../ Takes you up two directory levels, etc…
  • cd ~ Takes you back to the home directory.

File and Text Editing:

  • nano: A simple text editor.
  • vim or vi: A more advanced text editor with multiple modes.
  • emacs: A powerful and extensible text editor.

Permissions and Ownership:

  • chmod: Change file permissions.
  • chown: Change file ownership.
  • chgrp: Change group ownership.

Here are some command-line arguments you can use:

  • -R Make all files in directory have same permissions.
  • -f Forcibly over-ride warnings.
  • -v Gives a more verbose output.
  • -x Makes a file executable.

Process Management:

  • ps: List running processes.
  • top or htop: Display real-time system and process information.
  • kill: Terminate processes.

Package Management (Debian/Ubuntu):

  • apt-get: Command-line package management tool.
  • dpkg: Package manager for .deb files.

Package Management (Red Hat/Fedora):

  • yum: Package management tool.
  • rpm: Package manager for .rpm files.

File Searching:

  • find: Search for files and directories.
  • locate: Quickly search a prebuilt database of files.

Text Manipulation:

  • grep: Search text using patterns.
  • sed: Stream editor for text manipulation.
  • awk: Text processing language.

Archiving and Compression:

  • tar: Archive files.
  • gzip: Compress files using the gzip format.
  • zip and unzip: Create and extract zip archives.


  • ifconfig or ip: Display or configure network interfaces.
  • ping: Send ICMP echo requests to a network host.
  • ssh: Securely connect to remote servers.
  • scp: Securely copy files between local and remote systems.
  • netstat: Network statistics.

Adding and Managing Users:

  • useradd: Create a new user account.

    • Example: sudo useradd -m -s /bin/bash username
  • passwd: Set or change a user’s password.

    • Example: sudo passwd username
  • usermod: Modify user account attributes.

    • Example: sudo usermod -l newusername oldusername
  • userdel: Delete a user account.

    • Example: sudo userdel username

Group Management:

  • groupadd, groupdel, groupmod: Manage groups.
  • gpasswd: Manage group memberships for users.

    • Example: sudo gpasswd -a username groupname
  • groups: Display the groups to which a user belongs.

    • Example: groups username

Password Policies:

  • chage: Set password expiration and account aging policies.
    • Example: sudo chage -M 60 -I 7 -E 90 username

Higher-Level User Management Commands (Distro-Specific):

  • adduser: Create a user with interactive prompts for user details.

    • Example: sudo adduser username
  • deluser: Delete a user and remove their home directory (Distro-specific).

    • Example: sudo deluser username

File Transfer:

  • wget: Download files from the internet.
  • curl: Transfer data with URLs.
  • rsync: Efficient file copying and synchronization.

System Information:

  • uname: Display system information.
  • df: Display disk space usage.
  • free: Display memory usage.
  • lscpu: Display CPU information.
  • lsusb: List USB devices.

More Useful Tricks:

  • rm -r dir1 Recursively delete a directory and all of its contents.
  • cat file1 file2 Read both files.
  • cat file1 file2 > file3 Take the content from file1 and file2 and insert it into a new file, labelled file3.
  • cat -n file1 Display contents of file with line numbers.
  • wc -l file1 Displays the line count of file.
  • diff file1 file2 Display only the differences between the two files.
  • file1 | cut -d " " Cut any blank spaces from a file.
  • file1 | cut -d "z" Cut any occurrences of the letter z from file1.
  • file1 | cut -d " " | sort -u Cut blank spaces, sort the list, and remove duplicate entries.
  • cat file1 | sort -u | uniq > sortedFile Takes content from file1 removes all duplicate entries and saves remaining content to a new file.
  • ls | sort List items in order (Piping is super useful to string commands together).
  • grep "word" file1 Locate any word in a file.
  • grep -n "word" file1 Add line numbers every time searched for word is found.
  • grep ^ "word" file1 Find words starting with searched for word not just the specified word.
  • adduser ObiWan Adds the user ObiWan with a home directory.
  • deluser --remove-home ObiWan Deletes the user ObiWan and the home directory belonging to ObiWan.
  • cat /etc/passwd Lists all user accounts.
  • cat /etc/shadow Shows all encrypted passwords.
  • cat /etc/group List all groups.
  • whoami Displays who you are logged in as.
  • w Shows who else is logged on.
  • sudo -l Lists all programs that can be ran as root.


The Linux terminal is a powerful and efficient way to work with Linux systems, offering precise control over the operating system. While it may seem intimidating to beginners, it becomes a valuable tool as you become more familiar with its capabilities. It’s widely used by system administrators, developers, and power users for tasks ranging from basic file management to complex system administration and scripting.

That’s All Folks!

You can find all of our Linux guides here: Linux Guides

Luke Barber

Hello, fellow tech enthusiasts! I'm Luke, a passionate learner and explorer in the vast realms of technology. Welcome to my digital space where I share the insights and adventures gained from my journey into the fascinating worlds of Arduino, Python, Linux, Ethical Hacking, and beyond. Armed with qualifications including CompTIA A+, Sec+, Cisco CCNA, Unix/Linux and Bash Shell Scripting, JavaScript Application Programming, Python Programming and Ethical Hacking, I thrive in the ever-evolving landscape of coding, computers, and networks. As a tech enthusiast, I'm on a mission to simplify the complexities of technology through my blogs, offering a glimpse into the marvels of Arduino, Python, Linux, and Ethical Hacking techniques. Whether you're a fellow coder or a curious mind, I invite you to join me on this journey of continuous learning and discovery.

Leave a Reply

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

Verified by MonsterInsights