diff options
| author | Ahmed <git@gumx.cc> | 2026-06-20 00:08:09 +0300 |
|---|---|---|
| committer | Ahmed <git@gumx.cc> | 2026-06-20 00:08:09 +0300 |
| commit | fb16e4b6c9c597c01c1eb1649603b8a761d0cc31 (patch) | |
| tree | 61a1c89eec0393bc1217679f2b60fcf34c5b018b /linux-command-line | |
| parent | 9a2ac6cfad9855344f9bcc0b45780b4bcb1ff42d (diff) | |
fix: bunch of vibed edits to fix vibed edits
Diffstat (limited to 'linux-command-line')
| -rw-r--r-- | linux-command-line/shell-basics/index.md | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/linux-command-line/shell-basics/index.md b/linux-command-line/shell-basics/index.md index c0cf75b..f84c802 100644 --- a/linux-command-line/shell-basics/index.md +++ b/linux-command-line/shell-basics/index.md @@ -4,7 +4,7 @@ title: Shell Basics # Shell Basics -The shell is your primary interface to a Linux system. Everything — file management, process control, system administration — flows through it. Before graphical tools, before IDEs, there was the shell. Mastering it is non-negotiable. +The shell is your primary interface to a Linux system. Everything (file management, process control, system administration) flows through it. Before graphical tools, before IDEs, there was the shell. Mastering it is non-negotiable. **Prerequisites:** None **Estimated time:** 4-6 hours of practice @@ -16,10 +16,10 @@ The shell is your primary interface to a Linux system. Everything — file manag A shell is a program that reads commands from your input and executes them. It's both a **command interpreter** (runs programs) and a **programming language** (scripts). Common shells: -- **bash** — Bourne Again Shell, the default on most Linux systems -- **zsh** — Extended bash with better completion and prompting -- **sh** — POSIX shell, the lowest common denominator -- **fish** — Friendly interactive shell, not POSIX-compatible +- **bash**: Bourne Again Shell, the default on most Linux systems +- **zsh**: Extended bash with better completion and prompting +- **sh**: POSIX shell, the lowest common denominator +- **fish**: Friendly interactive shell, not POSIX-compatible When you open a terminal, you're running a **terminal emulator** (alacritty, kitty, xterm) which hosts a **shell process**. The terminal draws pixels; the shell interprets commands. @@ -40,12 +40,12 @@ cat /etc/shells ## Navigating the Filesystem -Linux has a single filesystem tree rooted at `/`. Everything is a file — devices, processes, sockets. +Linux has a single filesystem tree rooted at `/`. Everything is a file: devices, processes, sockets. ### Essential Navigation Commands ```bash -pwd # Print working directory — where you are +pwd # Print working directory: where you are ls # List files in current directory ls -la # Long format, show hidden files (dotfiles) ls -lh # Human-readable sizes (K, M, G) @@ -107,7 +107,7 @@ mv file.txt ~/Documents/ # Move to another directory # Delete rm file.txt # Remove file (no trash, no undo) rm -r mydir/ # Remove directory recursively -rm -ri mydir/ # Interactive — asks before each deletion +rm -ri mydir/ # Interactive: asks before each deletion rmdir emptydir/ # Remove only if empty ``` @@ -125,11 +125,11 @@ wc -l file.txt # Count lines ``` `less` is your friend. Use it for anything longer than a screenful. Key bindings inside `less`: -- `Space` / `b` — page down / up -- `/pattern` — search forward -- `n` / `N` — next / previous search match -- `g` / `G` — go to top / bottom -- `q` — quit +- `Space` / `b`: page down / up +- `/pattern`: search forward +- `n` / `N`: next / previous search match +- `g` / `G`: go to top / bottom +- `q`: quit --- @@ -147,7 +147,7 @@ ls -l file.txt # └───────────── file type: - = regular, d = directory, l = symlink ``` -### chmod — Change Permissions +### chmod: Change Permissions ```bash # Symbolic notation @@ -156,9 +156,9 @@ chmod go-w file.txt # Remove write for group and others chmod a+r file.txt # Add read for all # Octal notation (most common) -chmod 755 script.sh # rwxr-xr-x — owner full, others read+execute -chmod 644 file.txt # rw-r--r-- — owner read+write, others read -chmod 600 secret.key # rw------- — owner only +chmod 755 script.sh # rwxr-xr-x: owner full, others read+execute +chmod 644 file.txt # rw-r--r--: owner read+write, others read +chmod 600 secret.key # rw-------: owner only ``` **Octal cheat sheet:** r=4, w=2, x=1. Add them up per group. @@ -168,7 +168,7 @@ chmod 600 secret.key # rw------- — owner only - `4` = r-- (4) - `0` = --- (0) -### chown — Change Ownership +### chown: Change Ownership ```bash chown ahmed file.txt # Change owner @@ -189,9 +189,9 @@ This is where the shell gets powerful. The Unix philosophy: small programs that ### Redirection Every process has three standard streams: -- **stdin** (0) — input -- **stdout** (1) — normal output -- **stderr** (2) — error output +- **stdin** (0): input +- **stdout** (1): normal output +- **stderr** (2): error output ```bash # Redirect stdout to a file @@ -231,18 +231,18 @@ ps aux | grep nginx | grep -v grep cat /etc/passwd | cut -d: -f1 | sort | head -5 ``` -> **Useless use of cat:** `cat file | grep pattern` can be written as `grep pattern file`. But in pipelines with many stages, starting with `cat` can be clearer. Don't stress about it early on — clarity matters more than micro-optimization. +> **Useless use of cat:** `cat file | grep pattern` can be written as `grep pattern file`. But in pipelines with many stages, starting with `cat` can be clearer. Don't stress about it early on: clarity matters more than micro-optimization. ### Command Substitution Use the output of one command inside another: ```bash -# Using $() — preferred +# Using $(): preferred echo "Today is $(date +%Y-%m-%d)" files=$(ls *.txt) -# Using backticks — older style, harder to nest +# Using backticks: older style, harder to nest echo "Today is `date +%Y-%m-%d`" ``` @@ -282,10 +282,10 @@ apropos network # Search man pages by keyword ``` **Reading man pages:** The synopsis section uses conventions: -- `[optional]` — square brackets mean optional -- `REQUIRED` — caps or no brackets means required -- `...` — can be repeated -- `a | b` — choose one +- `[optional]`: square brackets mean optional +- `REQUIRED`: caps or no brackets means required +- `...`: can be repeated +- `a | b`: choose one --- @@ -309,7 +309,7 @@ apropos network # Search man pages by keyword ### Mini-Project -**Build a quick reference card:** Create a file `~/cheatsheet.md` that contains the 20 commands you found most useful from this section, organized by category, with a one-line description and example for each. This is your cheatsheet — you'll extend it throughout the course. +**Build a quick reference card:** Create a file `~/cheatsheet.md` that contains the 20 commands you found most useful from this section, organized by category, with a one-line description and example for each. This is your cheatsheet: you'll extend it throughout the course. --- @@ -317,11 +317,11 @@ apropos network # Search man pages by keyword - The shell is a command interpreter and a programming environment - Everything in Linux is a file, organized in a single tree from `/` -- Permissions are the foundation of Linux security — understand `rwx` and octal +- Permissions are the foundation of Linux security: understand `rwx` and octal - Pipes and redirection are the core of composing commands -- `man` and `--help` are always available — read them first, search the web second +- `man` and `--help` are always available: read them first, search the web second - Practice in a real terminal. Reading about commands is not the same as using them. --- -**Next:** [File Management](../file-management/) — find, locate, tar, rsync, and more +**Next:** [File Management](../file-management/): find, locate, tar, rsync, and more |
