Commands

This page is currently under construction

Exim

Delivery message by IDexim -M id
Delete all messages in the queueexiqgrep -i|xargs exim -Mrm
Remove message from queueexim -Mrm id
View Message by ID (Header)exim -Mvh id
Display Exim's Configurationexim -bP
Show all messages in the queue (only ID)exiqgrep -i
Process queueexim -q -v
Force a message delivery by IDexim -M id
Remove all frozen messagesexiqgrep -z -i | xargs exim -Mrm
View Message by ID (Body)exim -Mvb id

List Files

Show all filesls -a
Show results in long list formatls -l
Print file size in human readable sizesls -h
List subdirectories recursivelyls -R
Sort by file sizels -S
Sort by modification datels -t
Do not sortls -U
Sort alphabetically by entry extensionls -X
Reverse order when sortingls -r
List inodels -i
List all files by size (in human readable format), with the largest file at the bottomls -laSh
List users home directoryls ~
List parent directoryls ..
List all files with specific extension (.log)ls *.log
List directories onlyls -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 dataiptables -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 numbersiptables -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 countersiptables -Z
Show countersiptables -vL
Show exact countersiptables -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 databasesmysqldump -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 databasemysqldump -u[root_username] -p[root_password] [database_name] > databaseName.sql
Export multiple databasesmysqldump -u[root_username] -p[root_password] --databases [database_name] [database_name] > databaseName.sql
Export specific tablemysqldump -u[root_username] -p[root_password] [database_name] [table_name] > tableDump.sql
Import single databasemysql -u[root_username] -p[root_password] [database_name] < databaseName.sql
Import specific tablemysql -u[root_username] -p[root_password] -D [database_name] < tableName.sql
Extract a database (test) from a full database export - Using sedsed -n '/^-- Current Database: `databaseName`/,/^-- Current Database: `/p' All_Databases.sql > databaseName.sql
Show global variablesmysql -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 listmysql -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 tablesshow 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 directorycd ~
Return to previous directory cd -
Change to root directorycd /
Change to parent directorycd ..

Identify Hardware (Linux)

View CPU Informationcat /proc/cpuinfo
View Memory Information cat /proc/meminfo

Shutdown

Shutdown the system nowshutdown -h now
Shutdown the system in 10 minutesshutdown -h 10
Cancel pending shutdownshutdown -c
Send shutdown messageshutdown -h 10 "System is being taken offline"
Shutdown at specific time (20:15)shutdown -h 20:15
Reboot the systemshutdown -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 fsckcd / && touch /forcefsck && shutdown -r now