Linux Introduction — File System & Terminal Basics
772 words
4 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Linux Introduction — File System & Terminal Basics ## 🎯 Learning Objectives - Understand Linux history and the philosophy of Unix/Linux - Navigate the Filesystem Hierarchy Standard (FHS) - Open and use the terminal effectively - Understand command syntax and structure - Use `man` pages for help ## 1. What is Linux?

Linux Introduction — File System & Terminal Basics
🎯 Learning Objectives
- Understand Linux history and the philosophy of Unix/Linux
- Navigate the Filesystem Hierarchy Standard (FHS)
- Open and use the terminal effectively
- Understand command syntax and structure
- Use
manpages for help
1. What is Linux?
Linux is a Unix-like operating system created by Linus Torvalds in 1991. It's:
- Open source: Anyone can view, modify, and distribute the code
- Multi-user: Multiple users can use the same system simultaneously
- Multi-tasking: Runs many processes at once
- Stable and secure: Powers most servers, supercomputers, and Android devices
2. The Linux Filesystem Hierarchy
(Diagram)
| Directory | Purpose | Example Contents |
|---|---|---|
/ | Root — top of the filesystem | Everything starts here |
/bin | Essential user commands | ls, cp, mv, cat, echo |
/sbin | System administration | fdisk, mkfs, mount |
/etc | System configuration | /etc/passwd, /etc/ssh/sshd_config |
/home | User home directories | /home/alice, /home/bob |
/var | Variable data | Logs in /var/log, databases, mail |
/tmp | Temporary files | Cleared on reboot |
/usr | User programs | /usr/bin, /usr/lib, /usr/share |
/opt | Optional software | Installed manually |
/dev | Device files | /dev/sda (hard disk) |
/proc | Process information | Virtual filesystem (processes, kernel) |
3. The Terminal
The terminal is a text-based interface to the system. You type commands, the shell interprets them, and the OS executes them.
bash# Command structure: command [options] [arguments] # Examples: ls -la /home # List files with options and path cp -r source/ dest/ # Copy recursively grep -i "error" log.txt # Case-insensitive search
Common terminal shortcuts:
| Key | Action |
|---|---|
Ctrl+C | Kill current process |
Ctrl+D | Exit shell / EOF |
Ctrl+Z | Suspend current process |
Tab | Auto-complete |
↑/↓ | Command history |
Ctrl+L | Clear screen |
Ctrl+A | Go to beginning of line |
Ctrl+E | Go to end of line |
Ctrl+R | Reverse search command history |
4. Getting Help — man Pages
bash# Manual page for a command man ls man cp man grep # Search man pages for keyword man -k "copy files" apropos "search text" # Short description whatis ls whatis cp
Man page sections:
| Section | Content |
|---|---|
| 1 | User commands (ls, cp, grep) |
| 2 | System calls (open, read, write) |
| 3 | Library functions (printf, malloc) |
| 4 | Device drivers and special files |
| 5 | File formats (/etc/passwd) |
| 8 | System administration commands |
5. The Shell
The shell is a command interpreter. Common shells:
- bash: Bourne Again SHell (default on most Linux distributions)
- zsh: Z Shell (enhanced, default on macOS)
- sh: Bourne Shell (original)
You can check your shell:
echo $SHELL
6. First Commands
bash# Who am I? whoami # Print current username # Where am I? pwd # Print working directory # What's here? ls # List files ls -l # Long format (permissions, size, date) ls -a # Show hidden files (starting with .) ls -la # Combined: long + all # Navigate cd /tmp # Change to /tmp directory cd ~ # Change to home directory cd .. # Go up one directory cd - # Go to previous directory # Print text echo "Hello, World!" # Print text echo $HOME # Print variable value echo * # Print all files in directory
7. Practice Questions
Q1: What does/represent in Linux?Answer: The root directory — the top of the filesystem hierarchy. Everything (all files, directories, devices) is under/. Not to be confused with/root(the home directory for the root user). Q2: What's the difference between/binand/sbin?Answer:/bincontains essential user commands (ls, cp, cat) that regular users can run./sbincontains system administration commands (fdisk, mkfs, mount) typically used by the root user. Q3: How do you get help on thegrepcommand?Answer:man grep(full manual),grep --help(short summary),whatis grep(one-line description),apropos search(search for commands related to "search"). Q4: What doescd ..do?Answer: Moves up one directory level. If you're in/home/alice/Documents,cd ..takes you to/home/alice. Q5: What is the purpose of/tmp?Answer: Temporary files directory. Any user or process can write here. Files may be cleared on system reboot. Used for temporary data that doesn't need to persist. Q6: What doesls -lashow?Answer: Lists all files (including hidden ones starting with.) in long format showing: permissions, owner, group, size, modification date, and filename. Q7: How do you switch to a different user on the terminal?Answer:su username(switch user) orsudo -u username command(run command as user).sudorequires the current user to have sudo privileges. Q8: What does thepwdcommand do?Answer: Prints the current working directory (full path from root). Useful when you're lost in the filesystem. No arguments needed.
📐 Key Concepts
| Concept | Command | Purpose |
|---|---|---|
| Manual | man cmd | Read command documentation |
| Print working dir | pwd | Show current location |
| List files | ls | Show directory contents |
| Change directory | cd path | Navigate filesystem |
| Print text | echo text | Display output |
| Who am I | whoami | Show current user |