Common Linux Commands
Linux runs a large share of the world’s servers, cloud infrastructure, and production systems. For developers, system administrators, and DevOps engineers, the command line is not just a convenience. It is where much of the real work happens.
Although graphical interfaces exist, many tasks are faster, repeatable, and automatable through the shell. Learning a focused set of Linux commands can significantly improve daily efficiency and make troubleshooting much easier.
Navigating Files and Directories
In Linux, the filesystem is organized like a tree. Understanding paths and directory operations is often the first practical step.
pwdprints the current working directory as an absolute path.lslists directory contents. Useful options include:-lfor long format with details.-ato show hidden files.-hfor human-readable file sizes.
cdchanges the working directory. Common forms:cd /var/logmoves into the log directory.cd ~returns to the current user’s home directory.cd ..moves to the parent directory.
mkdircreates a directory. Use-pto create nested directories, such asmkdir -p /app/logs/2023.cpcopies files or directories. Add-rwhen copying a directory.mvmoves or renames files and directories.rmremoves files or directories. Use-rfor directories and-fto force removal. Be careful withrm -rf.
Viewing and Searching Files
Once you know how to move around, you often need to inspect files and locate specific content.
catdisplays file contents. It works well for small files.lessopens files in a pager. UseSpaceto scroll down,bto scroll up, and/keywordto search forward.headandtailshow file beginnings or endings. For example,head -n 20 file.txtshows the first 20 lines, whiletail -n 50 file.txtshows the last 50.tail -f /var/log/syslogfollows a log file in real time. This is a common tool when debugging issues.grepsearches file content. For example,grep "ERROR" app.logfinds lines containingERROR. Useful options include-i,-n, and-v.
Monitoring Processes and System Resources
System administrators regularly check CPU, memory, processes, and disk usage.
psshows a snapshot of running processes. A common combination isps aux.topandhtopprovide real-time resource monitoring. Intop, you can presskand enter a process ID to terminate a process.dfshows disk space usage.df -huses human-readable sizes.duestimates disk usage. For example,du -sh /var/logshows the total size of a directory.freeshows memory usage.free -hpresents it in human-readable form.
Network and Communication Commands
Network troubleshooting is a routine part of Linux work.
pingtests connectivity. For example,ping -c 4 www.baidu.comsends four packets before stopping.curlandwgethandle HTTP requests and downloads.curl -I https://www.example.comshows response headers, whilewget https://example.com/file.zipdownloads a file.netstatorssdisplays network information. A useful command isss -tulnto view listening ports.
Permissions and User Management
Linux is multi-user and permission-aware.
chmodchanges file or directory permissions. For example,chmod 755 script.shgives the owner read, write, and execute permissions, while the group and others get read and execute.chownchanges ownership and group. For example,chown -R www:www /var/www/htmlrecursively assigns an owner and group.sudoruns a command with superuser privileges. Prefix a command withsudowhen needed.
Building Practical Confidence
The commands above cover a useful starting point, but real-world work often involves combining them with text editors, package managers, service commands, and scripting tools.
To become comfortable, practice in a safe environment. Use man pages, test options, and build small scripts. Over time, these commands move from conscious effort to muscle memory.