About the Linux Commands Cheat Sheet (DevOps)
The commands worth knowing well are not the obscure ones — they are the handful you will use every day for the rest of your career, used properly. Navigating a filesystem, finding a file, following a log, seeing what is consuming resources and what is listening on a port covers the large majority of real work.
The most valuable habit is knowing which tool answers which question. Disk full is a different question from directory large, which is different again from a deleted file still held open by a process — and that last one explains the classic case where usage reports a full disk while the files appear to have been removed.
Permissions are where newcomers lose the most time. The three-triple model of owner, group and other is simple once seen clearly, and the common failure is not permissions on the file itself but on a directory in its path, because traversing a directory requires execute permission on it.
Frequently asked questions
My disk is full but I deleted the files. Why is the space not back?
A process still has the deleted file open, so the kernel keeps the data until that file descriptor closes. List open files and filter for deleted entries to find the culprit — usually a log file removed without restarting the service writing to it. Restarting that process releases the space; truncating the file rather than deleting it avoids the situation.
How do I find what is using a port?
Use the socket statistics tool with the options for listening sockets and process information. This shows which process holds the port, which is what you need when a service will not start because the address is already in use. The older netstat may not be installed on modern minimal images.
What is the difference between the load average and CPU usage?
Load average counts processes that are runnable or in uninterruptible sleep, which includes those waiting on disk. A machine with high load and low CPU is usually blocked on I/O rather than compute. Interpret load relative to core count — a load of 4 on four cores is fully utilised, and on sixteen cores it is quiet.
How do I search inside many files efficiently?
Use grep recursively with the options to exclude directories you do not care about, or a faster modern alternative if available. When looking for files by name or attribute rather than content, use find and let it filter before you process, since piping everything into a filter is far slower on a large tree.
Why does chmod not fix my permission denied error?
The permissions on the file may be fine while a parent directory blocks traversal — reaching a file requires execute permission on every directory in its path. Check the whole path rather than the leaf. On systems with SELinux or AppArmor, the context can also deny access independently of the traditional permission bits.