CXS shell command
/usr/sbin/cxs --allusers --baction high --bayes --breport medium --clamdsock /var/run/clamav/clamd.sock --deep --defapache nobody --doptions Mv --exploitscan --nofallback --filemax 10000 --noforce --html --ignore /etc/cxs/cxs.ignore --logfile /var/log/cxs.log --mail epoch23@gmail.com --options mMOLfSGchexdnwZRD --qoptions MBhv --quiet --report /var/log/cxs.scan --sizemax 1000000 --ssl --summary --sversionscan --timemax 30 --nounofficial --virusscan --voptions mfuhexT --Wmaxchild 3 --Wnotify inotify --Wrateignore 0 --Wrefresh 7 --Wsleep 3 --Wstart
Create new png files from jpg files recursively
find . -name "*.jpg" -exec mogrify -format png {} \;
Create webp files recursively from png files
find . -name "*.png" | parallel -eta cwebp {} -o {.}.webp
KILL a user session from root where ### is the user id
skill -KILL -t pts/###
Check the most recently modified file through shell
find /home/username/public_html/ -mtime 0
Speed Test - change test10.zip to test500.zip to test with a 500MB file
wget -O /dev/null https://dl.vanhoutte.be/cdn/1GB.bin
Detect possible hacker ssh shells running
ps ax | grep "ssh" | grep -v "grep"
Replace all occurrences of <string1> with <string2> for files in <mydir> recursively
find <mydir> -type f -exec sed -i 's/<string1>/<string2>/g' {} +
Append to files recursively
find . -type f -exec bash -c 'echo "append this" >> "{}"' \;
Find files named error_log and delete them all
find . -name error_log -delete #
Replace all occurrences within all php files in the same directory
sed -i 's///g' *php
Replace all occurrences within all html files in the same directory
sed -i "s###g" *html
Scan files within a directory for matching text
grep -rl 'text to match here' .
Check a port for what it belongs to, good for checking for backdoors
fuser -vn tcp 1337
List all directory and filesizes
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'
List top 10 biggest files in directory
du -a /var | sort -n -r | head -n 10
Find and print the top 10 largest files names (not directories) in a particular directory and its sub directories
find . -printf '%s %p\n'|sort -nr|head
Delete unread emails from server
find -P /home/epoch/mail/*/*/new -mindepth 1 -maxdepth 1 -mtime '+400' -delete
Delete read emails from server
find -P /home/epoch/mail/*/*/cur -mindepth 1 -maxdepth 1 -mtime '+400' -delete
Check bandwidth usage per connection
iftop -i eth1
Find and sort top 10 largest MYSQL database tables (do this from phpmyadmin SQL tab)
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
Repair & Optimize all MYSQL databases
mysqlcheck -u root --auto-repair --optimize --all-databases
Dump all MYSQL databases & tables to a file
mysqldump -uroot --all-databases > alldb.sql
Load MYSQL databases & tables from a file
mysql -u root -p < alldb.sql
Recursively Optimize PNG Files
find -name '*.png' -print0 | xargs -0 optipng -nc -nb -o7
for file in `find -name '*.png'`; do pngcrush -reduce -brute $file /usr/local/src/crushed.png; mv /usr/local/src/crushed.png $file; done
BASH script to execute actions on multiple files
#!/bin/sh
for png in `find $1 -name "*.png"`;
do
echo "crushing $png"
pngcrush -brute "$png" temp.png
mv -f temp.png $png
done;
CHANGE ALL FOLDER PERMISSIONS RECURSIVELY
find /home/*/public_html -type d -exec chmod 755 {} \;
CHANGE ALL FILE PERMISSIONS RECURSIVELY
find /home/*/public_html -type f -exec chmod 644 {} \;