Mustafa Çavuşoğlu

Notes

Everyday commands I use at work, up to seven per topic. Replace anything in angle brackets.

  1. Read a file
    cat for short files, less to scroll long ones (q to quit).
    cat config.yaml
    less app.log
  2. Start, end and live tail
    Check the latest lines of a log as they arrive.
    head -n 20 app.log
    tail -n 50 app.log
    tail -f app.log
  3. Search inside files
    Recursive, with line numbers, case-insensitive.
    grep -rni "error" ./logs
  4. Edit a file
    nano is simplest; in vim press i to edit, Esc then :wq to save.
    nano config.yaml
    vim config.yaml
  5. Replace text in a file
    Every match, in place.
    sed -i 's/old/new/g' config.yaml
  6. File, folder and disk sizes
    Human-readable sizes.
    ls -lh
    du -sh *
    df -h
  7. Find files
    By name or by size.
    find . -name "*.log"
    find . -size +100M