Knowledge / Information Technology / Linux command line essentials

Linux command line essentials

Information Technology (B.E./B.Tech) · Infrastructure and operations · free study notes for exams, placements and interviews

In short

The Linux command line is a text interface in which a shell (usually bash) reads commands, asks the kernel to run them as processes, and prints the result on a terminal. It matters because almost every server, cloud instance, build agent, database host and network device an Indian IT engineer touches is Linux with no graphical desktop, so file handling, permissions, logs, processes and services are all driven from the shell. University syllabi examine it under Operating Systems / Linux lab (shell commands, file permissions, process management, shell programming) and GATE-CS examines the underlying OS concepts (processes, signals, scheduling, file systems). Placement and interview rounds at TCS, Infosys, Wipro, HCLTech, Cognizant, Accenture, Capgemini, LTIMindtree and every support/DevOps/SRE role test it directly - "find the biggest file", "why is the CPU at 100%", "change permission to 755" - and certifications RHCSA, LFCS and CompTIA Linux+ are built on it.

Explained

Shell, kernel and how a command is executed

Filesystem hierarchy, navigation and file operations

Users, groups, ownership and permissions

Redirection, pipes and text processing

Processes, jobs, signals and resource monitoring

Packages, archives, networking and remote access

Shell scripting essentials

Key points

Formulas and examples

Permission mode (octal) = 4·r + 2·w + 1·x, computed separately for user, group and others
Effective mode on creation = base_mode AND (NOT umask); base_mode = 666 for files, 777 for directories
Full mode = special·1000 + user·100 + group·10 + others, where special = 4(setuid) + 2(setgid) + 1(sticky)
Exit status on signal termination = 128 + signal_number
CPU saturation ≈ load_average(1 min) / number_of_CPU_cores (≈1.0 means fully busy)
Transfer time (s) = size (bits) / throughput (bits per second); 1 byte = 8 bits, 1 GiB = 1024 MiB

Example 1 - umask to effective permissions. A user has umask 027. What mode does a new file and a new directory get?

Example 2 - symbolic and numeric chmod on a shared project directory. Requirement: owner full access, group read/write/enter, others nothing, and every new file inside must belong to the group devs.

Example 3 - reading a load average. uptime on a 4-vCPU cloud VM reports load average: 3.60, 2.90, 1.80.

Example 4 - exit status arithmetic. A job is killed with kill -9 4821; the shell reports status 137.

Example 5 - log retention and transfer sizing. An application writes 2.5 GiB of logs a day. Compliance requires 180 days of retention; gzip achieves roughly 10:1 on text logs.

TaskCommandNote
Follow a live logtail -f /var/log/syslogjournalctl -f on systemd hosts
10 largest files under a path`du -ah /var \sort -rh \head -10`-h sizes, sort -rh human-numeric
Free space and inodesdf -h / df -iboth can fill independently
Who is on port 8080`ss -tulpn \grep 8080`lsof -i :8080 as alternative
Count errors todaygrep -c ERROR app.loggrep -i for case-insensitive
Replace text in all configssed -i 's/8080/9090/g' *.confkeep a backup: sed -i.bak
Find files changed in 1 dayfind /etc -mtime -1 -type f-mmin -60 for the last hour
Restart and verify a servicesystemctl restart nginx && systemctl status nginxenable for boot persistence
AspectHard linkSymbolic link
Points toSame inodeA path string
Across filesystemsNoYes
To a directoryNot allowedAllowed
If target deletedData survives (link count > 0)Link dangles
ls -l showsRegular file, link count ≥ 2l type with -> target

Where it is used

Interview questions

Common mistakes

Related topics

Operating systems: processes and scheduling · Cloud computing basics · Containers: Docker and Kubernetes · DevOps and CI/CD basics · Monitoring and site reliability engineering · Computer networks and TCP/IP

Open in the Knowledge reader →Find jobs →