Introduction
🐧 Linux is a Unix-based operating system widely
used on servers, HPC clusters, and for scientific development.
This guide collects the most important commands to help you move
efficiently within the terminal.
Navigating the
Filesystem
pwd |
Show the current directory |
pwd |
ls |
List files in the directory |
ls -l |
cd |
Change directory |
cd /home/user |
mkdir |
Create a new directory |
mkdir projects |
rmdir |
Remove an empty directory |
rmdir old_folder |
💡 Tip: Use ls -a to also show hidden files (those
starting with .).
File Management
cp |
Copy files or directories |
cp file.txt backup.txt |
mv |
Move or rename files |
mv file.txt dati/file.txt |
rm |
Delete files |
rm vecchio.txt |
cat |
Display file contents |
cat note.txt |
less |
Scroll through file content |
less lungo.txt |
head / tail |
Show the first / last lines |
head -n 5 dati.txt |
⚠️ Warning: rm permanently deletes files. Use
rm -i to confirm each deletion.
Permissions and
Ownership
chmod |
Change file permissions |
chmod 755 script.sh |
chown |
Change file owner |
chown user:group file.txt |
ls -l |
Show file permissions |
ls -l |
✅ Note: Permissions are divided into three groups: user,
group, and others (e.g., -rwxr-xr–).
Processes and
Resources
top |
Show active processes |
top |
ps |
List processes |
ps aux |
kill |
Terminate a process |
kill 1234 |
df -h |
Show disk usage |
df -h |
du -sh |
Show folder size |
du -sh data/ |
❌ Common error: If kill does not work, try
kill -9 PID (force termination).
Searching and
Filtering
grep |
Search text in files |
grep "error" log.txt |
find |
Search files in the filesystem |
find /home -name "*.txt" |
sort |
Sort lines |
sort list.txt |
uniq |
Remove duplicates |
uniq list.txt |
wc |
Count lines, words, and characters |
wc -l file.txt |
Archiving and
Compression
tar |
Create / extract archives |
tar -czf backup.tar.gz folder/ |
gzip / gunzip |
Compress / decompress files |
gzip data.txt |
zip / unzip |
Create or extract zip archives |
zip -r data.zip folder/ |
Networking and
System
ping |
Test network connectivity |
ping google.com |
ssh |
Remote connection |
ssh user@server |
scp |
Copy files remotely |
scp file.txt user@server:/path/ |
uname -a |
System information |
uname -a |
df -h |
Disk status |
df -h |