Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Skip to content
- migrationmach0 Just another WordPress site
- USEFUL COMMANDS FOR BASHING
- Protected: USEFUL COMMANDS FOR BASHING
- For find a file and outputing specific txt from file find . -type f -name ‘wp-config.php’ -exec grep DB {} \;
- For finding and replacing all references of http to https for custom coding issues causing mixed content. find . -type f ( -name “.shtml” -or -name “.css” -or -name “*.php” ) -exec sed -i.$(date +%s).back ‘s/http:/https:/’ {} \;
- export db:
- mysqldump -p -u peachlet_admin peachlet_admin > /home/peachlet/peachlet_admin.$(date +%s).sql
- import db:
- mysql -p -u peachlet_admin peachlet_w1 < peachlet_admin.1546890570.sql
- ^^^^^^ MAKE COPY OF DB BEFORE IMPORTS
- for cp command and making time stamped backup cp -vi .htaccess .htaccess.$(date +%s).bak
- Reviewing phpinfo from command line using lynx:
- lynx –dump blackest.info/phpinfo.php | less
- Creating phpinfo file from command line
- printf “” > phpinfo.php
- echo -e “” > phpinfo.php
- Getting headers/information about a domain using Curl
- curl -IL blackestinfo.com
- Parsing apache error log via command line:
- tail -n0 -f /usr/local/apache/logs/error_log
- tail -n0 -f /usr/local/apache/logs/error_log | grep 192.185.1.20
- Job Control, with an example:
- *** to execute a command in the background:
- tail -n0 -f /usr/local/apache/logs/error_log &
- *** list jobs:
- jobs -l
- *** to bring a running job to the foreground:
- fg ${number_here}
- *** Example:
- fg 1
- *** Seen bellow:
- root@ja30 [/home/blackest/public_html]# tail -n0 -f /usr/local/apache/logs/error_log &
- [2] 15462
- root@ja30 [/home/blackest/public_html]# fg 2
- Examples of useful uapi commands:
- uapi Mysql create_database name=peachlet_hgadmin
- uapi Mysql create_user name=peachlet_hgadmin password=pass101x
- uapi Mysql set_privileges_on_database user=peachlet_hgadmin database=peachlet_hgadmin privileges=ALL%20PRIVILEGES
- service ${service_name} restart
- invoke if on centos 6 or below /etc/init.d/sshd restart
- ——- SSH KEY’ING ——-
- ssh key gen should be done for 4096 bytes only
- Example:
- ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
- ——- RSYNC ——-
- Copy of data across locations
- Trailing slash will have the content inside of the source and not the folder content is in be copied over
- Usage:
- rsync –dry-run -avpP $source/ $destination/
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
- Lack of trailing slash will copy over the folder with the contents inside of the directory:
- Usage:
- rsync –dry-run -avpP $source $destination
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
- 2 types of rsync <<
- (PULL)
- rsync –dry-run -avpP -e “ssh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
- (PUSH)
- rsync –dry-run -avpP -e “ssh -i transfer_key2” /home/saber/public_html/blog/ root@$server_ip:/home/hgtransfer/CASE_ID/source/thekingofknights.com/
- List all current processes
- ps -f
- su command
- sudo to perform command as root or other user without switching users
- ——- SSH KEY’ING ——-
- ssh key gen should be done for 4096 bytes only
- Example:
- ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
- ——- RSYNC ——-
- Copy of data across locations
- Trailing slash will have the content inside of the source and not the folder content is in be copied over
- Usage:
- rsync –dry-run -avpP $source/ $destination/
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
- Lack of trailing slash will copy over the folder with the contents inside of the directory:
- Usage:
- rsync –dry-run -avpP $source $destination
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
- 2 types of rsync <<
- (PULL)
- rsync –dry-run -avpP -e “ssh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
- (PUSH)
- rsync –dry-run -avpP -e “ssh -i transfer_key2” /home/saber/public_html/blog/ root@$server_ip:/home/hgtransfer/CASE_ID/source/thekingofknights.com/
- server to server migration
- step 1 gen a ssh auth key and append to /root/.ssh/authorized_keys
- command $ ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
- add to src for push and to dest if pulling
- step 2 test ssh connection success
- step 3 mkdir for work space
- step 4 backup content needed for move
- step 5 rsync the backup to dest
- cpanel backup/restore full restore
- step 1 create workspace
- mkdir -pv /home/hgtransfer/TICKETID/{restore-from, backup-to} << bracket expansion
- step 2 make backup
- /scripts/pkgacct –userbackup username /home/hgtransfer/TICKETID/backup-to
- step 3 make a screen
- screen -S TICKETID
- step 4 kill the package user
- pkgnkill username
- step 5 restorepkg from backup
- /scripts/restorepkg /home/hgtransfer/TICKETID/restore-from/cpmove-username.tar.gz
- Post-restore checks
- Make sure permissions and ownership of the files that were restored are set correctly.
- Make sure the site loads – visit the site in your browser.
- Check ownership
- If the account is on a reseller server, ensure that the user is updated to be owned by the correct reseller.
- cppc –setowner resellerusername resoldusername
- If the account is on a shared hosting server, ensure that the user is updated to the correct hosting package.
- cppc –sethgpkg Baby username
- If the account is on a reseller server and needs to be the reseller user, ensure that you set the reseller permissions accordingly.
- cppc –sethgpkg aluminum username
- service command for all services (software packages enabled on sys)
- service ${service_name} restart|status
- or invoke init.d
- /etc.init.d/sshd restart
- useful bash commands
- ——- SSH KEY’ING ——-
- ssh key gen should be done for 4096 bytes only
- Example:
- ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
- ——- RSYNC ——-
- Copy of data across locations
- Trailing slash will have the content inside of the source and not the folder content is in be copied over
- Usage:
- rsync –dry-run -avpP $source/ $destination/
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
- Lack of trailing slash will copy over the folder with the contents inside of the directory:
- Usage:
- rsync –dry-run -avpP $source $destination
- Example:
- rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
- 2 types of rsync <<
- bash resources
- http://mywiki.wooledge.org/BashGuide
- http://www.grymoire.com/Unix/Sh.html (The original Bourne Shell; Bash is a more expanded version of the Bourne Shell)
- https://www.hackerrank.com/domains/shell/bash
- https://cmdchallenge.com/
- http://www.grymoire.com/Unix/Find.html
- http://www.grymoire.com/Unix/Grep.html
- http://www.grymoire.com/Unix/Awk.html
- http://www.grymoire.com/Unix/sed.html
- Getting Gud with cPanel!
- https://university.cpanel.net/
- API’s & U
- https://documentation.cpanel.net/display/DD/Guide+to+UAPI
- https://documentation.cpanel.net/display/DD/Guide+to+cPanel+API+2
- Reviewing phpinfo from command line using lynx:
- lynx –dump blackest.info/phpinfo.php | less
- Creating phpinfo file from command line
- printf “” > phpinfo.php
- echo -e “” > phpinfo.php
- Getting headers/information about a domain using Curl
- curl -IL blackestinfo.com
- Parsing apache error log via command line:
- tail -n0 -f /usr/local/apache/logs/error_log
- tail -n0 -f /usr/local/apache/logs/error_log | grep 192.185.1.20
- Job Control, with an example:
- *** to execute a command in the background:
- tail -n0 -f /usr/local/apache/logs/error_log &
- *** list jobs:
- jobs -l
- *** to bring a running job to the foreground:
- fg ${number_here}
- *** Example:
- fg 1
- *** Seen bellow:
- root@ja30 [/home/blackest/public_html]# tail -n0 -f /usr/local/apache/logs/error_log &
- [2] 15462
- root@ja30 [/home/blackest/public_html]# fg 2
- Examples of useful uapi commands:
- uapi Mysql create_database name=peachlet_hgadmin
- uapi Mysql create_user name=peachlet_hgadmin password=pass101x
- uapi Mysql set_privileges_on_database user=peachlet_hgadmin database=peachlet_hgadmin privileges=ALL%20PRIVILEGES
- https://vim-adventures.com/
- (PULL)
- rsync –dry-run -avpP -e “ssh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
- export db:
- mysqldump -p -u peachlet_admin peachlet_admin > /home/peachlet/peachlet_admin.$(date +%s).sql
- import db:
- mysql -p -u peachlet_admin peachlet_w1 < peachlet_admin.1546890570.sql
- ^^^^^^ MAKE COPY OF DB BEFORE IMPORTS
- linux survival
- cmdchallenge.com
- bash common commands
- grep, awk, sed , printenv, cd, mv, cp, rm, rmdir, mkdir, touch, echo, export, import, bind, lsattr, ls, chmod, stat, host, nslookup , df -h, tail,
- eigsh common commands
- ui, dig bandecoffee.net , host -t mx bandecoffee.ne, dig, ipid, whois, du, wpinfo, pwtemp, logtail, loggrep, whois, ping, traceroute, vps
- eigsh@wizard2 > help
- account:
- abusetool [server] will enable or disable all cpanel/sites/emails/crons under a specified account in either the system, apache, exim or outbounding scripts
- backupdu Prints disk usage of a Dedi/VPSs cPanel backup directory
- bluri will block or unblock specified URI via mod_rewrite in domain’s document root .htaccess file.
- bui [] display domain/account billing information
- checkcancel displays last cPanel and FTP login times for an account
- checkrestrictions [server] shows all montool restrictions on account
- cloudsearch Looks up information for a cloudsites account.
- countproc [server] check current number of processes for a user
- dcv returns possible dcv email addresses for a domain
- dedireset reset the root password for a dedicated server
- domlist lists domains for a user
- gatorlookup checks if a specified domain or email address is a GATOR customer (the sitebuilder product)
- inodes shows a breakdown of inodes based on a path
- killproc kill all current processes for a user
- legalrestrict [server] chmod and chattrs a customers homedirectory
- ncdu [server] generates an explorable directory tree by size in a users homedir
- openport opens a port outbound globally on a server
- overselltemp [server] will set a reseller to be able to oversell temporarily for 24 hours
- restrict [server] htpasswd restricts customer account
- resusage print the resellers current disk and bandwith usage/limit
- searchcpanel [server] search cPanel access logs
- skipbackup skips next backup for an account
- sloptout [server] Opts a user out from regular sitelock scanning
- suspbackup creates a user accessible backup
- testlogin test the password of the account against the given information
- toswhitelist [server] white lists a customer IP against a TOS restricted account
- ui [server] display domain/account information
- unrestrict [server] removes htpasswd restrictions on customer account
- unsuspend unsuspend a user
- apache:
- apachegrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- apachelog This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- apacherestart restarts apache
- apachetail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- awstats [number of top results] displays the top number of sites/traffic via the customers awstats logs. Specifying 0 will provide this months stats.
- cachectl enable or disable caching for a users account
- checkautossl check a user’s AutoSSL configuration
- checksites <-r|-u> (server only required when user is specified) checks a users domains for problems (-r will show all resold domains under a reseller)
- createinfo create a phpinfo page in the users public_html dir
- createini create a modifiable php.ini in the users home dir
- disableuserdir [1] disables userdir for a user, optional input tells the script whether or not the changes should be applied immediately
- edithtaccess allows one to edit an .htaccess in a users account
- editini find and optionally edit all php.inis for a domain
- phpallow <52|53|54|55|56|70|71|all> allow user to select deprecated version of PHP
- phphandler <52|53|54|55|56|70|71|stable|edge|strip> updates a domains htaccess to use the specified php version
- phpvers displays all php versions installed on specified server
- purgecache removes cache for a provided domain from the caching layer
- purgecacheuser purges the cache on all domains for the specified user
- scoreboard check concurrent apache connections for a server
- sitereport performs a variety of account checks and reports problems
- sslinfo [server] print ssl information for all domains under an account
- uf display all vhosts matching the the domain
- whitelist whitelist a domain for certain mod_security rules
- cpanel:
- accounting This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- bwu display bandwidth usage information for a user or reseller (plus sub accounts)
- changepackage [aluminum|copper|silver|gold|diamond|hatchling|baby|business|hatchling_unlimited|baby_unlimited|business_unlimited] change package of a shared/reseller account
- checkbackup [server] displays the status of a users backups
- checkbackupvps check for backups on VPS servers
- checkips runs a check against used dedicated IPs to ensure theyre being used properly
- checkrescancel displays last cPanel and FTP login times for a reseller and resold
- cphulkdblacklist blacklists an IP in cphulkd
- cphulkdwhitelist whitelists an IP in cphulkd
- cpkeyupdate runs /usr/local/cpanel/cpkeyclt to update cPanel license
- fantfix fixes “script already installed” bug in fantastico for a user
- ftplog This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- getpasswsp prints the WSP login
- ipdedi shows information regarding dedi ip usage for a domain
- iskilled runs iskilled against a specified domain
- jailshell [port] enables jailshell for the specified clients account
- killgrep search through kill logs
- logingrep greps the cphulkd and cPanel logs for user failed logins and blocks
- oi shows detailed information about a domain from the server
- permfix [server] resets permissions on public_html and all subfiles/folders for a user
- pwreset changes password for a user to a random password
- pwtemp <(set|unset)(user|mail|ftp|mailman|plesk|wp|joom|drupal|magento|zencart|vb|whmcs|phpbb|smf)> <-d for a permanent reset> set/remove temporary passwords for accounts/emails/several CMS
- qifix fixes common issues with quickinstall and missing perl modules
- quota check current quota for a user. (includes inodes)
- resetcpanel this will reset the account as it was on day 1 with a new password
- resipcheck print a list of accounts with dedicated ips
- themeset [server] set theme for a cpanel user. options: x x3 rvskin
- dns:
- addptr adds or updates ptr for IP
- checkzone provides information about a domain
- dig [type-of-record] performs the dig command against a provided domain
- dkimspf enables, disables, and gets status of DKIM and SPF for a user
- dns prints dns information about a domain
- fixdediips fixes issues with arp and ips not routing properly to dedicated servers
- ipfix [server] fixes mismatch DNS and vhost ips
- ipid performs standard ip related lookups
- viewzone [server] views a DNS zone file for a domain
- whois whois a domain or IP
- email:
- addofficesrv add the sipdir and sipfed dns records required for Office365
- autossldisable [server] toggles a domain autossl on and off
- catchall toggle catchall setting for a user
- checkblacklist [1|true] check if an ip is on the exim blacklist, and optionally remove the block
- cmdelist de-lists a message from cloudmark
- couriergrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- couriertail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- dtoggle toggle a domain in /etc/localdomains & /etc/remotedomains
- ec [-h # of hours] runs ec against an account
- emailcheck list email accounts for a user with quota and remote / local status
- emailperhour [server] sets the limit of emails per hour an account can send
- eximclear [server] clears the mail queue for a particular user
- eximgrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- eximtail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
- gapps install google apps mail/calendar for a domain
- godaddy install godaddy MX records into a domain
- hamfpinsert inserts into ham
- hamfplookup <user> <server> checks mailpipe for whitelist fingerprints for a specified user/server hamlookup <exim-id> checks mailpipe for information on a particular message imapcheck <user|email> <server> checks to see if a user has hit our imap kill limit recently imapwhitelist <domain> <server> whitelists a user against our imap kill limit listfwder <domain> [server] list forwarders for a user mailperm <domain> <server> fix the mailbox permissions for a user popcheck <domain> <user> <password> check a POP/IMAP login for a user rblcheck <ip> checks an IP against RBLs and our internal apache/exim blacklist rldomcheck <domain> [server] check whether domain is in localdomains or remotedomains smtpwhite <domain> <server> whitelist a domain owner for smtp
- ftp:
- pwsync sync ftp/cPanel passwords
- testftp tests an ftp transaction against an account
- misc:
- checkfire checks the firewall and routing table to see if a customers IP has been blocked
- dr look for (and try to fix) errors with a server’s disaster recovery configuration
- dropjail [server] [port] drops into a clients jailshell – server is required when port is specified
- du [server] display disk and inode usage on specified server
- fixsb find and fix php_value mbstring in .htaccess for a user
- genpass [joomla|wp|md5] Will generate a random password for you, if joomla then password hash and salt is printed for insertion into database
- grabips lists all ips bound to a server
- gtmetrix runs a gtmetrix scan on target
- host host lookup for IP or hostname
- inodereport runs a server wide inode usage report for a server
- installfire installs the EIG Firewall onto a VPS or dedicated server
- installrootbin installs or updates the root bin for a vps or dedicated server
- loggrep searches log files for specified input
- logtail [search keyword] tails log files with optional grep input
- lsattr checks file for immutable attribute (chattr)
- man
- opens man page for a command
- montool provides access to some limited montool functionality
- mtrreport [count] traceroutes to destination using mtrs -r report. Count is a specification of -c and is optional
- n port scans an IP or hostname
- outboundwhitelist whitelists a user to be able to make outbound posts to wp-login
- ping [count] ping a domain until ctrl-cd or until numpings is reached
- quarantinelog [selection|all|timestamp] checks malware quarantine log
- retrace reverse traceroute, must include server
- status returns the status of a service running on a server
- top run top on a server
- traceroute traceroute a network location from wizard
- vps performs limited actions on a vps
- vpsupbrstatus Returns status of vps container upgrade.
- vpsupstatus Returns status of vps container upgrade.
- w display who is logged in to a server
- whoson [username] provides information on who is logged into specific servers
- wpinfo [backup file] displays wordpress information about a given site
- wprbl whitelist [server] whitelists a /24 IP range from being blocked by wprbl RBL checks
- mysql:
- adduserdb assigns a mysql user to a database
- backupdb dumps small databases into users homedirectory
- checksql show current mysql usage for a user
- mkdbuser creates a new database user
- myisamchk repair a database
- mysqllog This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead. removeuserdb <database> <database_user> <server> remove a user access to a specific database
- removedomain:
- removedomain [server] remove stale domain from server (generally so that a customer can add it)
- sales:
- checksni [server] tests if server supports SNI
- gbbannedip displays if an IP is banned from billing
- gencsr generates rsa csr
- pplookup <paypal id> prints a link to look a paypal ID in gatorbill removedediip <domain> <server> sets a user back to the primary shared IP
- security:
- amc runs /root/bin/amc against a directory
- lockdown [server] disables a service on a server for abuse tickets
- secinfo [server] check a domain for mod_security blocks
- securitylog [server] [port] parses /root/bin/security run logs
- transfers:
- swamp add account to swamp.hostgator.com system
- Search for:
- Search …
- Recent Posts
- Welcome to the Gutenberg Editor
- Hello world!
- Recent Comments
- migrationmach0 on Hello world!
- migrationmach0 on Hello world!
- A WordPress Commenter on Hello world!
- Archives
- January 2019
- Categories
- Uncategorized
- Meta
- Log in
- Entries RSS
- Comments RSS
- WordPress.org
- migrationmach0, Proudly powered by WordPress.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement