Ubuntu Linux Terminal Commands: Complete Guide for Dell PCs
Summary: Learn the most important Ubuntu Linux terminal commands for your Dell PC. Step-by-step guide covering files, software, network, users, and shortcuts.
Instructions
Terminal commands are instructions you can use in the Ubuntu terminal app to accomplish tasks on your computer. Whether you're new to Linux or just need a quick reference, this guide walks you through the most common and useful Ubuntu terminal commands, from managing files and software to checking your network and system information.
What Is the Ubuntu Terminal?
The Linux command line is a text interface to your computer. Often referred to as the shell, terminal, console, or prompt, it can give the appearance of being complex and confusing to use. But don't worry, it's simpler than it looks, and this guide will get you comfortable quickly.
The Ubuntu terminal, also known as the command-line interface or shell, is a text-based environment that allows you to interact with your computer's operating system. Unlike graphical user interfaces (GUIs) that rely on visual elements like windows, icons, and buttons, the terminal communicates through typed commands.
How to Open the Terminal on Ubuntu
There are two easy ways to open the terminal:
Option 1: Keyboard shortcut (fastest)
- Press Ctrl + Alt + T on your keyboard.
Option 2: Search from the Activities menu
- Click the Activities button in the upper-left corner of your screen.
- Type Terminal in the search bar.
- Click the Terminal app when it appears.
Understanding the Terminal Prompt
When you open the terminal, you'll see a blinking cursor next to some text. When you type a command, it appears on the same line as this text. That text is there to tell you the computer is ready to accept a command, it's the computer's way of prompting you. In fact, it's usually referred to as the prompt.
When you run a command, any output it produces will usually be printed directly in the terminal, then you'll be shown another prompt once it's finished. Some commands can output a lot of text; others will operate silently and won't output anything at all. Don't be alarmed if you run a command and another prompt immediately appears, that usually means the command succeeded.
Section 1: Navigating the File System
These commands help you move around folders (called directories in Linux) and understand where you are.
| Command | What It Does | Example |
|---|---|---|
pwd |
Shows your current folder location | pwd |
ls |
Lists files and folders in the current directory | ls |
ls -l |
Lists files with details like permissions, size, and date | ls -l |
ls -a |
Shows all files, including hidden ones | ls -a |
cd foldername |
Changes to a specific folder | cd Documents |
cd .. |
Goes back one folder level | cd .. |
cd ~ |
Goes directly to your home folder | cd ~ |
The pwd command displays the path of the current directory (folder) you're in. When you first open the terminal, you're in your home directory by default.
The ls command displays files and directories within a specified location. Common options include -a (shows hidden files, including those starting with a dot) and -l (displays a detailed list with permissions, ownership, size, and timestamps).
Section 2: Managing Files and Folders
These commands directly affect the files and text stored and used on your computer.
| Command | What It Does | Example |
|---|---|---|
mkdir foldername |
Creates a new folder | mkdir MyProject |
touch filename |
Creates a new empty file | touch notes.txt |
cp source destination |
Copies a file to a new location | cp notes.txt ~/Documents/ |
mv source destination |
Moves or renames a file | mv notes.txt renamed.txt |
rm filename |
Deletes a file | rm oldfile.txt |
rm -r foldername |
Deletes a folder and everything inside it | rm -r OldFolder |
cat filename |
Displays the contents of a file | cat notes.txt |
nano filename |
Opens a file for editing in a simple text editor | nano notes.txt |
grep "text" filename |
Searches for specific text inside a file | grep "error" log.txt |
rm command permanently deletes files. There is no recycle bin in the terminal. Always check before you run it.
The rm command is used to delete files. One significant aspect of Unix-like systems (including Ubuntu) is their file permission system.
The cat command displays, combines, or creates files by reading and writing file content. Common options include -n (displays line numbers alongside file content) and -b (displays line numbers for non-empty lines only).
The grep command searches for specific patterns or keywords within files or command output. Common options include -i (performs a case-insensitive search), -r (searches recursively through directories), and -n (displays line numbers with matching results).
Section 3: Installing and Managing Software
As a Debian-based Linux distribution, Ubuntu uses the APT package manager to install, update, and remove software packages via the command line.
Ubuntu includes both apt and apt-get. They use the same package database but are aimed at different jobs. apt is the better interactive tool for terminal sessions because its output is designed for humans. apt-get is the safer default for scripts because its command-line behavior is more stable across APT releases.
| Command | What It Does |
|---|---|
sudo apt update |
Refreshes the list of available software packages |
sudo apt upgrade |
Installs available updates for all installed packages |
sudo apt install packagename |
Installs a specific software package |
sudo apt remove packagename |
Removes a software package |
sudo apt autoremove |
Removes packages that are no longer needed |
To update your system, follow these steps:
- Open the terminal using Ctrl + Alt + T.
- Type the following command and press Enter to refresh the package list:
sudo apt update - Enter your password when prompted, then press Enter.
- Type the following command and press Enter to install available updates:
sudo apt upgrade - When asked to confirm, type Y and press Enter.
apt update fetches the latest package lists from the configured repositories. This does not upgrade any packages, it only updates the information about what packages are available.
To install a specific application:
- Open the terminal.
- Type the following command, replacing packagename with the app you want to install:
sudo apt install packagenameExample: To install the VLC media player, type:sudo apt install vlc - Press Enter, type Y when prompted, and press Enter again.
Section 4: Checking System Information
Use these commands to find out details about your Dell PC's hardware and software.
| Command | What It Does |
|---|---|
uname -a |
Shows the kernel version and system architecture |
lsb_release -a |
Shows your Ubuntu version |
df -h |
Shows disk usage for all drives (human-readable) |
free -h |
Shows how much RAM is available |
top |
Shows real-time CPU and memory usage |
htop |
Shows an improved, interactive view of running processes |
uptime |
Shows how long the system has been running |
date |
Displays the current date and time |
whoami |
Shows which user you're currently logged in as |
hostname |
Shows your computer's name on the network |
The uname command prints system information such as kernel version and architecture. Use uname -a to display all available system information at once.
The top command displays real-time information about system activity. It displays dynamic information about system processes.
Before upgrading Ubuntu to a new release, it's essential to prepare your system. Check disk space to ensure you have enough free space to download and install upgraded packages. You can check the disk space using the df -h command.
Section 5: Managing Users and Groups
User management is a critical part of maintaining a secure system. Ineffective user and privilege management often leads to a system being compromised.
| Command | What It Does |
|---|---|
whoami |
Shows the current logged-in user |
sudo adduser username |
Creates a new user account |
sudo deluser username |
Removes a user account |
passwd |
Changes your password |
sudo passwd username |
Changes another user's password |
sudo usermod -aG groupname username |
Adds a user to a group |
groups username |
Shows which groups a user belongs to |
id |
Shows the current user's ID and group memberships |
adduser is a high-level, user-friendly script that simplifies the process of creating a new user account. It interactively prompts for information, automatically creates a home directory, copies skeleton files (like .bashrc and .profile), sets appropriate permissions, and assigns a default shell. In most cases, it's the recommended command for creating users on Debian-based systems like Ubuntu.
To add a new user, follow these steps:
- Open the terminal.
- Type the following command, replacing username with the new user's name:
sudo adduser username - Press Enter and follow the on-screen prompts to set a password and fill in optional details.
To give a user admin (sudo) access:
The easiest way to grant sudo privileges in Ubuntu is to add the user to the sudo group. Members of this group can execute any command as root and are prompted for their password when using sudo.
- Open the terminal.
- Type the following command, replacing username with the user's name:
sudo usermod -aG sudo username - Press Enter. The changes take effect the next time the user logs in.
visudo command to edit the sudoers file. This command validates the syntax before saving, preventing errors that could lock you out of sudo access entirely.
Section 6: Managing File Permissions
Every file and directory has a set of permissions that determine who can read, write, or execute it.
| Symbol | Meaning |
|---|---|
r |
Read |
w |
Write |
x |
Execute |
| Command | What It Does | Example |
|---|---|---|
ls -l |
Views permissions for files in a folder | ls -l |
chmod 755 filename |
Sets read/write/execute for owner; read/execute for others | chmod 755 script.sh |
chmod 644 filename |
Sets read/write for owner; read-only for others | chmod 644 file.txt |
chown user:group filename |
Changes the owner and group of a file | chown john:staff file.txt |
A strong permission strategy is built on the Principle of Least Privilege (PoLP), meaning users and processes should only have the minimum necessary access to perform their intended functions.
Section 7: Network Commands
Use these commands to check your network connection, find your IP address, and troubleshoot connectivity.
| Command | What It Does |
|---|---|
ip addr or ip a |
Shows your IP address and network interfaces |
ping google.com |
Tests your internet connection |
ping -c 4 google.com |
Sends exactly 4 ping packets and stops |
wget URL |
Downloads a file from the internet |
curl URL |
Transfers data to or from a server |
hostname -I |
Displays your local IP address |
ss -tlnp |
Lists open network ports |
ifconfig command is deprecated and has been replaced by the ip command in most modern Linux distributions. It is part of the net-tools package, which may not be installed by default on newer systems. We recommend using ip addr instead.
The ip command is one of the most basic and helpful network commands in Linux. It typically displays the status of network interfaces and IP addresses assigned to your system. It succeeds the older ifconfig command, which is now deprecated.
Ping is a simple but powerful network tool that helps you check the connectivity between your computer and a remote host (such as a website, server, or another computer). It sends small data packets called "echo requests" to the target host, which then responds with "echo replies." A successful ping shows that there is a connection to the destination.
To check if your internet connection is working:
- Open the terminal.
- Type the following command and press Enter:
ping -c 4 google.com - If you see replies, your connection is working. If you see errors, check your network settings.
The curl and wget commands in Linux are both used for downloading files from the internet via the command line. These commands offer a convenient way to fetch files, web pages, or other resources directly from a specified URL.
Section 8: Process Management
These commands help you see what's running on your Dell PC and stop anything that isn't responding.
| Command | What It Does |
|---|---|
ps aux |
Lists all running processes |
top |
Shows live system resource usage |
kill PID |
Stops a process by its ID number |
killall processname |
Stops all processes with a given name |
Ctrl + C |
Stops the currently running terminal command |
Process management commands such as ps, kill, killall, and top are essential for monitoring system health and terminating unresponsive processes.
To stop an unresponsive program:
- Open the terminal.
- Type the following command and press Enter to find the program's process ID (PID):
ps aux | grep programname - Note the PID number in the second column.
- Type the following command, replacing PID with the actual number, and press Enter:
kill PID
Section 9: Helpful Terminal Shortcuts
These keyboard shortcuts save time and make your terminal experience much smoother.
| Shortcut | What It Does |
|---|---|
| Ctrl + Alt + T | Opens a new terminal window |
| Ctrl + C | Stops the current command |
| Ctrl + Z | Pauses (suspends) the current command |
| Ctrl + D | Closes the terminal session |
| Ctrl + L | Clears the terminal screen |
| Tab | Auto-completes a command or filename |
| Up/Down arrow keys | Scrolls through previous commands |
| Ctrl + R | Searches your command history |
| Ctrl + A | Moves the cursor to the beginning of the line |
| Ctrl + E | Moves the cursor to the end of the line |
| Ctrl + U | Clears the current line |
Mastering shortcuts like Ctrl + R for reverse command search, Ctrl + A/Ctrl + E for moving to the start/end of the line, and tab completion for commands and filenames can save precious time.
cd Doc and then press Tab, and the terminal fills in the rest to make it cd Documents.
Section 10: Getting Help in the Terminal
You don't need to memorize every command. Ubuntu has built-in help tools.
| Command | What It Does |
|---|---|
man commandname |
Opens the manual (full documentation) for any command |
commandname --help |
Shows a quick summary of command options |
whatis commandname |
Gives a one-line description of a command |
Example: To learn more about the ls command, type:
man ls
Press Q to exit the manual.
Troubleshooting Common Issues
"Command not found" error
This usually means one of the following:
- The package is not installed. Install it using:
sudo apt install packagename. - Linux is case-sensitive, so
LSandlsare treated as different commands. Verify spelling and capitalization.
"Permission denied" error
This error indicates that your user account lacks the required permissions to run a command or access a file. Run the command with elevated privileges using sudo, or modify file permissions with chmod if needed.
Network not reachable
- Run
ip addrto check that your network interface is active. - If ping works with an IP address but fails with a domain name, the issue is DNS. Run
dig domainto check whether your configured DNS server returns an answer. If the ANSWER SECTION is empty, try a different resolver usingdig @8.8.8.8 domain.
Quick Reference: Most Used Ubuntu Terminal Commands
| Category | Command | What It Does |
|---|---|---|
| Navigation | pwd |
Shows current location |
| Navigation | ls |
Lists files |
| Navigation | cd foldername |
Changes folder |
| Files | cp, mv, rm |
Copy, move, delete files |
| Software | sudo apt update |
Refreshes package list |
| Software | sudo apt install |
Installs software |
| System Info | df -h |
Checks disk space |
| System Info | free -h |
Checks RAM |
| Network | ip addr |
Shows IP address |
| Network | ping |
Tests connection |
| Users | sudo adduser |
Creates a new user |
| Help | man commandname |
Opens command manual |
Frequently Asked Questions (FAQs)
Q: What is the Ubuntu terminal used for?
The Ubuntu terminal is a text-based tool that lets you install software, manage files, check your network, control users, and much more, often faster than using a graphical interface.
Q: How do I open the terminal on Ubuntu?
Press Ctrl + Alt + T on your keyboard. This works on most Ubuntu versions, including Ubuntu 22.04 and 24.04.
Q: What is sudo in Ubuntu?
sudo (SuperUser DO) allows you to run programs or other commands with administrative privileges, just like "Run as administrator" in Windows.
Q: How do I stop a command that is running in the terminal?
Press Ctrl + C to stop a running command at any time.
Q: How do I update Ubuntu from the terminal?
Run sudo apt update to refresh the package list, then run sudo apt upgrade to install all available updates.
Q: Is ifconfig still available in Ubuntu?
ifconfig is part of the net-tools package. If you need it on a modern Ubuntu system, install it with sudo apt install net-tools. However, the preferred modern command is ip addr.
Q: How do I check my Ubuntu version from the terminal?
Type lsb_release -a and press Enter. This shows your Ubuntu version and codename.