Quiz 2

Linux Introduction — File System & Terminal Basics

772 words
4 min read
Python Week 1: the first filter for runtime behavior
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 man pages 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)
DirectoryPurposeExample Contents
/Root — top of the filesystemEverything starts here
/binEssential user commandsls, cp, mv, cat, echo
/sbinSystem administrationfdisk, mkfs, mount
/etcSystem configuration/etc/passwd, /etc/ssh/sshd_config
/homeUser home directories/home/alice, /home/bob
/varVariable dataLogs in /var/log, databases, mail
/tmpTemporary filesCleared on reboot
/usrUser programs/usr/bin, /usr/lib, /usr/share
/optOptional softwareInstalled manually
/devDevice files/dev/sda (hard disk)
/procProcess informationVirtual 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:
KeyAction
Ctrl+CKill current process
Ctrl+DExit shell / EOF
Ctrl+ZSuspend current process
TabAuto-complete
/Command history
Ctrl+LClear screen
Ctrl+AGo to beginning of line
Ctrl+EGo to end of line
Ctrl+RReverse 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:
SectionContent
1User commands (ls, cp, grep)
2System calls (open, read, write)
3Library functions (printf, malloc)
4Device drivers and special files
5File formats (/etc/passwd)
8System 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 /bin and /sbin?
Answer: /bin contains essential user commands (ls, cp, cat) that regular users can run. /sbin contains system administration commands (fdisk, mkfs, mount) typically used by the root user. Q3: How do you get help on the grep command?
Answer: man grep (full manual), grep --help (short summary), whatis grep (one-line description), apropos search (search for commands related to "search"). Q4: What does cd .. 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 does ls -la show?
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) or sudo -u username command (run command as user). sudo requires the current user to have sudo privileges. Q8: What does the pwd command do?
Answer: Prints the current working directory (full path from root). Useful when you're lost in the filesystem. No arguments needed.

📐 Key Concepts

ConceptCommandPurpose
Manualman cmdRead command documentation
Print working dirpwdShow current location
List fileslsShow directory contents
Change directorycd pathNavigate filesystem
Print textecho textDisplay output
Who am IwhoamiShow current user

🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.