DEV Community

Cover image for Mastering Ubuntu: The Essential Commands You Need to Know
Isaiah Izibili
Isaiah Izibili

Posted on

Mastering Ubuntu: The Essential Commands You Need to Know

*Introduction *

Whether you're just dipping your toes into Linux or managing a full-blown Ubuntu server, knowing your way around the terminal is non-negotiable. In this guide, we’ll walk through the most essential Ubuntu commands—step by step—explaining not just how to use them, but why they matter. From installing packages to navigating directories and monitoring system health, this article is your launchpad into the world of Linux command-line mastery.

🐧 Essential Ubuntu Commands Explained Step-by-Step

Ubuntu is one of the most popular Linux distributions, widely used for development, server management, and learning Linux fundamentals. Below is a breakdown of key commands every Ubuntu user should know, what they do, and why they’re important.

🔐 sudo su

  • What it does: Switches to the superuser (root) account.
  • Why it matters: Some tasks require elevated privileges. sudo su gives you full access to the system.
  • How to use:
sudo su
Enter fullscreen mode Exit fullscreen mode

You'll be prompted for your password. Once entered, your shell changes to root (# prompt).

Sudocommand

📦 Package Management
apt update

  • What it does: Refreshes the list of available packages and versions.
  • Why it matters: Ensures you're installing the latest versions.
  • How to use:
sudo apt update
Enter fullscreen mode Exit fullscreen mode

apt update

apt install vim

  • What it does: Installs the Vim text editor.
  • Why it matters: Vim is a powerful tool for editing configuration files and code.
  • How to use:
sudo apt install vim
Enter fullscreen mode Exit fullscreen mode

vim

apt install nginx

  • What it does: Installs the Nginx web server.
  • Why it matters: Nginx is widely used for hosting websites and reverse proxying.
  • How to use:
sudo apt install nginx
Enter fullscreen mode Exit fullscreen mode

nginx

📁 File & Directory Management

mkdir

  • What it does: Creates a new directory.
  • Why it matters: Organize files into folders.
  • How to use:
mkdir my_folder
Enter fullscreen mode Exit fullscreen mode

ls

  • What it does: Lists files and directories.
  • Why it matters: Helps you see what’s in your current directory.
  • How to use:
ls
Enter fullscreen mode Exit fullscreen mode

Iist

cd

  • What it does: Changes the current directory.
  • Why it matters: Navigate your file system.
  • How to use:
cd my_folder
Enter fullscreen mode Exit fullscreen mode

Cd folder

ls -l

  • What it does: Lists files with detailed info (permissions, size, date).
  • Why it matters: Useful for checking file attributes.
  • How to use:
ls -l
Enter fullscreen mode Exit fullscreen mode

hinding list

pwd

  • What it does: Prints the current working directory.
  • Why it matters: Know where you are in the file system.
  • How to use:
pwd
Enter fullscreen mode Exit fullscreen mode

pwd

touch

  • What it does: Creates an empty file.
  • Why it matters: Useful for quickly generating files.
  • How to use:
touch myfile.txt
Enter fullscreen mode Exit fullscreen mode

touch

rm

  • What it does: Deletes files.
  • Why it matters: Clean up unnecessary files.
  • How to use:
rm myfile.txt
Enter fullscreen mode Exit fullscreen mode

rmdir

  • What it does: Removes empty directories.
  • Why it matters: Helps maintain a tidy file structure.
  • How to use:
rmdir my_folder
Enter fullscreen mode Exit fullscreen mode

rmdelete

cp

  • What it does: Copies files or directories.
  • Why it matters: Duplicate files or back them up.
  • How to use:
cp file1.txt file2.txt
Enter fullscreen mode Exit fullscreen mode

coping

mv

  • What it does: Moves or renames files.
  • Why it matters: Organize or rename files.
  • How to use:
mv oldname.txt newname.txt
Enter fullscreen mode Exit fullscreen mode

move

📊 System Monitoring
df -h

  • What it does: Shows disk space usage in human-readable format.
  • Why it matters: Monitor storage capacity.
  • How to use:
df -h
Enter fullscreen mode Exit fullscreen mode

free -h

  • What it does: Displays memory usage.
  • Why it matters: Check RAM availability.
  • How to use:
free -h
Enter fullscreen mode Exit fullscreen mode

memory usage

uptime

  • What it does: Shows how long the system has been running.
  • Why it matters: Useful for server health checks.
  • How to use:
uptime
Enter fullscreen mode Exit fullscreen mode

monitor

🔍 Searching & Environment

grep

  • What it does: Searches for patterns in text.
  • Why it matters: Find specific data in files or output.
  • How to use:
grep "search_term" filename.txt
Enter fullscreen mode Exit fullscreen mode

env

  • What it does: Displays environment variables.
  • Why it matters: Useful for debugging and configuration.
  • How to use:
env
Enter fullscreen mode Exit fullscreen mode

environment variables

whoami

  • What it does: Shows the current user.
  • Why it matters: Confirm your identity, especially after switching users.
  • How to use:
whoami
Enter fullscreen mode Exit fullscreen mode

who ami

🌐 Networking
nslookup

  • What it does: Queries DNS to resolve domain names.
  • Why it matters: Diagnose network issues.
  • How to use:
nslookup example.com
Enter fullscreen mode Exit fullscreen mode

nslookup

ping

  • What it does: Sends packets to a host to test connectivity.
  • Why it matters: Check if a server or website is reachable.
  • How to use:
ping google.com
Enter fullscreen mode Exit fullscreen mode

System Info & File Viewing

uname

  • What it does: Displays system information.
  • Why it matters: Know your OS and kernel version.
  • How to use:
uname -a
Enter fullscreen mode Exit fullscreen mode

Iinux

cat

  • What it does: Displays file content.
  • Why it matters: Quickly read files.
  • How to use:
cat myfile.txt
Enter fullscreen mode Exit fullscreen mode

cat file

df

  • What it does: Shows disk usage (not human-readable by default).
  • Why it matters: Monitor storage.
  • How to use:
df
Enter fullscreen mode Exit fullscreen mode

show disk usage

Final Thoughts

Mastering these commands will give you a solid foundation in Ubuntu and Linux in general. Whether you're managing servers, writing scripts, or just exploring, these tools are your gateway to understanding and controlling your system.

Top comments (0)