Below I will post some useful Linux Bash or *ash similar command code. Some of these will seem trivial to those that know and to the rest, will hopefully be future cheat sheet material.

Commands:
[ctrl]-r = search bash history for entered string
[ctrl]-k = delete all characters to the end of the line
[ctrl]-u = delete all characters till the beginning of the line

Find all of the files in a directory with name or extension
and a creation time in the past 10 days:
find /source/dir -ctime -10 -iname "nameor*.extension" -exec cp "{}" /destination/dir/ \;

Find the number of requests Apache2 got in the last log file, grouped by hour:
cat /var/log/apache2/access.log | egrep -v 'cron|bot' | egrep -o '[0-9]{2}/[a-zA-Z]{3}/[0-9]{4}:[0-9]{2}' | uniq -c

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.