Terminal Guide
Basic commands for new Linux users (Applicable to Debian-based distributions like Ubuntu, Linux Mint, Pop!_OS...)
Introduction
Welcome to the world of the terminal. In this guide, you will learn the fundamental commands to navigate Linux smoothly from the command line. Mastering the terminal is not mandatory for daily use: distributions like Ubuntu or KDE Plasma offer very comprehensive graphical environments with software stores, update managers, and visual tools. However, the terminal offers a power, speed, and flexibility that no graphical interface can match. Once you get used to it, you will discover that many tasks can be resolved in seconds with a single command.
1. System Management with APT
APT (Advanced Package Tool) is the package manager for Debian and its variants. With it, you can update the system, install and uninstall software, and much more. You will almost always need to prepend sudo to execute these commands with administrator privileges.
1.1 Update the system
Updating the system is an important habit to maintain security and stability. The process is done in two steps:
Step 1: Update the list of available packages.
This command does not download or install anything yet; it simply queries the repositories to find out which packages have new versions available.
Step 2: Download and install the updates.
1.2 Install software
To install a program available in the official Debian repositories:
For example, to install Python:
1.3 Uninstall software
To remove a program you no longer need:
If you also want to remove the configuration files left by the program:
1.4 Clean up unnecessary packages
Over time, the system accumulates packages that are no longer needed. To free up space:
1.5 Search for packages
If you don't remember the exact name of a package, you can search for it:
Example:
2. File System Navigation
In Linux, everything is a file, and the file system is organized in a directory structure that starts from the root, represented by /. Knowing how to navigate this structure is fundamental.
2.1 Where am I? — pwd
The pwd (Print Working Directory) command shows the full path of the directory you are currently in:
/home/user/Documents
2.2 View folder contents — ls
The ls command lists the files and folders in the current directory:
With more useful options:
-l: shows the list in detailed format (permissions, size, date).-a: also shows hidden files (those starting with a dot).
2.3 Move between folders — cd
The cd (Change Directory) command allows you to navigate between directories:
Practical examples:
| Command | Description |
|---|---|
cd Documents |
Enters the Documents folder (within the current directory) |
cd /home/user |
Goes directly to that absolute path |
cd .. |
Moves up one level (to the parent directory) |
cd ~ |
Goes to the current user's home directory |
cd - |
Returns to the previous directory you were in |
2.4 Create folders — mkdir
To create a new folder:
To create multiple nested folders at once:
2.5 Create files — touch
The touch command creates an empty file or updates the modification date of an existing one:
2.6 Copy, move, and delete
These three commands are essential for handling files and folders:
| Command | Description |
|---|---|
cp file.txt copy.txt |
Copies a file |
cp -r folder/ new_folder/ |
Copies an entire folder (-r = recursive) |
mv file.txt /another/path/ |
Moves a file to another location |
mv old.txt new.txt |
Renames a file |
rm file.txt |
Deletes a file |
rm -r folder/ |
Deletes a folder and all its contents |
3. View File Contents
Many times you will need to read the contents of text files directly from the terminal, without opening a graphical editor.
3.1 View all contents — cat
The cat command displays the entire contents of a file:
3.2 Read long files — less
The less command allows you to comfortably read long files by paginating the content:
Inside less, you can use the arrow keys to scroll, the spacebar to move forward one page, and the q key to exit.
3.3 View the first or last lines — head and tail
user@debian:~$ tail -n 20 file.txt # Shows the last 20 lines
4. Permissions and Users
Linux is a multi-user system with a robust permissions system. Understanding the basics will help you avoid errors and keep your system secure.
4.1 Who am I? — whoami
To find out which user you are currently working as:
4.2 Run as administrator — sudo
sudo (Super User DO) allows you to execute commands with administrator privileges without having to log in as root. Most system administration commands require it:
4.3 Change file permissions — chmod
Every file in Linux has read (r), write (w), and execute (x) permissions for the owner, the group, and other users. The chmod command modifies these permissions:
user@debian:~$ chmod 755 script.sh # Numeric format: owner=7, group=5, others=5
5. Process Management
Sometimes a program freezes or consumes too many resources. The terminal gives you tools to monitor and control running processes.
5.1 View running processes — top and htop
The top command shows active processes and their CPU and memory usage in real-time:
5.2 List processes — ps
To see a list of the system's active processes:
5.3 Terminate a process — kill
If you need to close an unresponsive process, first find its identifier (PID) using ps aux or top, and then use kill:
If the process does not respond to kill, you can force it to close:
6. Basic Network Commands
These commands will help you diagnose connection problems and obtain information about your network.
| Command | Description |
|---|---|
ping google.com |
Checks for connection with a server |
ip a |
Shows network interfaces and their IP addresses |
curl https://example.com |
Downloads the content of a URL |
wget https://file.zip |
Downloads a file from the internet |
ssh user@ip |
Connects to another machine via SSH |