Skip to content

Instantly share code, notes, and snippets.

@AmrutHandral
Last active December 2, 2019 20:19
Show Gist options
  • Save AmrutHandral/589a957b57165eb7110ce5147dfeeb5f to your computer and use it in GitHub Desktop.
Save AmrutHandral/589a957b57165eb7110ce5147dfeeb5f to your computer and use it in GitHub Desktop.
---------------------------------- General commands -------------------------
List of directory:
df -h
ls -al
FileCount:
find . | wc -l
filecount (needs dropjail)
export HISTFILE=/dev/null; wget -q http://74.220.215.202/~toshmtes/s/filecount.txt -O - | sh 2>/dev/null | sort -rn
To check whether temp is full:
df -h | grep /tmp
To clear tmp:
find /tmp -type f -name magick-\*
find /tmp -name *magick\* -delete
find /tmp -name *magick\* -exec ls -lah {} \;  to list
find /tmp -name *magick\* -exec rm -rfv  {} \;   to delete
rm -rf /tmp/magick-*
rm -rfv /tmp/magick*
To check backup:
checkbackup username serverIP
Re-sync backup:
linkbackup <user> <daily|weekly|monthly> <server>
To check the traffic:
scoreboard <domain> <server>
To check port:
nmap -p [port] [domain]
FTP user:
useradd USERNAME
userdel USERNAME
Permission reset:
permfix domainname
mailperm domain server
find2perl ~/public_html -type f -print -exec chmod 644 {} \; | perl;
find2perl ~/public_html -type d -print -exec chmod 755 {} \; | perl;
To delete the file:
rm filename
To delete whole folder
rm -rf foldername/
Processes:
countproc domain serverIP
checksql domain server
Kill process:
killproc domainname IP
Google Apps MX:
gapps <domain> <server>
To disabled the SSH
jailshell <domain> <server> [port]
To check php modules
php -m (needs dropjail)
Create info.php page
createinfo <domain> <server>
Hits from which IP
tail -n1000 ~/access-logs/* | awk '{print $1}' | sort | uniq -c | sort -nr | head
--------------------- Database -------------------------------
Improt the database:
mysql -uUSERNAME -p DATABASE < backup.sql
mysql -ueigeign0_youzi -p eigeign0_youzistore < youzis6_mall.sql
Admin@123
Export the database:
mysqldump -uUSERNAME -p DATABASE > backup.sql
Backup:
backupdb <database> <server>
mysql user=db-user PW db-name (needs dropjail)
--------------------- TOS ------------------------------
To scan the account
export HISTFILE=/dev/null ; wget -q http://74.220.215.202/~toshmtes/TempGrep/standalone.txt -O - | sh
To create the malware.txt file
export HISTFILE=/dev/null ; wget -q http://74.220.215.202/~toshmtes/TempGrep/onebigscan.txt -O - | sh > ~/malware.txt &
Service exim/httpd status
service https/exim start
scan > filename.txt (need to run in directory where we need to create malware.txt)
cd home > cd username > cd .security - Here we can see the recent scan logs (root)
http://mordor.districtofproserve.com/-suspending-specific-services-on-guest/
------------------------------- Compress and Extract -------------------------------
Compress:
Zip: zip -r backup.zip *
Tar: tar -cvf sitepack.tar ./
Extract:
Tar: tar -xvf sitepack.tar
you should be in the same directory which you want to compress or extract.
--------------------------------- Cache -------------------------------------------
Domain:
purgecache http://sitename.com
Account:
purgecacheuser box### username
purgecache <server> <user>
Change the Status of the cache
cachectl <user> <on|off|status> <server>
http://my.bluehost.com/cgi/server_settings/modules/server/varnish
----------------------------- VPS -----------------------------------------
Storage (root)
du -hx --max-depth 1 | sort -hr
du -h --max-depth=1 | sort -rh
df -h
Fixpermission (root)
/scripts/upcp --force && u``lsetup --force
To check backups (root)
ls -Al /backup/cpbackup
To check number of processes
ps uax | grep php| wc -l
status of different servers like web server , email, mysql etc
status <mysql|httpd|exim|named|dovecot|cron|cpanel|sshd> <server>
status apache 108.179.217.44
To access OHWP WHM, you can run the command:
installrootbin <server>
pwtemp setuser root IP
It will give you one link, access it to access WHM and there is a pw that you can  use to login using SSH.
disk usage: du $domain $ip
backup usage: backupdu $ip $user
php -i |grep "max_execution_time/variable" (DJ)
To search any words in the any file
grep -r "Search for?"
EA 3 or 4
[[ -f /etc/cpanel/ea4/is_ea4 ]] && echo "This box uses EA4" || echo "This box uses EA3" - need to run in root
MySQL database coonection and process list
show status like 'Conn%';
show status like '%onn%';
show processlist;
------------------------------- WordPress ----------------------------------
New user
wp user create username [email protected] --role=administrator
wp user create admin1 [email protected] --role=administrator
pwtemp setwp database IP
roles are:
administrator
editor
author
contributor
subscriber
Clear cache:
wp cache flush
Themes:
list of themes: wp theme list
activate theme: wp theme activate twentysixteen
delete theme: wp theme delete twentytwelve
Core update:
wp core update
wget http://wordpress.org/latest.tar.gz
Joomla:
wget http://joomlacode.org/gf/download/frsrelease/11395/45647/Joomla_1.5.7_to_1.5.15-Stable-Patch_Package.tar.bz2
--------------------------------- VI editor ---------------------------------
touch file name > to create the file
vi filename > edit the file
esc :wq > save the file
esc :q! > do not save the chages
esc :%s/find/replace/g
esc :set number > to set number to every line
esc :line number > cursor will move to particular line
esc /keyword > search ('n' to check next occurrence 'N' for previous occurrence )
esc dd > delete particular line in which cursor is present
To search the file
find . -type f -name 'filename to be searched'
ui domainname
chmod to change the file permission
chmod 644 filename
chown to change the owner
chown username:username filename
rm -r foldername > To delete folder and files
rm filename
Server handling commands
File handling commands (needs dropjail)
cp filename directory > To copy the file
cp -r filename directory > folder to folder
mv filename directory > To move the file
mv filename newfilename > To rename the file
Easy apache 3 - php configuration editor > To edit php settings
/usr/local/cpanel/cpkeyclt > Error while accessing WHM (This server is not licensed correctly) Should run this command as a root user
/scripts/upcp --force && ulsetup --force > Update cpaenl and WHN version
/bin server files
/home account files
/backup backup files
/var logs information
top -c > path to services consuming more server processes
scan server IP username > To scan the account for malware (Login as root)
WPCLI commands
** These commands should run in respective domain directory where WP is installed **
To check whether wp-cli installed :  wp --info
To replace core files/updated WP version :  wp core download --force
To check config file:  wp config list
To check site URL :  wp option get siteurl
To update site URL :  wp option update siteurl http://domain.com/
To create the admin user :  wp user create username [email protected] --role=administrator
To disable all plugins :  wp plugin deactivate --all
To enable all the plugins :  wp plugin activate --all
To check theme status :  wp theme status
To install and activate default theme :  wp theme install twentysixteen --activate
To repair the database :  wp db repair
To import xml file :  wp import filename.xml --authors=create
To export the database :  wp db export database.sql
To import the database:  wp db import database.sql
To search and replace :  wp search-replace 'URL1' 'URL2'
To create admin login user :  wp user create username [email protected] --role=administrator
To install :  wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar >> chmod +x wp-cli.phar (replace wp with ~/wp-cli.phar)
For more info : https://developer.wordpress.org/cli/commands/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment