Mastering the Ubuntu Terminal: Key Linux Commands for Beginners

Ubuntu is a Linux-based operating system — a popular Linux distribution — that’s free, user-friendly, and widely supported by the community.
It’s a robust platform for both servers and desktops. The terminal provides a text-based interface to interact with Ubuntu.
Instead of navigating menus with your mouse, you type commands directly.

This lets you:

  • Perform tasks faster

  • Automate routines

  • Manage files, users, services, and much more

  • Access your system remotely (with SSH)

Linux commands are instructions you enter in a terminal (also called a console or a shell) to tell your Linux operating system what to do.

They enable you to perform tasks without needing a graphical interface (GUI) — for example:

  • Viewing files

  • Installing software

  • Updating settings

  • Automating routines with scripting

Essentially, Linux commands are the way you communicate directly with the Linux kernel (the core of the OS).

What Are They Used For? 🔹

Some of the most common uses for Linux commands include:

Managing files and folders
ls (list files)

cd (change directory),

mv (move files),

rm (remove files),

chmod (change permissions), etc.

Installing or removing software
apt install package-name (for Ubuntu/Debian)
dnf install package-name (for Fedora)
yum install package-name (for CentOS)

Managing users and groups
adduser (add a new user)
userdel (delete a user)
groups (list groups for a user)

