Essential Linux Commands That Solve Over 95% of Common Problems
This guide introduces the Linux operating system, explains its key directories, and provides a comprehensive list of the most frequently used commands for navigation, file manipulation, permission handling, user and group management, process control, and software installation, covering more than 95% of everyday tasks.
Operating System Overview
Linux is an operating system that runs directly on bare hardware and manages computer resources; all other software depends on it.
Filesystem Layout
/var– variable files such as logs, spools, lock files, temporary files and page‑cached files. /home – each user’s personal files, configuration, documents, caches, etc. /proc – virtual files that expose kernel and process information; they occupy no disk space. /bin – essential binaries required for system boot, usable by all users. /etc – system configuration files (firewall rules, startup scripts, etc.). /root – home directory of the super‑user. /dev – device files that abstract hardware as files, enabling read/write operations.
Common Command Operations
Show current directory: pwd Change directory: cd [directory] – e.g., cd ~ (home), cd .. (parent), cd - (previous), cd / (root).
List files: ls, ls -l (long format), ls -a (include hidden), ls -la (both).
Create directories: mkdir folder, recursive mkdir -p a/b/c.
Remove empty directories: rmdir folder, recursive rmdir -p folder.
Delete files or directories: rm -rf path (forceful), rm -ri path (interactive).
Copy files/directories: cp source dest, recursive cp -r src dst, interactive cp -ri src dst.
Move/rename: mv old new (rename) or mv src dst (move).
Create empty file: touch filename.
Edit or view with vi: vi filename (opens existing file or creates a new one).
Display file content: cat filename, create and write cat > filename.
Show file head: head -n N filename.
Show file tail: tail -f filename (follow), tail -n N filename (last N lines).
Permission Management
Files have read ( r), write ( w) and execute ( x) bits for owner, group and others. Example listing:
drwxr-x-x. 2 root root 4096 Sep 23 2011 bin d– directory. rwx – owner has read, write, execute. r-x – group has read and execute. r-x – others have read and execute.
Change permissions with chmod using two modes:
Symbolic mode: specify u, g, o with + or -. Example: chmod u+rwx,g+rw,o+rw f01.
Numeric mode: three octal digits represent rwx bits. Example: chmod 753 f01 gives rwx to owner, r‑x to group, -wx to others; chmod 777 f01 gives full access to everyone.
User and Group Management
Each user has a unique UID; each group has a unique GID. IDs below 500 are typically reserved for system accounts, so new users should use IDs > 500.
Root is the super‑user (UID 0) and belongs to the root group.
Only root can add or delete users.
When a user is added without specifying a group, a private group with the same name is created.
User Operation Commands
Switch user: su username (temporary, retains current environment) or su - username (full login).
Current user: whoami.
Groups of current user: groups.
Show UID/GID: id.
Add user: useradd username or with UID useradd -u 1001 username.
Set password: passwd username.
Delete user: userdel username or remove home with userdel -r username.
Modify user: usermod [options] username (e.g., usermod -l newname oldname, usermod -g newgroup username).
Add group: groupadd groupname or with GID groupadd -g GID groupname.
Process Management
List processes: ps -ef | grep keyword. Output columns include user, PID, PPID, CPU usage, and command path.
Terminate process: kill -9 PID.
Other Common Commands
clear– clear the terminal. man – view command manual. mnt – mount file systems.
SSH service control: service sshd start, service sshd restart, service sshd stop.
Run a Java JAR in background: nohup java -jar jar-0.0.1-SNAPSHOT.jar & (nohup prevents termination when the terminal closes).
Software Installation Methods
Three common methods on Linux:
Tar installation: extract source packages with tar -zxvf file.tar.gz, tar -jxvf file.tar.bz2 or tar -xvf file.tar and follow the software’s install steps.
RPM installation: Red Hat package manager; install with rpm -ivh package.rpm, query with rpm -qa | grep name, remove with rpm -e package.
YUM installation: front‑end to RPM that resolves dependencies automatically from online repositories.
Linux Tech Enthusiast
Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
