If you work as a developer, knowing your way around the terminal is a fundamental skill. Here is a list of essential commands grouped by category.
1. Navigation and File Management#
pwd - print the current working directory
ls - list the files in the current directory
ls -la - list all files (including hidden ones) with details
cd <dir> - change directory
cd .. - go up one directory
cd ~ - go to the user’s home directory
cd - - go back to the previous directory
mkdir <dir> - create a new directory
mkdir -p <path/to/dir> - create nested directories
touch <file> - create an empty file or update its timestamp
cp <source> <dest> - copy a file
cp -r <source> <dest> - copy a directory with all its contents
mv <source> <dest> - move or rename files and directories
rm <file> - remove a file
rm -rf <dir> - remove a directory and all its contents, without asking for confirmation
Careful:
rmdoesn’t use a trash bin. Whatever you delete withrm -rfis gone for good: double-check the path before pressing Enter.
2. Viewing and Searching#
cat <file> - show the content of a file
less <file> - view a file with scrolling (q to quit)
head -n 10 <file> - show the first 10 lines
tail -n 10 <file> - show the last 10 lines
tail -f <file> - follow additions to a file in real time (useful for logs)
grep "pattern" <file> - search for text in a file
grep -rn "pattern" . - search for text recursively in the current directory, showing line numbers
find . -name "*.js" - find files by name
wc -l <file> - count the lines of a file
3. Pipes and Redirection#
The real power of the terminal comes from combining commands.
command1 | command2 - pass the output of the first command as input to the second
command > file.txt - write the output to a file (overwriting it)
command >> file.txt - append the output to the end of a file
command 2> errors.log - save only the errors to a file
command > out.log 2>&1 - save output and errors to the same file
# The 5 largest items in the current folder
du -sh * | sort -rh | head -n 5
# How many lines contain "ERROR" in a log
grep -c "ERROR" app.log4. Permissions and Ownership#
chmod +x <file> - make a file executable
chmod 755 <file> - rwx for the owner, r-x for group and others
chmod 644 <file> - rw- for the owner, r-- for group and others (typical for text files)
chown user:group <file> - change owner and group
sudo <command> - run a command with administrator (root) privileges
5. Processes and System#
ps aux - show all running processes
top - dynamic monitor of processes and resources
htop - interactive, more readable version of top (often needs to be installed separately)
kill <pid> - ask a process to terminate, given its PID
kill -9 <pid> - forcefully kill a process that isn’t responding
killall <name> - kill all processes with a given name
df -h - show available disk space
du -sh <dir> - show the total size of a directory
free -h - show RAM usage
uname -a - show kernel and system information
6. Networking#
ping <host> - check whether a host is reachable
curl <url> - transfer data from/to a server
curl -I <url> - show only the response headers
wget <url> - download a file from the web
ss -tuln - show listening ports (replaces the old netstat -tuln)
ip a - show network interfaces and IP addresses
ssh user@host - secure remote connection
scp <file> user@host:<path> - secure file copy between hosts
7. Packages and Services#
sudo apt update && sudo apt upgrade - refresh the package list and upgrade the system (Debian/Ubuntu; Fedora uses dnf)
sudo apt install <package> - install a package
systemctl status <service> - show the status of a service (e.g. nginx)
sudo systemctl restart <service> - restart a service
sudo systemctl enable <service> - start the service automatically at boot
journalctl -u <service> -f - follow a service’s logs in real time
8. Archives and Compression#
tar -czvf archive.tar.gz <dir> - create a compressed archive
tar -xzvf archive.tar.gz - extract a compressed archive
zip -r archive.zip <dir> - create a zip archive
unzip archive.zip - extract a zip archive
9. Variables, Environment and Help#
env - show environment variables
export VAR=value - set an environment variable
echo $VAR - print the value of a variable
which <command> - show the path of the program that will run
history - show the history of executed commands
alias name='command' - create an alias for a command
man <command> - open a command’s manual (q to quit)
Bonus: Terminal Editors#
nano <file> - simple text editor (Ctrl + O to save, Ctrl + X to exit)
vim <file> - advanced text editor (:wq to save and quit, :q! to quit without saving)
Knowing these commands will make you much more productive and independent in your development environment!




