Linux Essentials & Open Source
1) What is Linux (in plain words)?
- Linux is an operating system like Windows/macOS. More precisely, Linux is the kernel—the core program that talks to hardware.
- A Linux distribution (distro) = Linux kernel + basic tools + desktop/server apps + a package manager (e.g., Ubuntu, Fedora, Debian, Arch, Kali).
Where you already meet Linux
Android phones, smart TVs/routers, cloud servers (AWS/GCP/Azure), supercomputers, Raspberry Pi, and many websites you visit daily.
2) Why Linux?
- Free & open source: no license fees; you can inspect/modify the code.
- Stable & secure: strong permissions model; fewer forced restarts.
- Fast & lightweight: runs well even on older hardware.
- Customizable: choose desktop environments, shells, and tools that suit you.
- Great for developers: built-in programming tools, servers, Docker, Git, Python, C/C++.
3) The big picture (how Linux is organized)
- Kernel: manages CPU, memory, disks, devices.
- Shell: the command interpreter (e.g., bash, zsh) you type into.
- Utilities: small programs that do one thing well (ls, cp, grep, …).
- Filesystem: single tree starting at / (root). Everything is a file.
- Package manager: install/update software (APT on Ubuntu/Debian, DNF on Fedora, pacman on Arch).
4) Try Linux quickly
Option A: WSL on Windows (fastest)
1. Open PowerShell as Administrator.
2. Run:
3. wsl --install -d Ubuntu
4. Reboot if asked, then set a Unix username/password.
5. Open Ubuntu app → you’re in a Linux terminal inside Windows.
Option B: VirtualBox (Windows/macOS/Linux)
1. Install VirtualBox.
2. Download a distro ISO (Ubuntu LTS is beginner-friendly).
3. Create a VM → attach ISO → start → follow installer.
4. Use Linux in a window safely (no changes to your main OS).
Tip: If your machine is older/low-RAM, choose Xubuntu or Lubuntu.
5) Filesystem basics (must-know)
- Case-sensitive: File.txt ≠ file.txt.
- Absolute path: starts with / (e.g., /home/rohit/docs).
- Relative path: from current folder (e.g., docs/report.txt).
- Home: ~ (e.g., /home/yourname).
- Hidden files: start with . (e.g., .bashrc).
- Common directories:
- /home user folders
- /etc config files
- /bin, /usr/bin programs
- /var variable data/logs
- /tmp temporary files
- /dev, /proc system/virtual files
6) Terminal 101
Command format:
command [options] [arguments]
Examples: ls -la, cp -r pics backup/
7) Everyday commands (with mini examples)
Goal |
Command |
Try this |
Where am I? |
pwd |
pwd |
List files |
ls, ls -la |
ls -la (shows hidden & details) |
Change folder |
cd |
cd ~/Downloads |
Make folder |
mkdir |
mkdir projects |
Create empty file |
touch |
touch notes.txt |
Copy |
cp, cp -r |
cp notes.txt backup.txt |
Move/Rename |
mv |
mv backup.txt notes_old.txt |
Remove |
rm, rm -r |
rm notes_old.txt (careful!) |
View file |
cat, less |
less /etc/hosts (q to quit) |
Show first/last lines |
head, tail |
head -n 20 big.txt |
Search text |
grep |
grep "error" app.log |
Find files |
find |
find . -name "*.py" |
Safety: avoid rm -rf / or running sudo blindly. Use rm -ri to confirm.
8) Pipelines & redirection (superpower)
- Redirect output to file: > overwrite, >> append
· ls -l > list.txt
- Pipe output of one command into another:
· dmesg | grep usb
· cat big.txt | wc -l
9) Permissions (r, w, x)
- Each file has permissions for user (u), group (g), others (o).
- ls -l shows like: -rwxr-xr-- user group file
- r=4, w=2, x=1 → add them:
- 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--
- Change permissions:
· chmod 754 script.sh # u=rwx,g=rx,o=r
· chmod u+x script.sh # add execute for user
- Change owner/group (needs sudo):
· sudo chown alice:devs report.txt
10) Processes & system monitoring
- See running processes: ps aux
- Interactive monitor: top (or htop if installed)
- Kill by PID: kill 1234 (polite), kill -9 1234 (force)
- Memory/Disk:
· free -h
· df -h
· du -sh *
11) Networking basics
- Test connectivity: ping example.com (Ctrl+C to stop)
- Download: wget URL or curl -O URL
- Show IP info: ip a
- Remote login & copy:
· ssh user@server
· scp file.txt user@server:/home/user/
12) Package managers (install software)
- Ubuntu/Debian:
· sudo apt update
· sudo apt install git
· sudo apt upgrade
- Fedora/RHEL: sudo dnf install <pkg>
- Arch: sudo pacman -S <pkg>
13) Shell scripting (your first automation)
hello.sh
#!/usr/bin/env bash
echo "Hello, $USER! Today is $(date +%A)."
Make executable & run:
chmod +x hello.sh
./hello.sh
Mini script with input, loop, and conditions
#!/usr/bin/env bash
read -p "Folder to back up: " SRC
DEST="$HOME/backups/$(date +%Y-%m-%d)"
mkdir -p "$DEST"
if [ -d "$SRC" ]; then
cp -r "$SRC" "$DEST"
echo "Backup done at $DEST"
else
echo "Folder not found!"
fi
Concepts used: shebang, variables (SRC), input (read), if condition, -d (directory check), date, quoting paths with spaces.
14) Users, groups, and sudo
- Add user (admin action): sudo adduser ankit
- Add to group: sudo usermod -aG sudo ankit
- Change password: passwd
- sudo runs a command with admin privileges: sudo apt install tree
15) Environment basics
- Show environment vars: env, echo $PATH
- Add aliases/functions in ~/.bashrc or ~/.zshrc (then source ~/.bashrc)
· echo 'alias ll="ls -alF"' >> ~/.bashrc
16) Open Source: values & licenses
- Open source means the source code is available to use, study, modify, and share.
- Core ideas (the “freedoms”):
1. Use the software for any purpose.
2. Study how it works (access to source).
3. Modify it.
4. Share copies (original or modified).
Popular licenses (simple view):
- MIT: very permissive; use anywhere, just keep the license notice.
- Apache-2.0: permissive + explicit patent protection.
- GPL-3.0: “copyleft”; if you distribute modified versions, you must keep it open under GPL as well.
Choosing a license (quick rule):
- Want maximum freedom for users (including closed-source use)? MIT/Apache.
- Want improvements to stay open? GPL.
Contributing to open source:
- Find a project on GitHub/GitLab → read CONTRIBUTING.md → fix a bug or docs → make a pull request.
17) Good habits & safety
- Tab-complete paths; use quotes for paths with spaces: "My Files"
- Read man pages: man ls (q to quit)
- Prefer rm -ri (interactive) for safety; keep regular backups.
- Use version control: git init, git add, git commit.
18) 30-minute practice lab (do this now)
1. Create a playground:
2. mkdir -p ~/lab/linux101 && cd ~/lab/linux101
3. Make files & folders:
4. mkdir src docs
5. echo "Hello Linux" > docs/readme.txt
6. cp docs/readme.txt src/hello.txt
7. ls -la
8. Search & count:
9. grep -r "Hello" .
10. wc -l src/hello.txt
11. Permissions:
12. echo -e '#!/usr/bin/env bash\necho Linux!' > run.sh
13. chmod 755 run.sh
14. ./run.sh
15. Package install (Ubuntu example):
16. sudo apt update && sudo apt install tree
17. tree ~/lab/linux101
19) Quick cheat sheet
pwd # print current directory
ls -la # list (all, long)
cd /path # change directory
mkdir newdir # make directory
cp src dst # copy (add -r for folders)
mv old new # move/rename
rm file # remove (use -r for folders, -i to confirm)
cat/less file # show file
grep "text" file # search text
find . -name "*.py" # find files by pattern
chmod 755 file # set permissions
top # live process view
df -h # disk usage (drives)
du -sh * # disk usage (folders)
ping example.com # test network
wget/curl URL # download
ssh user@host # remote login
sudo apt install x # install (Ubuntu/Debian)
Want this as a printable PDF or a slide deck?
Say the word and I’ll turn these notes into a nicely formatted PDF or PPT for your class.