Git & Command Line22 min readBeginner

Permissions, Find & Grep

rwx, chmod, find, grep — the tools you'll Google constantly until you know them.

Permissions

Every file has three permission groups (owner, group, world) × three permissions (read, write, execute). `ls -l` shows them as `rwxr-xr--`.

bash
-rw-r--r--  1 ada users  1.2K Jan 15 12:00 notes.txt
# 1st char: file type (- = file, d = dir, l = symlink)
# Next 3:   owner permissions   (rw- = read, write, no exec)
# Next 3:   group permissions   (r-- = read only)
# Next 3:   world permissions   (r-- = read only)
bash
chmod +x deploy.sh         # make executable
chmod 755 script.sh        # rwxr-xr-x (owner all, others read+exec)
chmod 644 secret.txt       # rw-r--r-- (owner read+write, others read)
chown ada:users notes.txt  # change owner and group
sudo chmod 600 ~/.ssh/id_rsa  # SSH keys must be 600 or SSH refuses to use them

Numeric mode

  • 4 = read
  • 2 = write
  • 1 = execute
  • Add them: 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--
  • Common: 755 (executable scripts), 644 (text files), 600 (private keys)

find — locate files by name, type, age, size

bash
find . -name "*.py"                  # all Python files in current tree
find . -name "test_*" -type f        # only files (not directories) starting with test_
find . -mtime -7                     # modified in the last 7 days
find . -size +100M                   # bigger than 100 MB
find . -name "*.log" -delete         # find AND delete (be careful)

grep — search file contents by regex

bash
grep "TODO" *.py                # search for TODO in all Python files
grep -r "TODO" .                 # recursive
grep -rn "TODO" .                # also show line numbers
grep -ri "todo" .                # case-insensitive
grep -v "DEBUG" app.log          # INVERT — lines NOT matching
grep -E "error|fatal" app.log    # extended regex (multiple patterns)
💡 Tip
Modern alternatives: `rg` (ripgrep) is much faster than grep with sane defaults. `fd` is a friendlier `find`. Install both — they're worth it.