Papadope Course
EN | ΕΛ

Lesson 1 - Basic Commands

Lesson 1 - Basic Commands (25/10/25)

Basic Linux commands for file manipulation and searching.


cat

Display/concatenate files.

cat notes.txt                                    # display file contents
cat -n script.sh                                 # number lines in output
cat -A data.bin                                  # show "non-printable" characters (debugging)
cat part1.txt part2.txt > all.txt                # concatenate files into new file
cat > todo.txt << 'EOF'                          # quick creation with heredoc
- setup lab VM
- update packages
EOF

file

Identify file type regardless of extension.

file mystery.bin                                 # type of a file
file -i sample.png                               # MIME type (useful in web/forensics)
file *                                           # batch on multiple files

du

Disk usage by files/folders.

du -sh .                                         # human-readable sizes (K/M/G)
du -h -d 1 | sort -h                             # how "heavy" each subdirectory is (depth 1)
du -sh /var/log                                  # size of specific folder
du -h -d 2 | sort -h | tail -n 10                # top 10 heaviest items

find

Locate files with criteria + execute commands.

find . -type f -name 'config.php'                # find files named exactly "config.php"
find /var/log -type f -name '*.log' -size +10M   # find .log files larger than 10MB
find . -type f -mtime -1                         # find files modified in last 24 hours
find /var/www -type f -perm -o=w                 # find files with world-writable permissions (dangerous)
find . -type f -name '*.pcap' -exec ls -lh {} \; # execute command on findings
find . -type f -print0 | xargs -0 grep -n 'API_KEY' # safe piping (for weird names)

Be careful with -delete. Test first with -print/-ls.


grep

Search text/regex.

grep 'ERROR' app.log                             # find the word "ERROR" in a log
grep -i 'login failed' server.log                # case-insensitive
grep -R -n 'API_KEY' .                           # recursively in folder + line number
grep -R -n -C 2 'Exception' .                    # show context: 2 lines before/after
grep -E -n 'admin|root' /etc/passwd              # extended regex (e.g., alternatives)
grep -Rl 'Bearer ' .                             # show only file names
grep -v '^#' settings.conf                       # negative match (lines that DON'T match)
grep -oE 'AKIA[0-9A-Z]{16}' config/*             # show only the matching part

How do these help us though?