The Linux command line is one of the most powerful tools available to users and system administrators. While modern Linux distributions provide graphical interfaces, the command line offers greater flexibility, speed, and control over the operating system.
This tutorial introduces the basic Linux commands every beginner should know.
What Is the Command Line?
The command line is a text-based interface that allows users to interact with the operating system by typing commands.
In Linux, the command-line interface is commonly called the shell. The most widely used shell is Bash (Bourne Again Shell).
When you open a terminal window, you are interacting with the shell.
A typical command prompt may look like this:
ron@linux:~$
The dollar sign ($) indicates that you are logged in as a regular user.
Finding Your Current Directory
The pwd command displays your current working directory.
pwd
Example output:
/home/ron
This means you are currently in the user’s home directory.
Listing Files and Directories
The ls command displays files and directories.
ls
Example:
Documents Downloads Pictures
To display detailed information:
ls -l
To show hidden files:
ls -la
Changing Directories
Use the cd command to move between directories.
Change to the Documents directory:
cd Documents
Move up one directory:
cd ..
Return to your home directory:
cd ~
Creating Directories
Create a new directory using mkdir.
mkdir projects
Verify it exists:
ls
Creating Files
Create an empty file using touch.
touch notes.txt
View the file:
ls
Copying Files
Use the cp command to copy files.
cp notes.txt backup.txt
You now have two files:
notes.txt
backup.txt
Moving and Renaming Files
Use mv to move or rename files.
Rename a file:
mv notes.txt mynotes.txt
Move a file to another directory:
mv mynotes.txt Documents/
Removing Files
Delete a file using rm.
rm backup.txt
Be careful: deleted files generally cannot be recovered easily.
Removing Directories
Delete an empty directory:
rmdir projects
Delete a directory and its contents:
rm -r projects
Use caution with recursive deletion.
Viewing File Contents
Display a file’s contents:
cat myfile.txt
View long files one page at a time:
less myfile.txt
Press q to quit.
Displaying System Information
View your Linux kernel version:
uname -r
Display complete system information:
uname -a
Finding Files
Locate files with the find command.
Find a file named notes.txt:
find . -name notes.txt
Search the entire system:
find / -name notes.txt
Administrative privileges may be required.
Viewing Running Processes
Display running processes:
ps
View all running processes:
ps aux
A more interactive process viewer:
top
Press q to exit.
Viewing Disk Usage
Display filesystem usage:
df -h
Example output:
Filesystem Size Used Avail Use%
/dev/sda1 100G 40G 60G 40%
The -h option makes sizes human-readable.
Viewing Memory Usage
Check memory utilization:
free -h
Example:
Mem: 8.0G 3.1G 4.9G
Downloading Files
Download files from the internet using wget.
wget https://example.com/file.zip
Or with curl:
curl -O https://example.com/file.zip
Installing Software
On Debian and Ubuntu systems:
Update package information:
sudo apt update
Upgrade installed packages:
sudo apt upgrade
Install a package:
sudo apt install nginx
On Fedora:
sudo dnf install nginx
On FreeBSD:
sudo pkg install nginx
Understanding File Permissions
Display file permissions:
ls -l
Example:
-rw-r--r-- 1 ron users 1024 file.txt
Permission types:
- r = read
- w = write
- x = execute
Change permissions:
chmod 755 script.sh
Make a script executable:
chmod +x script.sh
Using Manual Pages
Most Linux commands include documentation.
View a command’s manual page:
man ls
Search within the manual using /.
Quit by pressing:
q
Useful Commands Summary
| Command | Purpose |
|---|---|
| pwd | Show current directory |
| ls | List files |
| cd | Change directory |
| mkdir | Create directory |
| touch | Create file |
| cp | Copy file |
| mv | Move or rename file |
| rm | Delete file |
| cat | Display file contents |
| find | Search for files |
| ps | View processes |
| top | Monitor processes |
| df | Show disk usage |
| free | Show memory usage |
| wget | Download files |
| chmod | Change permissions |
| man | View documentation |
Conclusion
Learning the Linux command line is one of the most valuable skills for anyone interested in Linux, system administration, software development, or cybersecurity. Although modern graphical interfaces make many tasks easier, understanding command-line tools provides greater control over the operating system and helps users work more efficiently. By mastering the commands covered in this tutorial, beginners can build a strong foundation for more advanced Linux administration and scripting tasks.