This page is currently under construction
Exim | |
Delivery message by ID | exim -M id |
Delete all messages in the queue | exiqgrep -i|xargs exim -Mrm |
Remove message from queue | exim -Mrm id |
View Message by ID (Header) | exim -Mvh id |
Display Exim's Configuration | exim -bP |
Show all messages in the queue (only ID) | exiqgrep -i |
Process queue | exim -q -v |
Force a message delivery by ID | exim -M id |
Remove all frozen messages | exiqgrep -z -i | xargs exim -Mrm |
View Message by ID (Body) | exim -Mvb id |
List Files | |
Show all files | ls -a |
Show results in long list format | ls -l |
Print file size in human readable sizes | ls -h |
List subdirectories recursively | ls -R |
Sort by file size | ls -S |
Sort by modification date | ls -t |
Do not sort | ls -U |
Sort alphabetically by entry extension | ls -X |
Reverse order when sorting | ls -r |
List inode | ls -i |
List all files by size (in human readable format), with the largest file at the bottom | ls -laSh |
List users home directory | ls ~ |
List parent directory | ls .. |
List all files with specific extension (.log) | ls *.log |
List directories only | ls -d |
iptables | |
Drop traffic on port 80 attempting to POST to a filename (POST /xmlrpc.php) | iptables -I INPUT -p tcp --dport 80 -m string --string 'POST /xmlrpc.php' --algo bm -j DROP |
Drop traffic on port 80 attempting to POST data | iptables -I INPUT -p tcp --dport 80 -m string --string 'POST /' --algo bm -j DROP |
Drop traffic on port 80 attempting to GET a filename (GET /readme.txt) | iptables -I INPUT -p tcp --dport 80 -m string --string 'GET /readme.txt' --algo bm -j DROP |
List iptables with line numbers | iptables -L --line-numbers |
List iptables with numeric format (Ports, IP Addresses etc.) | iptables -L -n |
List specific chain (INPUT) | iptables -L INPUT |
Delete specific rule (Line 4 from INPUT) | iptables -D INPUT 4 |
Zero counters | iptables -Z |
Show counters | iptables -vL |
Show exact counters | iptables -xvL |
Insert a rule at top of a chain (OUTPUT) | iptables -I OUTPUT -p tcp --sport 80 -j ACCEPT |
Insert rule at line number (3) | iptables -I INPUT 3 -p tcp --dport 80 -j ACCEPT |
Replace rule at line number (6) | iptables -R INPUT 6 -p tcp --dport 80 -j ACCEPT |
Flush chain (INPUT) | iptables -F INPUT |
Append rule to end of a chain (INPUT) | iptables -A INPUT -p tcp --dport 80 -j ACCEPT |
Set chain (INPUT) default policy (DROP) | iptables -P INPUT DROP |
Specify adapter to filter traffic on (eth0) | iptables -I INPUT -i eth0 -p tcp --dport 80 -j ACCEPT |
MySQL | |
Export all databases | mysqldump -u[root_username] -p[root_password] --all-databases > All_Databases.sql |
Export all databases (with formatted filename) | mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` --all-databases> ~/$(hostname).All_Databases.`date +%F_%H:%M`.sql |
Export single database | mysqldump -u[root_username] -p[root_password] [database_name] > databaseName.sql |
Export multiple databases | mysqldump -u[root_username] -p[root_password] --databases [database_name] [database_name] > databaseName.sql |
Export specific table | mysqldump -u[root_username] -p[root_password] [database_name] [table_name] > tableDump.sql |
Import single database | mysql -u[root_username] -p[root_password] [database_name] < databaseName.sql |
Import specific table | mysql -u[root_username] -p[root_password] -D [database_name] < tableName.sql |
Extract a database (test) from a full database export - Using sed | sed -n '/^-- Current Database: `databaseName`/,/^-- Current Database: `/p' All_Databases.sql > databaseName.sql |
Show global variables | mysql -u[root_username] -p[root_password] -e 'show variables;' |
Show a specific variable (max_connections) | mysql -u[root_username] -p[root_password] -e 'show variables like "max_connections";' |
Change global variable (max_connections) | mysql -u[root_username] -p[root_password] -e 'set global max_connections = 200;' |
Show current process list | mysql -u[root_username] -p[root_password] -e 'show processlist;' |
MySQL Shell | |
Show databases (from inside MySQL shell) | show databases; |
Select a specific database (databaseName) | use databaseName; |
Show tables | show tables; |
Describe a table (tableName) | describe tableName; |
Show all data inside a table (tableName) | select * from tableName; |
Show column (URL) from a table (tableName) | select URL from tableName; |
Show column (URL) from a table (tableName) based on the value of another column (ID) | select URL from tableName where ID=2; |
Change Directory | |
Change to directory (/var/log) | cd /var/log |
Change to users home directory | cd ~ |
Return to previous directory | cd - |
Change to root directory | cd / |
Change to parent directory | cd .. |
Identify Hardware (Linux) | |
View CPU Information | cat /proc/cpuinfo |
View Memory Information | cat /proc/meminfo |
Shutdown | |
Shutdown the system now | shutdown -h now |
Shutdown the system in 10 minutes | shutdown -h 10 |
Cancel pending shutdown | shutdown -c |
Send shutdown message | shutdown -h 10 "System is being taken offline" |
Shutdown at specific time (20:15) | shutdown -h 20:15 |
Reboot the system | shutdown -r now |
Reboot the system and skip fsck (may not work) | shutdown -rf now |
Reboot the system and force an fsck (may not work) | shutdown -rF now |
Reboot the system and force an fsck | cd / && touch /forcefsck && shutdown -r now |