ESSENTIAL COMMANDS AND THEIR FUNCTIONS

  1. ROOT/ADMINISTRATIVE ACCESS- “sudo su”

    “Sudo” means “Superuser do”. It gives root privileges to the user temporarily in order to execute commands associated with the root user.

    “Su” means “switch user” or “substitute user”. This command switches the current user to the root user with access to root privileges

    Sudo su lets you become root with your own password (provided your account is a sudoer).

    • sudo su lets you switch to the root user (the Administrator or Superuser) while retaining your current terminal.

    • This means you will perform subsequent commands with root privilege.

    • It's a convenient way to carry out multiple administrative tasks without needing to prepend sudo to each command.

      How sudo su works:

      Basic usage:

      Run this command on your terminal : sudo su

      ➥ You'll be prompted for your password (your own password, not root’s password — depending on your sudo configuration). Please not that the password you enter will not be visible so ensure you type in the correct password.
      ➥ Once authenticated, your command prompt typically changes to something like: root@hostname:~#

      …the # indicates you’re now the root user.

    • Example 1 : Update packages with root privileges

      Instead of running:

      sudo apt update

      sudo apt upgrade

    • the following lets you become root first:

      sudo su

      apt update

      apt upgrade

      exit

      (where exit exits root back to your normal account)

    • Summary:

    • sudo su = Become root after validating with your password (provided you have sudo privilege).

    • su = Become root directly by entering root’s password (if root’s password is set).

    • It's a convenient way to perform multiple administrative tasks without repeatedly typing sudo.

  2. PACKAGE MANAGEMENT: “apt update”, “apt upgrade”

    Package management refers to the process of installing, updating, configuring, or removing software packages on your Linux system.
    Every Linux distribution typically comes with its own package manager — this helps you manage software efficiently.

    Here are some popular Linux package managers:

    | Distribution | Package Manager | Command | | --- | --- | --- |

    Ubuntu, Debian, Linux Mint

    APT (Advanced Packaging Tool)

    apt

    Fedora, CentOS, Red Hat

    DNF or YUM

    dnf or yum

    Arch Linux, Manjaro

    Pacman

    pacman

    openSUSE

    Zypper

    zypper

    Alpine

    apk

    apk

    Run “apt update” to update package lists for upgrade

    Run “apt upgrade” to install the newest versions of all packages currently installed on the system.

    Run “apt list —upgradable” to list all packages that have available upgrades

    IMPORTANCE OF PACKAGE MANAGEMENT

    Security — Packages include bug fixes and vulnerability patches.
    Consistency — All files for a package are installed in standard locations.
    Dependencies — The package manager handles prerequisites for you.
    Clean-up — Easily remove packages without orphan files.
    Installing from Repositories — Allows you to reuse trustworthy, curated software.

  3. WORKING WITH DIRECTORIES

    Commands to work with directories

    Directories in Linux are containers that hold files and other directories (subdirectories).
    They enable you to organize files in a hierarchical structure, much like folders in other operating systems.

    Here are some important Linux directories and their purposes:

    | Directory | Description | | --- | --- | | / (root) | The root directory — base of the Linux filesystem | | /bin | Stores essential binary files (executable programs) | | /sbin | Stores system administration programs | | /etc | Stores configuration files for the system | | /home | Stores user home directories (each user's files) | | /root | The home directory for root (administrator) | | /lib | Stores critical shared libraries | | /lib64 | Stores 64-bit libraries | | /opt | Stores third-party or optional software | | /tmp | Temporary files; often cleared upon reboot | | /usr | tStores user programs and data | | /usr/bin | Executable files for ordinary users | | /usr/sbin | Executable files for administrators | | /usr/lib | Libraries for programs in /usr/bin | | /var | Stores variable files (logs, caches, messages, etc) | | /boot | Stores files needed to boot the OS | | /dev | Stores device files (representing hardware) | | /media or /mnt | Temporary mount points for removable media or filesystems |

    WORKING WITH DIRECTORIES

    To create a directory, run “mkdir directory-name”

    To remove a directory, run “rmdir directory-name” (directory must be empty)

    To force remove a directory, run “rm -r directory-name” (this deletes directory and its content)

    To change directory, run “cd directory-name”

    To go up to parent directory, run “cd ..”

    To list directory content, run “ls” : This command lists the contents of the current directory

    “ls -l” : Use this command to verify information in your file. It gives a long display output about files listed

    "ls -a” : List all files and directories, including hidden ones.

  4. FILES:

    In Linux, everything is a file — whether it's a text document, an image, a directory, a socket, or even a hardware device.
    Files are containers for data and information.

    Types of files

    Regular files — text files, documents, images, programs, etc.
    Directories — folders that hold files or other directories
    Symbolic links — shortcuts or references to another file
    Device files — represent hardware components (like disks or terminals)
    Special files — FIFO, sockets, and other IPC mechanisms

    Commands to work with files:

    Create a new file**: ”**touch file-name.txt”

    Edit a file: “nano file-name.txt”, “vi file-name.txt”

    View file content: “cat file-name.txt”

    Copy a file: “cp source.txt destination.txt”

    Move or rename a file: “mv old-name.txt new-name.txt”

    Remove a file: “rm file-name.txt”

    File paths:

    Absolute path:

    • Starts with / — specifies the complete path from root.

    • Example: /home/user/documents/file.txt

Relative path:

  • From your current directory.

  • Example: ./file.txt or ../file.txt

  1. PERMISSIONS

    Every Linux file has permissions (read, write, execute) for owner, group, and others.

    View permissions: “ls -l”

    Change permissions: “chmod 755 script.sh (rwxr-xr-x)

    Change owner or group: “chown owner:group file-name.txt”

  2. What is a Shell?

    A shell is a program that provides a text-based interface for users to interact with the operating system.

    Popular shells include:

    Shell

    Description

    sh

    Bourne Shell (original UNIX shell)

    bash

    Bourne Again SHell (most common, Linux default)

    zsh

    Z Shell (more advanced features)

    csh

    C Shell (uses C-like syntax)

    fish

    Friendly Interactive Shell (user-friendly design)

    A shell script is a file that contains a sequence of shell commands that are executed in order.

    Key Characteristics of Shell Scripts

    • Plain text files (.sh)

    • Run using bash scriptname.sh or ./scriptname.sh

    • Start with a shebang (#!/bin/bash) to specify the interpreter

    • Can use:

      • Variables

      • Conditions (if, else)

      • Loops (for, while)

      • Functions

Command substitution ($(command))

Example: Simple Script

bash

Copy

#!/bin/bash

read -p “Enter your age: “age”

if [$age -ge 25 ];then

echo “hmn! you are old enough to settle down.”

else

echo “you are still young, go and hustle”

fi

This script:

  1. Asks for the user’s age

  2. If age entered is greater than 25, tells the user he is old enough to settle down,

  3. but if younger than 25, tells the user to work hard as he is still young

    1. How to ADD a User

To add a user, run: “sudo adduser username”

Using adduser (higher level tool — interactive):

This will:

  • Create a new account

  • Set up a home directory (/home/username)

  • Prompt you to set a password

  • Ask for additional info (Full Name, Phone Number, etc)

    1. How to ADD a Group
  • Using addgroup (higher level — interactive): sudo addgroup groupname

    Using groupadd (lower level): sudo groupadd groupname

    1. How to ADD a User to a Group

“sudo usermod -a -G groupname username”

  • How to View User or Group Information

  • List groups for a particular user: “groups username”

    ✅ View all users: “cat /etc/passwd”

    ✅ View all groups: “cat /etc/group”

  1. HISTORY - The history command helps you keep track of the commands you’ve executed in the terminal session, which can be useful for recalling complex command sequences or troubleshooting issues.

    CONCLUSION

    Mastering these Linux commands is essential for anyone who intends to use the Linux operating system effectively. Each command plays a fundamental role in managing files, directories, and packages within a Linux environment.

    By understanding and utilizing these commands, users can efficiently navigate the filesystem, edit text files, and maintain the system's software.

    These skills are crucial for both beginners and experienced users, enabling them to perform tasks more efficiently, automate processes, and manage their systems with greater control and precision.

1
Subscribe to my newsletter

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

Written by

Funmilola Musari
Funmilola Musari