Avantguard Computer & Security Systems

Various Commands

Find & Remove

# Find files older than 30 days and delete
find /path -mtime +30 -type f -delete

# Find and remove empty directories
find /path -type d -empty -delete

# Find files by size (larger than 100MB)
find / -size +100M -type f

Tree

# Install
apt install tree

# Usage
tree /path/to/dir
tree -L 2              # limit depth to 2 levels
tree -a                # show hidden files
tree -d                # directories only
tree -h                # human-readable sizes

Tar

# Create archive
tar -czvf archive.tar.gz /path/to/dir

# Extract archive
tar -xzvf archive.tar.gz
tar -xzvf archive.tar.gz -C /destination/

# List contents
tar -tzvf archive.tar.gz

# Create split archive (split into 1GB chunks)
tar -cz /path | split -b 1G - archive.tar.gz.

Rsync

# Basic sync (local)
rsync -av /source/ /destination/

# Sync to remote
rsync -avz /source/ user@host:/destination/

# Delete files at destination not in source
rsync -avz --delete /source/ /destination/

# Dry run (preview changes)
rsync -avzn /source/ /destination/

# Exclude files
rsync -avz --exclude='*.log' --exclude='.git' /source/ /destination/

Grep

# Basic search
grep "pattern" file.txt
grep -r "pattern" /path/    # recursive
grep -i "pattern" file.txt  # case insensitive
grep -v "pattern" file.txt  # invert (exclude matches)
grep -n "pattern" file.txt  # show line numbers
grep -l "pattern" /path/*   # list files with match

# Extended regex
grep -E "pattern1|pattern2" file.txt

# Count matches
grep -c "pattern" file.txt

Maildirmake

# Create Maildir structure
maildirmake /home/user/Maildir
maildirmake -f Sent /home/user/Maildir
maildirmake -f Drafts /home/user/Maildir
maildirmake -f Trash /home/user/Maildir
maildirmake -f Junk /home/user/Maildir

SSH Keygen

# Generate Ed25519 key (recommended)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Generate RSA key (4096-bit)
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

# Copy public key to remote host
ssh-copy-id user@host

# Manual copy
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys

# Change passphrase
ssh-keygen -p -f ~/.ssh/id_ed25519