Introduction / Why This Is Useful
The Linux terminal isn't a relic of the past—it's the fastest tool for system management. Graphical interfaces are convenient, but the console enables bulk operations, automates routine tasks, and provides precise control over a server or desktop. After completing this guide, you'll be able to navigate directories confidently, manage files, and diagnose basic issues without touching the mouse.
Requirements / Preparation
- Access to a Linux system (locally or via SSH)
- A user account with standard user privileges. System operations will require
sudoaccess - Internet connection to install additional packages (if necessary)
💡 Tip: Avoid running commands as
rootunless absolutely necessary. Working as a standard user withsudoprotects the system from accidental damage.
Navigating the Filesystem
In Linux, everything starts at the root /. Understanding the directory structure is the first step to confident console work.
Viewing the Current Directory and Contents
To see where you are, use pwd (print working directory):
pwd
The output will show the full path, for example: /home/your_name.
To list files and folders, use ls (list):
ls -la
The -l flag outputs detailed information (permissions, owner, size, modification date), while -a shows hidden files starting with a dot.
Moving Between Directories
The cd command (change directory) moves you through the filesystem:
cd ~/Documents
Useful shortcuts:
cd ..— move up one levelcd ~or justcd— return to your home directorycd -— return to the previous directory
Managing Files and Directories
Creating, copying, and deleting files works logically but requires attention to paths.
Creating, Copying, and Moving
To create a directory:
mkdir -p project/src/docs
The -p flag automatically creates the entire chain of nested directories if they don't exist.
Create an empty file:
touch notes.txt
Copy or move a file:
cp notes.txt ~/Documents/backup_notes.txt
mv backup_notes.txt ~/Downloads/
Safe Deletion
Deletion in the terminal is irreversible. To delete a file:
rm temp.log
To delete a directory and all its contents:
rm -rf project/
⚠️ Important: Always double-check the path before running
rm -rf. A mistake in the argument could erase system data.
Monitoring Resources and Searching Information
The console lets you quickly assess system status and find information within text.
Checking Disk and Memory
Check free disk space:
df -h
The -h flag formats output in human-readable units (GB, MB).
Check RAM usage:
free -h
Reading Files and Searching Content
To quickly view the end of a log file:
tail -n 20 /var/log/syslog
Search for a string in a file using grep:
grep "error" /var/log/syslog
The -i flag ignores case, while -r enables recursive search through all files in a directory.
Verification
To confirm you've mastered these skills, complete this test scenario:
- Create a
test_envfolder in your home directory and navigate into it. - Inside, create two files:
config.txtanddata.log. - Copy
config.txttoconfig_backup.txt. - Verify all files exist using
ls -la. - Check disk usage with
df -hand free up space by deletingdata.log.
If the ls output matches expectations and df shows current data—you've mastered the basics.
Common Issues
- Permission denied: You're trying to modify a file owned by another user or the system. Add
sudobefore the command or check permissions withls -l. - Command not found: The package isn't installed or there's a typo. Check syntax or install the utility via your distribution's package manager (e.g.,
sudo apt install <package_name>). - Argument list too long: Occurs when trying to process thousands of files with one command (e.g.,
rm *). Usefind . -type f -deleteor break the operation into stages. - Spaces in filenames: If a path contains spaces, escape them with a backslash
My\ Folder/or wrap the entire path in quotes"My Folder/".