Linux Study Notes
Comprehensive 60+ Page Guide
Covering Commands, Scripting, Process Management, and More
Prepared for 20-Marks View with Examples & Exercises
Introduction to Linux & Shells
Linux is an open-source operating system kernel. It forms the base for many distributions (Ubuntu,
Debian, Fedora, etc.).
The Shell is a command-line interpreter that allows users to interact with the system.
Common shells: bash, zsh, fish, ksh. Bash is the most widely used.
Importance: Stability, open-source, flexibility, and community support.
Basic Commands
`ls` – Lists directory contents. Options: -l (long listing), -a (hidden files).
`pwd` – Prints current working directory.
`cd` – Changes directory. Use `cd ..` to go up one level.
`mkdir` – Creates a directory. Example: mkdir projects.
`rm` – Removes files/directories. Use -r for recursive deletion.
`touch` – Creates empty files or updates timestamps.
Process Management
`ps` – Shows running processes. Example: ps aux.
`top` – Real-time process monitoring. Press q to quit.
`kill` – Terminates processes using PID. Example: kill -9 1234.
`nohup` – Runs processes immune to hangups. Useful for background jobs.
Disk Usage
`df` – Displays disk space usage. Example: df -h for human-readable.
`du` – Shows space used by files/directories. Example: du -sh *.
File Handling
`grep` – Searches inside files. Example: grep 'error' logfile.
`find` – Locates files. Example: find / -name file.txt.
`awk` – Text processing. Example: awk '{print $1}' file.
`sort` – Sorts lines. Example: sort names.txt.
`wc` – Counts lines/words/characters. Example: wc -l file.
`head` & `tail` – Shows file start/end. Example: head -n 10 file.
`chmod` – Changes permissions. Example: chmod 755 script.sh.
`ln` – Creates links. Hard vs symbolic links explained.
File Transfer & Server Access
`ssh` – Secure login to remote server. Example: ssh user@host.
`scp` – Secure file copy. Example: scp file.txt user@host:/path.
PuTTY – SSH client for Windows.
WinSCP – File transfer GUI for Windows.
Package Management
`apt-get` – Installs, updates, removes software. Example: apt-get install nano.
`wget` – Downloads files. Example: wget https://example.com/file.zip.
Cron Jobs & Automation
Cron is used for scheduled tasks.
`crontab -e` – Edit cron jobs.
Syntax: minute hour day month weekday command.
Example: `0 2 * * * backup.sh` runs daily at 2 AM.
`at` – Schedules one-time jobs.
Shell Scripting
Start scripts with `#!/bin/bash`.
Use variables: name=Linux, echo $name.
Conditionals: if [ $a -gt $b ]; then ... fi.
Loops: for, while, until.
Functions: function greet { echo Hello; }.
Case statements: menu-driven scripts.
Advanced: handling arguments ($1, $2), error handling.
WSL Setup for Windows
WSL allows running Linux on Windows.
Enable WSL: `wsl --install`.
Install Ubuntu/Debian from Microsoft Store.
Use `wsl -l -v` to list distributions.
Access Linux files from Windows Explorer.