Linux Command Line — Daily Essentials

লেসন ৭ / ৩৮

🧭 Navigation

pwd                # where am I
ls -lah            # all + size
cd /var/www/html
cd ~               # home
cd -               # previous
tree -L 2          # 2-level tree

📄 File Operations

touch file.txt
mkdir -p /app/logs
cat file.txt
less file.txt          # paged
head -20 file.txt
tail -20 file.txt
tail -f /var/log/nginx/error.log    # live 🔥

cp source dest
cp -r src/ dest/
mv old new
rm file
rm -rf folder/         # ⚠️ irreversible

🔍 Find & Grep

find / -name "nginx.conf"
find /var/www -name "*.php"
find /tmp -mtime +7 -delete
find . -size +100M

grep -i "error" log.txt
grep -n "TODO" *.php
grep -r "API_KEY" /var/www/
grep -v "info" log.txt
grep -A 3 -B 2 "ERROR" log.txt
tail -f log | grep --line-buffered ERROR  # 🔥

💾 Disk Usage

df -h                  # disk space 🔥
du -sh /var/www/*      # folder sizes
du -sh * | sort -rh | head -10
ncdu /                 # interactive

🔢 Pipe & Redirect

cat log | grep 404 | wc -l
ps aux | grep nginx

echo "x" > file        # overwrite
echo "y" >> file       # append
cmd 2> err.log         # stderr
cmd > out 2>&1         # both
cmd &> all.log         # bash shortcut

⚡ Shortcuts

Ctrl+R    # search history 🔥
Ctrl+L    # clear
Ctrl+A/E  # line start/end
!!        # last command
sudo !!   # repeat with sudo
history | grep nginx

🎓 মূল কথা ⭐

10 command = 90% কাজ। Ctrl+R history search use করুন। Daily practice ছাড়া fluency আসবে না।