Commands Reference
EXIM
| Description | Command |
|---|---|
| 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
| Description | Command |
|---|---|
| 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 extension | ls -X |
| Reverse order when sorting | ls -r |
| List inode | ls -i |
| List all files by size (human readable) | ls -laSh |
| List users home directory | ls ~ |
| List parent directory | ls .. |
| List all files with extension (.log) | ls *.log |
| List directories only | ls -d |
IPTABLES
| Description | Command |
|---|---|
| Drop traffic on port 80 (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 (POST data) | iptables -I INPUT -p tcp --dport 80 -m string --string 'POST /' --algo bm -j DROP |
| Drop traffic on port 80 (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 with numeric format | 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 chain (INPUT) | iptables -A INPUT -p tcp --dport 80 -j ACCEPT |
| Set chain default policy (DROP) | iptables -P INPUT DROP |
| Specify adapter (eth0) | iptables -I INPUT -i eth0 -p tcp --dport 80 -j ACCEPT |
MYSQL
| Description | Command |
|---|---|
| Export all databases | mysqldump -u[user] -p[pass] --all-databases > All_Databases.sql |
| Export single database | mysqldump -u[user] -p[pass] [db_name] > db.sql |
| Export multiple databases | mysqldump -u[user] -p[pass] --databases [db1] [db2] > dbs.sql |
| Export specific table | mysqldump -u[user] -p[pass] [db] [table] > table.sql |
| Import single database | mysql -u[user] -p[pass] [db] < db.sql |
| Import specific table | mysql -u[user] -p[pass] -D [db] < table.sql |
| Show global variables | mysql -u[user] -p[pass] -e 'show variables;' |
| Show a specific variable | mysql -u[user] -p[pass] -e 'show variables like "max_connections";' |
| Change global variable | mysql -u[user] -p[pass] -e 'set global max_connections = 200;' |
| Show process list | mysql -u[user] -p[pass] -e 'show processlist;' |
MYSQL SHELL
| Description | Command |
|---|---|
| Show databases | show databases; |
| Select a specific database | use databaseName; |
| Show tables | show tables; |
| Describe a table | describe tableName; |
| Show all data inside a table | select * from tableName; |
| Show column from a table | select URL from tableName; |
| Show column based on value | select URL from tableName where ID=2; |
CHANGE DIRECTORY
| Description | Command |
|---|---|
| Change to directory | 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)
| Description | Command |
|---|---|
| View CPU Information | cat /proc/cpuinfo |
| View Memory Information | cat /proc/meminfo |
SHUTDOWN
| Description | Command |
|---|---|
| Shutdown the system now | shutdown -h now |
| Shutdown 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 | shutdown -h 20:15 |
| Reboot the system | shutdown -r now |
| Reboot and skip fsck | shutdown -rf now |
| Reboot and force fsck | shutdown -rF now |
| Reboot and force fsck (reliable) | cd / && touch /forcefsck && shutdown -r now |