Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 20.82 KB | None | 0 0
  1. Skip to content
  2. migrationmach0  Just another WordPress site
  3. USEFUL COMMANDS FOR BASHING
  4. Protected: USEFUL COMMANDS FOR BASHING
  5. For find a file and outputing specific txt from file find . -type f -name ‘wp-config.php’ -exec grep DB {} \;
  6.  
  7. 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:/{} \;
  8.  
  9. export db:
  10.  
  11. mysqldump -p -u peachlet_admin peachlet_admin > /home/peachlet/peachlet_admin.$(date +%s).sql
  12. import db:
  13. mysql -p -u peachlet_admin peachlet_w1 < peachlet_admin.1546890570.sql
  14. ^^^^^^ MAKE COPY OF DB BEFORE IMPORTS
  15.  
  16. for cp command and making time stamped backup cp -vi .htaccess .htaccess.$(date +%s).bak
  17.  
  18. Reviewing phpinfo from command line using lynx:
  19. lynx –dump blackest.info/phpinfo.php | less
  20.  
  21. Creating phpinfo file from command line
  22. printf “” > phpinfo.php
  23. echo -e “” > phpinfo.php
  24.  
  25. Getting headers/information about a domain using Curl
  26. curl -IL blackestinfo.com
  27.  
  28. Parsing apache error log via command line:
  29. tail -n0 -f /usr/local/apache/logs/error_log
  30. tail -n0 -f /usr/local/apache/logs/error_log | grep 192.185.1.20
  31.  
  32. Job Control, with an example:
  33. *** to execute a command in the background:
  34. tail -n0 -f /usr/local/apache/logs/error_log &
  35. *** list jobs:
  36. jobs -l
  37. *** to bring a running job to the foreground:
  38. fg ${number_here}
  39. *** Example:
  40. fg 1
  41. *** Seen bellow:
  42. root@ja30 [/home/blackest/public_html]# tail -n0 -f /usr/local/apache/logs/error_log &
  43. [2] 15462
  44. root@ja30 [/home/blackest/public_html]# fg 2
  45.  
  46. Examples of useful uapi commands:
  47. uapi Mysql create_database name=peachlet_hgadmin
  48. uapi Mysql create_user name=peachlet_hgadmin password=pass101x
  49. uapi Mysql set_privileges_on_database user=peachlet_hgadmin database=peachlet_hgadmin privileges=ALL%20PRIVILEGES
  50.  
  51. service ${service_name} restart
  52.  
  53. invoke if on centos 6 or below /etc/init.d/sshd restart
  54.  
  55. ——- SSH KEY’ING ——-
  56. ssh key gen should be done for 4096 bytes only
  57. Example:
  58. ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
  59. ——- RSYNC ——-
  60. Copy of data across locations
  61. Trailing slash will have the content inside of the source and not the folder content is in be copied over
  62. Usage:
  63. rsync –dry-run -avpP $source/ $destination/
  64. Example:
  65. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
  66. Lack of trailing slash will copy over the folder with the contents inside of the directory:
  67. Usage:
  68. rsync –dry-run -avpP $source $destination
  69. Example:
  70. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
  71.  
  72. 2 types of rsync <<
  73. (PULL)
  74. rsync –dry-run -avpP -essh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
  75. (PUSH)
  76. rsync –dry-run -avpP -essh -i transfer_key2” /home/saber/public_html/blog/ root@$server_ip:/home/hgtransfer/CASE_ID/source/thekingofknights.com/
  77.  
  78. List all current processes
  79.  
  80. ps -f
  81.  
  82. su command
  83.  
  84. sudo to perform command as root or other user without switching users
  85.  
  86. ——- SSH KEY’ING ——-
  87. ssh key gen should be done for 4096 bytes only
  88. Example:
  89. ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
  90. ——- RSYNC ——-
  91. Copy of data across locations
  92. Trailing slash will have the content inside of the source and not the folder content is in be copied over
  93. Usage:
  94. rsync –dry-run -avpP $source/ $destination/
  95. Example:
  96. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
  97. Lack of trailing slash will copy over the folder with the contents inside of the directory:
  98. Usage:
  99. rsync –dry-run -avpP $source $destination
  100. Example:
  101. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
  102. 2 types of rsync <<
  103. (PULL)
  104. rsync –dry-run -avpP -essh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
  105. (PUSH)
  106. rsync –dry-run -avpP -essh -i transfer_key2” /home/saber/public_html/blog/ root@$server_ip:/home/hgtransfer/CASE_ID/source/thekingofknights.com/
  107.  
  108. server to server migration
  109. step 1 gen a ssh auth key and append to /root/.ssh/authorized_keys
  110. command $ ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
  111. add to src for push and to dest if pulling
  112. step 2 test ssh connection success
  113. step 3 mkdir for work space
  114. step 4 backup content needed for move
  115. step 5 rsync the backup to dest
  116. cpanel backup/restore full restore
  117. step 1 create workspace
  118. mkdir -pv /home/hgtransfer/TICKETID/{restore-from, backup-to} << bracket expansion
  119. step 2 make backup
  120. /scripts/pkgacct –userbackup username /home/hgtransfer/TICKETID/backup-to
  121. step 3 make a screen
  122. screen -S TICKETID
  123. step 4 kill the package user
  124. pkgnkill username
  125. step 5 restorepkg from backup
  126. /scripts/restorepkg /home/hgtransfer/TICKETID/restore-from/cpmove-username.tar.gz
  127. Post-restore checks
  128. Make sure permissions and ownership of the files that were restored are set correctly.
  129. Make sure the site loads – visit the site in your browser.
  130. Check ownership
  131. If the account is on a reseller server, ensure that the user is updated to be owned by the correct reseller.
  132. cppc –setowner resellerusername resoldusername
  133. If the account is on a shared hosting server, ensure that the user is updated to the correct hosting package.
  134. cppc –sethgpkg Baby username
  135. If the account is on a reseller server and needs to be the reseller user, ensure that you set the reseller permissions accordingly.
  136. cppc –sethgpkg aluminum username
  137. service command for all services (software packages enabled on sys)
  138. service ${service_name} restart|status
  139. or invoke init.d
  140. /etc.init.d/sshd restart
  141. useful bash commands
  142. ——- SSH KEY’ING ——-
  143. ssh key gen should be done for 4096 bytes only
  144. Example:
  145. ssh-keygen -b 4096 -f /home/hgtransfer/CASE_ID/transfer_key
  146. ——- RSYNC ——-
  147. Copy of data across locations
  148. Trailing slash will have the content inside of the source and not the folder content is in be copied over
  149. Usage:
  150. rsync –dry-run -avpP $source/ $destination/
  151. Example:
  152. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog/ /home1/saber/public_html/
  153. Lack of trailing slash will copy over the folder with the contents inside of the directory:
  154. Usage:
  155. rsync –dry-run -avpP $source $destination
  156. Example:
  157. rsync –dry-run -avpP /home/hgtransfer/CASE_ID/blog /home1/saber/public_html/
  158. 2 types of rsync <<
  159. bash resources
  160. http://mywiki.wooledge.org/BashGuide
  161. http://www.grymoire.com/Unix/Sh.html (The original Bourne Shell; Bash is a more expanded version of the Bourne Shell)
  162. https://www.hackerrank.com/domains/shell/bash
  163. https://cmdchallenge.com/
  164. http://www.grymoire.com/Unix/Find.html
  165. http://www.grymoire.com/Unix/Grep.html
  166. http://www.grymoire.com/Unix/Awk.html
  167. http://www.grymoire.com/Unix/sed.html
  168. Getting Gud with cPanel!
  169. https://university.cpanel.net/
  170. API’s & U
  171. https://documentation.cpanel.net/display/DD/Guide+to+UAPI
  172. https://documentation.cpanel.net/display/DD/Guide+to+cPanel+API+2
  173. Reviewing phpinfo from command line using lynx:
  174. lynx –dump blackest.info/phpinfo.php | less
  175. Creating phpinfo file from command line
  176. printf “” > phpinfo.php
  177. echo -e “” > phpinfo.php
  178. Getting headers/information about a domain using Curl
  179. curl -IL blackestinfo.com
  180. Parsing apache error log via command line:
  181. tail -n0 -f /usr/local/apache/logs/error_log
  182. tail -n0 -f /usr/local/apache/logs/error_log | grep 192.185.1.20
  183. Job Control, with an example:
  184. *** to execute a command in the background:
  185. tail -n0 -f /usr/local/apache/logs/error_log &
  186. *** list jobs:
  187. jobs -l
  188. *** to bring a running job to the foreground:
  189. fg ${number_here}
  190. *** Example:
  191. fg 1
  192. *** Seen bellow:
  193. root@ja30 [/home/blackest/public_html]# tail -n0 -f /usr/local/apache/logs/error_log &
  194. [2] 15462
  195. root@ja30 [/home/blackest/public_html]# fg 2
  196. Examples of useful uapi commands:
  197. uapi Mysql create_database name=peachlet_hgadmin
  198. uapi Mysql create_user name=peachlet_hgadmin password=pass101x
  199. uapi Mysql set_privileges_on_database user=peachlet_hgadmin database=peachlet_hgadmin privileges=ALL%20PRIVILEGES
  200. https://vim-adventures.com/
  201. (PULL)
  202. rsync –dry-run -avpP -essh -i transfer_key” root@$server_ip:/home/saber/public_html/blog ~+/source/thekingofknights.com/
  203. export db:
  204. mysqldump -p -u peachlet_admin peachlet_admin > /home/peachlet/peachlet_admin.$(date +%s).sql
  205. import db:
  206. mysql -p -u peachlet_admin peachlet_w1 < peachlet_admin.1546890570.sql
  207. ^^^^^^ MAKE COPY OF DB BEFORE IMPORTS
  208. linux survival
  209. cmdchallenge.com
  210. bash common commands
  211. grep, awk, sed , printenv, cd, mv, cp, rm, rmdir, mkdir, touch, echo, export, import, bind, lsattr, ls, chmod, stat, host, nslookup , df -h, tail,
  212. eigsh common commands
  213. ui, dig bandecoffee.net , host -t mx bandecoffee.ne, dig, ipid, whois, du, wpinfo, pwtemp, logtail, loggrep, whois, ping, traceroute, vps
  214. eigsh@wizard2 > help
  215. account:
  216. abusetool [server] will enable or disable all cpanel/sites/emails/crons under a specified account in either the system, apache, exim or outbounding scripts
  217. backupdu Prints disk usage of a Dedi/VPSs cPanel backup directory
  218. bluri will block or unblock specified URI via mod_rewrite in domain’s document root .htaccess file.
  219. bui [] display domain/account billing information
  220. checkcancel displays last cPanel and FTP login times for an account
  221. checkrestrictions [server] shows all montool restrictions on account
  222. cloudsearch Looks up information for a cloudsites account.
  223. countproc [server] check current number of processes for a user
  224. dcv returns possible dcv email addresses for a domain
  225. dedireset reset the root password for a dedicated server
  226. domlist lists domains for a user
  227. gatorlookup checks if a specified domain or email address is a GATOR customer (the sitebuilder product)
  228. inodes shows a breakdown of inodes based on a path
  229. killproc kill all current processes for a user
  230. legalrestrict [server] chmod and chattrs a customers homedirectory
  231. ncdu [server] generates an explorable directory tree by size in a users homedir
  232. openport opens a port outbound globally on a server
  233. overselltemp [server] will set a reseller to be able to oversell temporarily for 24 hours
  234. restrict [server] htpasswd restricts customer account
  235. resusage print the resellers current disk and bandwith usage/limit
  236. searchcpanel [server] search cPanel access logs
  237. skipbackup skips next backup for an account
  238. sloptout [server] Opts a user out from regular sitelock scanning
  239. suspbackup creates a user accessible backup
  240. testlogin test the password of the account against the given information
  241. toswhitelist [server] white lists a customer IP against a TOS restricted account
  242. ui [server] display domain/account information
  243. unrestrict [server] removes htpasswd restrictions on customer account
  244. unsuspend unsuspend a user
  245. apache:
  246. apachegrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  247. apachelog This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  248. apacherestart restarts apache
  249. apachetail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  250. awstats [number of top results] displays the top number of sites/traffic via the customers awstats logs. Specifying 0 will provide this months stats.
  251. cachectl enable or disable caching for a users account
  252. checkautossl check a user’s AutoSSL configuration
  253. 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)
  254. createinfo create a phpinfo page in the users public_html dir
  255. createini create a modifiable php.ini in the users home dir
  256. disableuserdir [1] disables userdir for a user, optional input tells the script whether or not the changes should be applied immediately
  257. edithtaccess allows one to edit an .htaccess in a users account
  258. editini find and optionally edit all php.inis for a domain
  259. phpallow <52|53|54|55|56|70|71|all> allow user to select deprecated version of PHP
  260. phphandler <52|53|54|55|56|70|71|stable|edge|strip> updates a domains htaccess to use the specified php version
  261. phpvers displays all php versions installed on specified server
  262. purgecache removes cache for a provided domain from the caching layer
  263. purgecacheuser purges the cache on all domains for the specified user
  264. scoreboard check concurrent apache connections for a server
  265. sitereport performs a variety of account checks and reports problems
  266. sslinfo [server] print ssl information for all domains under an account
  267. uf display all vhosts matching the the domain
  268. whitelist whitelist a domain for certain mod_security rules
  269. cpanel:
  270. accounting This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  271. bwu display bandwidth usage information for a user or reseller (plus sub accounts)
  272. changepackage [aluminum|copper|silver|gold|diamond|hatchling|baby|business|hatchling_unlimited|baby_unlimited|business_unlimited] change package of a shared/reseller account
  273. checkbackup [server] displays the status of a users backups
  274. checkbackupvps check for backups on VPS servers
  275. checkips runs a check against used dedicated IPs to ensure theyre being used properly
  276. checkrescancel displays last cPanel and FTP login times for a reseller and resold
  277. cphulkdblacklist blacklists an IP in cphulkd
  278. cphulkdwhitelist whitelists an IP in cphulkd
  279. cpkeyupdate runs /usr/local/cpanel/cpkeyclt to update cPanel license
  280. fantfix fixes “script already installed” bug in fantastico for a user
  281. ftplog This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  282. getpasswsp prints the WSP login
  283. ipdedi shows information regarding dedi ip usage for a domain
  284. iskilled runs iskilled against a specified domain
  285. jailshell [port] enables jailshell for the specified clients account
  286. killgrep search through kill logs
  287. logingrep greps the cphulkd and cPanel logs for user failed logins and blocks
  288. oi shows detailed information about a domain from the server
  289. permfix [server] resets permissions on public_html and all subfiles/folders for a user
  290. pwreset changes password for a user to a random password
  291. 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
  292. qifix fixes common issues with quickinstall and missing perl modules
  293. quota check current quota for a user. (includes inodes)
  294. resetcpanel this will reset the account as it was on day 1 with a new password
  295. resipcheck print a list of accounts with dedicated ips
  296. themeset [server] set theme for a cpanel user. options: x x3 rvskin
  297. dns:
  298. addptr adds or updates ptr for IP
  299. checkzone provides information about a domain
  300. dig [type-of-record] performs the dig command against a provided domain
  301. dkimspf enables, disables, and gets status of DKIM and SPF for a user
  302. dns prints dns information about a domain
  303. fixdediips fixes issues with arp and ips not routing properly to dedicated servers
  304. ipfix [server] fixes mismatch DNS and vhost ips
  305. ipid performs standard ip related lookups
  306. viewzone [server] views a DNS zone file for a domain
  307. whois whois a domain or IP
  308. email:
  309. addofficesrv add the sipdir and sipfed dns records required for Office365
  310. autossldisable [server] toggles a domain autossl on and off
  311. catchall toggle catchall setting for a user
  312. checkblacklist [1|true] check if an ip is on the exim blacklist, and optionally remove the block
  313. cmdelist de-lists a message from cloudmark
  314. couriergrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  315. couriertail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  316. dtoggle toggle a domain in /etc/localdomains & /etc/remotedomains
  317. ec [-h # of hours] runs ec against an account
  318. emailcheck list email accounts for a user with quota and remote / local status
  319. emailperhour [server] sets the limit of emails per hour an account can send
  320. eximclear [server] clears the mail queue for a particular user
  321. eximgrep This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  322. eximtail This command is deprecated, use loggrep/logtail instead. This command is deprecated, use loggrep/logtail instead.
  323. gapps install google apps mail/calendar for a domain
  324. godaddy install godaddy MX records into a domain
  325. hamfpinsert inserts into ham
  326. 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
  327. ftp:
  328. pwsync sync ftp/cPanel passwords
  329. testftp tests an ftp transaction against an account
  330. misc:
  331. checkfire checks the firewall and routing table to see if a customers IP has been blocked
  332. dr look for (and try to fix) errors with a server’s disaster recovery configuration
  333. dropjail [server] [port] drops into a clients jailshell – server is required when port is specified
  334. du [server] display disk and inode usage on specified server
  335. fixsb find and fix php_value mbstring in .htaccess for a user
  336. genpass [joomla|wp|md5] Will generate a random password for you, if joomla then password hash and salt is printed for insertion into database
  337. grabips lists all ips bound to a server
  338. gtmetrix runs a gtmetrix scan on target
  339. host host lookup for IP or hostname
  340. inodereport runs a server wide inode usage report for a server
  341. installfire installs the EIG Firewall onto a VPS or dedicated server
  342. installrootbin installs or updates the root bin for a vps or dedicated server
  343. loggrep searches log files for specified input
  344. logtail [search keyword] tails log files with optional grep input
  345. lsattr checks file for immutable attribute (chattr)
  346. man
  347. opens man page for a command
  348. montool provides access to some limited montool functionality
  349. mtrreport [count] traceroutes to destination using mtrs -r report. Count is a specification of -c and is optional
  350. n port scans an IP or hostname
  351. outboundwhitelist whitelists a user to be able to make outbound posts to wp-login
  352. ping [count] ping a domain until ctrl-cd or until numpings is reached
  353. quarantinelog [selection|all|timestamp] checks malware quarantine log
  354. retrace reverse traceroute, must include server
  355. status returns the status of a service running on a server
  356. top run top on a server
  357. traceroute traceroute a network location from wizard
  358. vps performs limited actions on a vps
  359. vpsupbrstatus Returns status of vps container upgrade.
  360. vpsupstatus Returns status of vps container upgrade.
  361. w display who is logged in to a server
  362. whoson [username] provides information on who is logged into specific servers
  363. wpinfo [backup file] displays wordpress information about a given site
  364. wprbl whitelist [server] whitelists a /24 IP range from being blocked by wprbl RBL checks
  365. mysql:
  366. adduserdb assigns a mysql user to a database
  367. backupdb dumps small databases into users homedirectory
  368. checksql show current mysql usage for a user
  369. mkdbuser creates a new database user
  370. myisamchk repair a database
  371. 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
  372. removedomain:
  373. removedomain [server] remove stale domain from server (generally so that a customer can add it)
  374. sales:
  375. checksni [server] tests if server supports SNI
  376. gbbannedip displays if an IP is banned from billing
  377. gencsr generates rsa csr
  378. 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
  379. security:
  380. amc runs /root/bin/amc against a directory
  381. lockdown [server] disables a service on a server for abuse tickets
  382. secinfo [server] check a domain for mod_security blocks
  383. securitylog [server] [port] parses /root/bin/security run logs
  384. transfers:
  385. swamp add account to swamp.hostgator.com system
  386.  
  387. Search for:
  388. Search …
  389. Recent Posts
  390. Welcome to the Gutenberg Editor
  391. Hello world!
  392. Recent Comments
  393. migrationmach0 on Hello world!
  394. migrationmach0 on Hello world!
  395. A WordPress Commenter on Hello world!
  396. Archives
  397. January 2019
  398. Categories
  399. Uncategorized
  400. Meta
  401. Log in
  402. Entries RSS
  403. Comments RSS
  404. WordPress.org
  405. migrationmach0, Proudly powered by WordPress.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement