and some fun details
NTUEE Lightdance 2026
吳亞倫 (Aaron Wu)
slide
$ whoamilink to this slide:
https://slides.com/aaw/ntueelightdance-linux/
Unix (1969): Developed by Ken Thompson and Dennis Ritchie at Bell Labs.
Unix Philosophy: "Do one thing and do it well." Small programs can be combined to perform complex tasks.
GNU (1983): Richard Stallman launched the GNU Project to create a free Unix-like operating system.
GNU: abbreviation of "GNU's Not Unix!"
GNU Tools: Developed essential utilities such as GCC, Bash, and Coreutils.
Linux (1991): Linus Torvalds created the Linux kernel, which was later combined with GNU tools to form GNU/Linux systems.
Linus Torvalds,
the creater of linux and git.
Kernel (Linux)
The core of the operating system.
Manages hardware, memory, processes,
and filesystems.
GNU (GNU's Not Unix)
A collection of free software and system utilities.
Provides Bash, Coreutils (ls, cp, mv), GCC, glibc, etc.
Shell (Bash, Zsh, Fish)
Interprets commands and launches programs.
Bash is part of GNU.
Terminal (GNOME Terminal, iTerm2, Windows Terminal)
Provides the interface for interacting with a shell.
Handles keyboard input and text display.
A text-based interface for interacting with a computer by typing commands.
CLI vs. GUI (Graphical User Interface)
CLI: Text commands, automation, remote access.
GUI: Windows, icons, menus, and visual interaction.
ls -la ~/my-projectCommand
Options
Argument
man: manual for linux commands
manman manA Linux distribution (distro) is an operating system built around the Linux kernel.
Each distribution provides its own software packages, package manager, and default configurations.
Popular distributions:
Ubuntu / Debian: apt
Fedora: dnf
Arch Linux: pacman
Most common Linux commands work across distributions.
wsl --installPrint text to standard output (stdout)
echoLinux organizes files and directories in a hierarchical tree structure.
The tree starts at the root directory (/).
Files and directories are accessed through paths, separated by /.
Special path symbols:
/ — Root directory
. — Current directory
.. — Parent directory
~ — Home directory
Everything is a file — Five-Star General Douglas MacArthur never said that
Everything is a file — Unix Design Philosophy by Ken Thompson
Show directory structure in tree format
treelist the items in your directory
Files and directories starting with . are considered hidden.
Hidden files are not displayed by ls by default.
ls -a: Show all files, including hidden ones.
ls -la: Show hidden files with detailed information.
Often used for configuration files (dotfiles).
Examples: .bashrc, .zshrc, .ssh/, .git/
Hidden files are not protected or encrypted.
Change current directory / Show Current Directory
cd / pwdCreate a directory
mkdirRead a file and output it's content
catcp <source> <destination> — Copy files or directories.
Use -r to copy directories recursively.
mv <source> <destination> — Move or rename files and directories.
rm <file> — Remove files.
Use -r to remove directories recursively.
Use -i to ask for confirmation before removal.
Warning: rm permanently deletes files. There is no trash bin!
cp / mv / rmclear the output of terminal
clearPipes & I/O Redirection
cmd < input.txt
Use input.txt as the standard input (stdin) of cmd.
cmd > output.txt
Redirect standard output (stdout) to output.txt.
Create or overwrite the file.
cmd >> output.txt
Append standard output (stdout) to output.txt.
cmd1 | cmd2
Pass the stdout of cmd1 to the stdin of cmd2.
cmd1 | xargs cmd2
Convert input items into command-line arguments for cmd2.
< | > >> a very easy to use text editor in terminal
a very easy to use text editor in terminal
hjkl for moving cursori to start writing contentesc:w:q:q!vimtutora editor for people that are not smart enough to use vim
Important directories:
/home — User files
/etc — System configurations
/usr — Programs and libraries
/var — Logs and variable data
/tmp — Temporary files
Other directories: /boot, /opt, /mnt, /dev, /proc, /sys
All files are organized under the root directory /.
Linux uses a single directory hierarchy.
Files from different storage devices can appear under the same tree.
Disk: A physical or virtual storage device.
Partition: A region of a disk.
Block Device: Storage accessed through fixed-size blocks.
Examples:
/dev/sda — Disk
/dev/sda1 — Partition
/dev/nvme0n1p1 — NVMe partition
NOTE: /dev/* are a files but also interface to devices!
A filesystem organizes files and directories on storage.
Common types:
ext4 — Common Linux filesystem
XFS — Common on Linux servers
FAT32 / exFAT — Common on removable drives
NTFS — Common on Windows
Different partitions may use different filesystem types.
Mounting: Attach a filesystem to a directory.
Mount Point: The directory where a filesystem becomes accessible.
Example: /dev/sdb1 mounted at /mnt/data.
A single directory tree can contain multiple filesystems.
An inode stores file metadata and references to file data.
A hard link is another filename referring to the same inode.
Removing one hard link does not invalidate the others.
A symbolic link (symlink) stores a path to another file or directory.
Created using ln -s target link.
If the target path disappears, the link becomes broken.
Very often used!
Some filesystems expose system information without storing ordinary files on disk.
These files are generated or managed by the kernel.
/proc — Process and kernel information.
/sys — Kernel objects and device attributes.
/dev exposes device files and special interfaces.
Many devices support file-like operations such as read() and write().
Examples:
/dev/null — Discards written data.
/dev/zero — Produces zero bytes.
/dev/tty — Controlling terminal.
User: Each user has a unique User ID (UID).
Group: A collection of users, identified by a Group ID (GID).
A user can belong to multiple groups.
Root: The superuser (UID 0) with administrative privileges.
Useful Commands
whoami — Show the current username.
id — Show UID, GID, and group memberships.
Every file has an owner and a group.
Permissions are divided into:
User (u): File owner
Group (g): Members of the file's group
Others (o): Everyone else
Three basic permission bits:
r — Read (4)
w — Write (2)
x — Execute (1)
Use ls -l to inspect file permissions.
cd 進入某個目錄,需要該目錄的 x 權限
chmod — Change file permission bits.
Symbolic Mode:
chmod u+x script.sh — Add execute permission for the owner.
chmod g-w file.txt — Remove group write permission.
Numeric Mode:
chmod 755 script.sh → rwxr-xr-x
chmod 644 file.txt → rw-r--r--
chmod 600 private.key → rw-------
Permission Values: r = 4, w = 2, x = 1
chmodchown — Change file ownership.
Syntax: chown [owner][:group] file
Examples:
sudo chown alice file.txt — Change owner.
sudo chown alice:developers file.txt — Change owner and group.
sudo chown -R alice:developers project/ — Change recursively.
Changing file ownership usually requires root privileges.
chownsudo — Execute a command as another user.
By default, commands run as root.
Access is controlled by the system's sudo policy.
Common examples:
sudo apt install tree
sudo chown root:root file.txt
sudo -l — List permitted commands.
Use sudo carefully!
sudopasswd — Change a user's password.
password will not display
passwdAn executable is a file that can be run as a program.
Binary Executables: Machine code compiled from source code.
Linux commonly uses the ELF format.
Scripts: Text files executed by an interpreter.
Examples: Bash scripts, Python scripts
Execution also depends on file permissions.
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
cout << "I am a C++ program" << endl;
for (int i = 0; i < argc; ++i) {
cout << "argv[" << i << "] is " << argv[i] << endl;
}
return 0;
}g++ main.cpp -o mainRemember what we've said...
ls -la ~/my-projectCommand
Options
Argument
Remember what we've said...
./main -a milkfrogCommand
Options
Argument
argv[0]
argv[2]
argv[1]
relative path to the Executable!!!
Why?
Most common external commands are executable files.
Common locations:
/usr/bin — System commands
/usr/local/bin — Locally installed programs
~/.local/bin — User-installed programs
type / command -v — Find the location of a command.
So, how does the shell know where to find ls?
Shell variables store values.
Assign a variable using name=value.
Use $name or ${name} to expand its value.
Double quotes allow expansion; single quotes prevent it.
There are some "special" variables...
Environment Variables: Variables inherited by child processes.
PATH: A list of directories separated by :.
The shell searches these directories for external commands.
Use export to set environment variables.
Can we figure out how to install programs?
Method 1:
/usr/bin or other dirs in PATHUse symbolic links!
Method 2:
sudo ln -s /usr/bin/myawesomecmd /home/ubuntu/cproject/mainShells can automatically execute configuration files during startup.
~/.bashrc — Loaded by interactive, non-login Bash shells.
Aliases, prompts, shell customization.
~/.profile — Loaded by login shells (if selected).
Environment variables, PATH configuration.
source <file> — Execute a file in the current shell.
Example:
export PATH="$HOME/.bin:$PATH"
alias ll="ls -la"Can we figure out how to install programs?
Method 3:
Pros: don't need sudo, no extra cmds every session
Instead of manually downloading every program we need and install them, we have
A package contains software and its metadata.
Package managers automatically handle:
Downloading and installing software
Resolving dependencies
Updating and removing packages
Different Linux distributions use different package managers:
Ubuntu / Debian: apt
Fedora: dnf
Arch Linux: pacman
Example (Ubuntu):
sudo apt update # Update package lists
sudo apt install tree # Install tree
sudo apt install sl
sudo apt upgrade # Upgrade packagesShell Builtins: Commands implemented inside the shell.
Examples: cd, export, alias
External Commands: Separate executable programs.
Examples: ls, grep, python3
Use type to identify how a command is implemented.
Why is cd a builtin?
IP Address: Identifies a network interface for communication.
Example: 192.168.1.100
Port: Identifies a network service or endpoint.
SSH: 22, HTTP: 80, HTTPS: 443
DNS: Translates domain names into IP addresses.
Example: example.com → IP address
localhost (127.0.0.1): Refers to the local machine.
ip a / ip r: Inspect Network InterfacesSSH (Secure Shell): Securely access and control remote machines.
Provides encrypted communication between client and server.
Basic syntax: ssh [user@]hostname
Useful options:
-p — Specify the SSH port.
-i — Specify a private key.
sshPrivate Key: Kept secret on your local machine.
Public Key: Stored in ~/.ssh/authorized_keys on the remote server.
The server verifies that you possess the corresponding private key.
Setup:
# 1. Generate a key pair
ssh-keygen -t ed25519
# 2. Copy the public key to the remote server
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server
# 3. Connect using the key
ssh user@server
Never share your private key!
Forward network connections through an encrypted SSH tunnel.
Local Port Forwarding (-L):
Expose a remote service through a local port.
Common use cases:
Jupyter Notebook
Web dashboards
Development servers
ssh -L 8080:localhost:9090 user@serverSCP (Secure Copy): Transfer files between computers over SSH.
Works with the same authentication and SSH configuration.
Basic syntax: scp <source> <destination>
Use -r to copy directories recursively.
scp