Linux runs the vast majority of the world's web servers, containers and cloud services. Even developers who work on Windows or macOS end up connecting to a server over SSH sooner or later. That is why mastering the essential linux commands saves time and prevents surprises in production.
In this guide, we gather the most frequently used commands, organized by task and with practical examples.
Navigating the file system
pwd: shows the current directory.ls -lah: lists files with details, human-readable sizes and hidden files.cd /var/www: enters a directory. Usecd -to go back to the previous one.tree -L 2: displays the folder structure up to two levels deep.
Managing files and directories
mkdir -p projects/api: creates directories, including intermediate ones.cp -r source destination: copies files and folders.mv old.txt new.txt: moves or renames.rm file.txt: removes a file. Be careful:rm -rfdeletes without confirmation and there is no recycle bin.ln -s target shortcut: creates a symbolic link, widely used in deployments.
Reading and searching content
cat,lessandhead -n 20: display file contents.tail -f storage/logs/laravel.log: follows a log in real time.grep -rn "error" /var/log: searches for text across many files, with line numbers.find . -name "*.php" -mtime -1: finds PHP files changed in the last 24 hours.
Permissions and users
Every file has read (r), write (w) and execute (x) permissions for the owner, the group and everyone else.
chmod 644 file: read and write for the owner, read-only for others.chmod 755 script.sh: allows the script to run.chown -R www-data:www-data storage: changes the owner of a folder, common on web servers.sudo command: runs with administrator privileges.
Resist the temptation of chmod 777. It makes the permission error go away, but it opens a security hole.
Processes and system resources
toporhtop: show CPU and memory usage per process.ps aux | grep php: lists processes and filters by name.kill PID: stops a process. Usekill -9only as a last resort.df -h: free space on each disk.du -sh *: size of each folder in the current directory.free -h: RAM and swap usage.
Networking
ip a: shows network interfaces and IP addresses.pingandtraceroute: test connectivity and the route to a destination.curl -I https://site.com: displays only the HTTP response headers.ss -tulpn: lists open ports and the processes using them.ssh user@server: connects securely to a remote server.
Services and system logs
systemctl status nginx: checks whether a service is running.systemctl restart php8.2-fpm: restarts a service.journalctl -u nginx --since "1 hour ago": shows a service's recent logs.
Productivity tips for essential Linux commands
- Press Tab to autocomplete file names and commands.
- Press Ctrl + R to search your command history.
- Chain commands with the pipe
|, for example:cat access.log | grep 500 | wc -l. - Read the manual for any command with
manor the--helpoption.
Frequently asked questions
Which Linux distribution should I use on servers?
Ubuntu Server and Debian are the most common choices thanks to their stability and large communities. In enterprise environments, Red Hat and its derivatives are also popular.
Can I use Linux on Windows?
Yes. WSL lets you run a full Linux distribution inside Windows, which is ideal for development.
Conclusion
Mastering the essential Linux commands makes you more autonomous when investigating problems, deploying and keeping servers healthy. Practice in a test environment, create your own shortcuts and check the manual whenever you need to. If your company needs help with servers and infrastructure, WDS Developer can support you.
