Processen, geheugengebruik, netwerkactiviteit en schijfactiviteit
# List tasks, htop shows slightly more info top htop
# Memory usage, the number below "free" on the "-/+ buffers/cache" line is the actual free space free -m
# Show network activity, use "n"-key to toggle hostname resolving iftop
# Disk activity per process iotop
# Show number of cpu cores nproc
Beveiliging
Fail2ban
# Validate if regexes work with given logfile fail2ban-regex /path/to/logfile /etc/fail2ban/filter.d/filter-to-test.conf
# Show jail status fail2ban-client status jailname
# Remove ip from jail, use latter command for fail2van >v0.8.8 fail2ban-client get jailname actionunban 1.2.3.4 fail2ban-client set jailname unbanip 1.2.3.4
# Use -t "testing" the mail, this will output the e-mail adding a report at the bottom. cat message.eml | spamassassin -t # Use -D for "debugging" spamassassin, optionally pass a matching test, for example pyzor or bayes cat message.eml | spamassassin -D pyzor 2>&1 | less
# Manually learn a message as spam or ham cat "message.eml" | sa-learn --spam|--ham --username=vmail
# Remove address from whitelist manually spamassassin --remove-addr-from-whitelist foo@bar.baz
# Feed a message to the spamc-process and return the results (--full-spam will only return if message is marked as spam) cat message.eml | spamc --u rcpt@domain.tld--full|--full-spam
ClamAV
# Either use clamscan (reloads all database files) or use clamdscan (doesn't reload database files, thus faster) to scan a message or a path. # Add "-i" to only show infected files clamscan path/or/file clamdscan path/or/file
Postfix
# Delete all deferred messages from mailq postsuper -d ALL deferred
# Resend mails on queue (when you for example resolved a temporary error) # If mails remain on the queue after this than there should be a reason for that! postqueue -f sendmail -q
# View contents of a queued message # Either use mailq or postqueue -p to list message-ids postcat -q MESSAGEID
Bestanden (bewerken, opzoeken)
Find
# Remove "-ls" to show what exactly matched find . -type f | xargs grep "String in file"-ls # When files contain special characters, spaces or quotes, you have to escape them find . -type f -print0 | xargs -0 grep "String in file"-ls
# Find files and loop execute command on results find . -name '*.txt' -exec echo {} \;
# If results contain spaces or other special chars, then pipe it trough 'read' find . -name '*.txt' | while IFS= read -r FILE; do echo $FILE; done;
Grep
# Search in a continuous stream (for example with tail -f) tail -f file | grep --line-buffered search-string
Comprimeren & extraheren (decomprimeren)
# Compressing files tar -cvzf target.tar.gz file1 dir1wildcard/* zip target.zipfile1dir1wildcard/*
# Add a progress bar to compressing a tar tar cf - file-to-compress -P | pv -s $(du -sb file-to-compress | awk '{print $1}') | gzip > target.tar.gz
# Decompressing/extracting archives # Remove -z to extract a simple tar-archive tar -xvzf source.tar.gz unzip source.zip
Afbeeldingen converteren met Imagick
# Merge multiple images into one (creates CSS-sprite) # -extent is optional and can be used to make every image the same size # Use +append to create horizontal tiles convert image1.png image2.png image3.png -gravity NorthWest-extent 33x33 -append sprites.css
PDF
# Merge multiple pdf's into one single file gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf in1.pdf in2.pdf in3.pdf
# Rotate single page or multiple pages # Add 'north', 'east', 'south' or 'west' after eacht pagenumber you want to rotate. pdftk A=source.pdf cat A1-3 4east 5south 6-10 output dest.pdf
# Create a new tag git tag -a "v1.2.3." -m "Release message"
# Force new tags to remote origin git push --follow-tags
# Delete tag git push --delete origin "v1.2.3"
SVN
Tags (maken en verwijderen)
# Creating a tag in SVN is nothing more than copying sources to another folder svn copy svn://path.to.repo/project/stable svn://path.to.repo/project/tags/0.1.2 -m "Release message"
# Deleing a tag is nothing more than deleting the folder svn delete svn://path.to.repo/project/tags/0.1.2 -m "Remove release"
SVN Patches (maken, patchen en terugdraaien)
# Pipe the diff of two revisions to an output file svn diff -r [n-1]:[n] > /tmp/patch_[n].diff
# Use that output file to patch svn (keep an eye on conflicts) svn patch /tmp/patch_[n].diff
# And if patch went wrong, you can undo all changes svn revert
Properties bewerken (e.g. bestanden "ignoren")
# List all properties, or a specific one svn proplist svn propget svn:ignore
# Open an editor to edit the properties (use when for example ignoring multiple files/folders) svn propedit svn:ignore .
# Or set the property inline svn propset svn:ignore config.php .
CURL
# Get the headers from a given request # Useful when debugging 301 redirects curl -I -L "https://perfacilis.com/"
# Import database # Warning: specifying a database name has no effect if sql file contains "USE ..." mysql --defaults=file=/etc/mysql/debian.cnf dbname < dbname.sql gunzip < dbname.sql.gz | mysql --defaults=file=/etc/mysql/debian.cnf dbname