-
Notifications
You must be signed in to change notification settings - Fork 4
/
Commands
596 lines (437 loc) · 21 KB
/
Commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
How to Increase Upload Size MySQL Database on cPanel with phpMyAdmin:-
----------------------------------------------------------------------
https://coolestguidesontheplanet.com/increase-upload-database-size-for-cpanel-and-phpmyadmin-server/
https://forums.cpanel.net/threads/increasing-max-upload-file-size-in-cpanel-phpmyadmin.61078/
Open command prompt as an administrator and run the following commands:-
------------------------------------------------------------------------
Net stop dnscache
Net start dnscache
ipconfig /flushdns
ipconfig /registerdns
To set privilage for reseller via command:-
-------------------------------------------
/usr/local/cpanel/scripts/fix_reseller_acls --add-default-privs --reseller <Username>
IPTables Commands
-----------------
iptables -L -nv --line-number
iptables-save > /home/iptables.savedup.rules
iptables-restore < /home/iptables.savedup.rules
magento-test-file.php for check the missing module:-
====================================================
https://gist.github.com/atomicpages/4383809
https://gist.github.com/mhhansen/9493703
How to Install node js in cpanel:-
----------------------------------
https://hostiso.com/how-to-install-setup-node-js/
ImunifyAV & 360Agent Malware report generates commands:-
---------------------------------------------------------
imunify-antivirus malware malicious list --user username --limit 500 | awk '{print $8}' > scanresult.txt
imunify360-agent malware malicious list --user username --limit 100 > /home/username/scanresult.txt
imunify360-agent malware malicious list --user username --limit 100 > /home/username/scanresult.txt
To check previous history of site :-
------------------------------------
http://web.archive.org/
To get a list of the inodes usage for every directory in the directory you are currently in, execute the following command:-
----------------------------------------------------------------------------------------------------------------------------
echo "Detailed Inodes usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
On the opened terminal page you can try using the following commands:-
----------------------------------------------------------------------
Show total Inode usage:
find . | wc -l
Inode usage for directories and files located in the current directory:
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
List of Top50 directories by the number of Inode on those directories (number of results displayed described by “head -50” value):
find . -xdev -type d -exec sh -c 'echo "$(find "$0" | grep "^$0/[^/]*$" | wc -l) $0"' {} \; | sort -rn | head -50
To clear cache Command:-
------------------------
echo 2 > /proc/sys/vm/drop_caches ====> (To free up cache from server)
/usr/sbin/exim -bpr | grep frozen | awk '{print $3}' | xargs exim -Mrm =====> (Remove frozen mails)
kill -9 $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') --->> TO kill zombies process
cat /var/log/exim_mainlog | grep domain.com | grep "2018-08-04" | wc -l
To check large backup stored under server:-
-------------------------------------------
#find ./ -mindepth 1 -maxdepth 3 -size +1G -type f -----> (enter command under cd /home directory)
the below command to see from where the spams are initiating:-
--------------------------------------------------------------
head -1 /var/log/exim_mainlog | awk '{print $1}' ; awk '$3 ~ /^cwd/{print $3}' /var/log/exim_mainlog | sort | uniq -c | sed "s|^ *||g" | sort -nr | head --lines 15 | egrep -v ' cwd=(/$|/etc/csf|/var/spool/exim)' ; tail -1 /var/log/exim_mainlog | awk '{print From $1}'
Here is the command line which clients is sending spams by root ssh:-
---------------------------------------------------------------------
grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n
find out spamming php script using below command also:-
-------------------------------------------------------
tail -n 1000 /var/log/exim_mainlog | grep /home
------------------------------------
Login node via ssh:-
====================
1. ssh [email protected] -p 22 (login to node)
2. vzlist -a | grep IP
3. vzctl enter ID
4. csf -r
After that you can go to the /etc/hosts.allow file
and add his local IP to the list of cpanel and whm
------------------------------------
To check domain dns:-
=====================
lynx <999bazzar.in>
Database Serach command:-
=========================
grep -lr "username_"
To fix disk quota:-
===================
/scripts/fixquotas --> (To fix disk quota issue which show 0 size in whm)
To remove history from shell:-
==============================
cat /dev/null > ~/.bash_history && history -c && exit
To check database connections:-
===============================
mysqladmin processlist | grep unitech_uniman |wc -l
To generate the DKIM key for the user (DKIM, SPF):-
===================================================
# /usr/local/cpanel/bin/dkim_keys_install <Username>
# /usr/local/cpanel/bin/spf_installer <Username>
For this pdo.so error:-
Fatal error: Class 'PDO' not found in /home/username/public_html/includes/database/database.inc on line 184
put following in php.ini file:
+=================
extension="pdo.so"
extension="pdo_mysql.so"
+=================
If php files are getting downloaded instead of executing then put following code in .htaccess file
PHP files are downloading instead of executing
==================
AddHandler application/x-httpd-php5 .php
Apache handler
==================
Default apache handler
===============
DirectoryIndex index.php
===============
To get regular html pages to handle php code, you need to add this line to your htaccess file.
====================
AddHandler application/x-httpd-php5 .html .htm
=====================
To check default handler set on the server
=====================
grep DirectoryIndex /etc/httpd/conf/httpd.conf
=====================
---------------------------------------
To check a permission and ownership of file,folder or path of configuration file:-
----------------------------------------------------------------------------------
stat /etc/named.conf
stat <file name>
---------------------------------
WordPress compromised site clean:-
==================================
mv public_html public_html_wp_upgrade
wget https://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz
mkdir public_html
mv wordpress/* public_html/
chown username.username public_html -R
chmod 750 public_html
chgrp nobody public_html
rm -fr public_html/wp-content
mv public_html_wp_upgrade/wp-config.php public_html/
mv public_html_wp_upgrade/wp-content public_html/
mv public_html_wp_upgrade/.htaccess public_html/
mv public_html_wp_upgrade/google* public_html/
rm -fr wordpress latest.tar.gz
cd public_html;find -type f -exec chmod 644 {} \;
---------------------------------------
Delete .htaccess files From all directory:-
-------------------------------------------
find . -name \*.htaccess -type f -delete
=========================+
SSL Installation via command line:-
-----------------------------------
Example =>
=> SSL Directory - /etc/pmta/sygbo_ssl
$ openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
=> Combine the SSL Cert and Key file's to common_example.com.pem
$ cat example_com.crt example.com.key >> common_example.com.pem
e.g files format:-
common_example.com.pem
example.com.ca-bundle.pem
example_com.crt
example.com.key
=========================+
Imunify360:-
------------
wget https://repo.imunify360.cloudlinux.com/defence360/i360deploy.sh
bash i360deploy.sh
imunify360-agent register IPL
Litespeed:-
-----------
wget https://www.litespeedtech.com/packages/cpanel/lsws_whm_autoinstaller.sh
chmod a+x lsws_whm_autoinstaller.sh
./lsws_whm_autoinstaller.sh TRIAL 1 0 <username> <"password"> [email protected] 1 0
Site URL: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cpanel:auto-installer ---> (For refernce)
Update litespeed:-
------------------
/usr/local/lsws/admin/misc/lsup.sh -f -v 5.2
/etc/init.d/lsws stop/start
Tomcat service restart command:-
================================
/etc/init.d/easy-tomcat7 restart
Deleting tons of files in Linux (Argument list too long)
--------------------------------------------------------
find . -type f -print -delete
find . -name '*' | xargs rm
MySQL Issue:-
=============
basically, make a backup of your crashed tables. edit your /etc/my.cnf and add
innodb_force_recovery = 1
To restart mysql:-
==================
systemctl start mariadb.service
Replace database command:-
--------------------------
replace "http://domain.com" "https://domain.com" -- fabmake_av12.sql
sed -i -e "s/OldWord/NewWord/g" <FileName>
Command to reset from MySQL console:-
=====================================
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
To remove history from shell:-
------------------------------
cat /dev/null > ~/.bash_history && history -c && exit
nano opt. in shell:-
---------------------
nano
ctrl + w ---> search opt.
ctrl + x ----> exit and save by press y
Check load average commands:-
-----------------------------
# w
# uptime
# top
# cat /proc/loadavg
# kill -9 $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') --->> TO kill zombies process
# mysqladmin pr -------> (mysql status)
# watch mysqladmin pr -------> (mysql watch)
kill the process:-
------------------
# kill -9 PID
# killall -9 php
You can kill httpd, if Apache is consuming high resources:-
-----------------------------------------------------------
# killall -9 httpd
# /etc/init.d/httpd restart
To update cpanel license :-
---------------------------
/usr/local/cpanel/cpkeyclt
To update date and time:-
-------------------------
rdate -s rdate.cpanel.net
To update date and time:-
-------------------------
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
info.php content:-
-------------------
<? phpinfo(); ?>
Letsencrypt licence:-
---------------------
cat /etc/letsencrypt-cpanel.licence -----> (letsencrypt path)
For auditing of account:-
-------------------------
# du -sch *
# du -sch ./* | grep 'G' |sort -h |tail -5
To install Zend Optimizer:-
---------------------------
1. Login to your server via SSH
2. Run: /scripts/installzendopt
To Check SSL Certificate of website:-
-------------------------------------
curl --insecure -v https://domainname.com 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'
echo | openssl s_client -servername www.domainname.com -connect www.domainname.com:443 2>/dev/null | openssl x509 -noout -text
openssl ciphers -v | awk '{print $2}' | sort | uniq
Server Load Commands:-
======================
Check the number of connections from an IP address currently connected to the server:-
--------------------------------------------------------------------------------------
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
netstat -nap | grep :443 |wc -l ======> To check IP connection.
netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n ====> (To check Ip connection on server)
Below is an Unix command to list all the IP addresses connected to your server on port 80:-
===========================================================================================
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
To find unique IP addresses of Apache web server, use:- =====> (Doc Link: https://www.tecmint.com/find-top-ip-address-accessing-apache-web-server/)
=======================================================
awk '{print $1}' /var/log/apache2/access.log | sort | uniq -c | sort -nr | head -10
To find unique IP addresses of the Nginx web server, use:-
==========================================================
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head -10
Alternatively, you can make use of the grep command to filter the access log for a specific time range or pattern matching.
grep "2023-10-10 12:00" /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -10
Restore the backup commands:-
-----------------------------
rsync -a /path/to/backup /path/to/restored/folder ===> (Restore the backup of account)
tar -zcvf tar-archive-name.tar.gz source-folder-name
tar -zcf filename.tar.gz
tar -xvf homedir.tar ===> (To untar in SSH)
tar -tvf file.tar ===> (To view the files in tar.gz)
link : http://www.cyberciti.biz/faq/list-the-contents-of-a-tar-or-targz-file/
link : http://www.cyberciti.biz/faq/tar-extract-linux/
To suspend the account :-
-------------------------
/scripts/suspendacct username "reason" ===> (To suspend the account)
/scripts/unsuspendacct username ===> (To unsuspend the account)
/scripts/killacct username ===> (To completely terminate the account from server)
Backup Script Command:-
-----------------------
/scripts/restorepkg --force fullpath&namefilebackup
/scripts/pkgacct <username> (To create backup)
/usr/local/cpanel/bin/backup --force (I found a command to force a backup of all accounts using the new backup system)
rsync --progress -a sourceDirectory destinationDirectory
rsync -avh --progress sourceDirectory destinationDirectory
pv my_big_file > backup/my_big_file
CSF command :-
--------------
csf -g ===> (IP to check ofr IP block)
csf -dr ===> (IP to remove IP from block list)
csf -r ===> (To restart firewall)
csf -a ===> (To accept IP)
csf -x ===> (To disable firwall)
grep -rl IPADDRESS /var/lib//mysql/cphulkd/ ===> (Check Ip address in cPhulk )
grep 106.211.64.120 /var/log/maillog | grep -i fail
grep 106.211.3.72 /usr/local/cpanel/logs/login_log
grep 123.123.123.123 /var/log/exim_mainlog | grep set_id
https://serversitters.com/deciphering-csf-blocked-messages.html
To correct the files/directory permissions inside public_html directory
======================
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
======================
Cronjob Command :-
------------------
crontab -e
crontab -u username -l
WHMCS Cron run via script:-
---------------------------
/opt/cpanel/ea-php71/root/usr/bin/php -q /home/username/whmcsdata/crons/cron.php all -F -vvv
/usr/local/bin/ea-php56 -q /home/username/public_html/artisan schedule all -F -vvv
php -q /home/username/public_html/billing/crons/cron.php all -F -vvv
maldet scan:-
-------------
maldet -a /home/username/ ===> (To scan a specific user's home directory)
maldet -a /home/username/public_html/ ===> (To scan a specific user's home & public_html directory)
maldet -b --scan-all /home?/?/public_? ===> (To scan for all user's public_html and public_ftp in all home directories)
maldet --report list ===> (List all scan reports time and SCANID)
maldet --report SCANID ===> (Show a specific report details)
grep "{scan}" /usr/local/maldetect/event_log ===> (Show all scan details from log file)
maldet -q SCANID ===> (By default the quarantine is disabled)
clamscan -ri /home/username/public_html/
To change the site URL from wp-admin backend:-
----------------------------------------------
For wp sites >> go wp-admin >> setting >> general >> site URL
To check Email:-
----------------
# exim -bpc ---> to view the number of emails in the queue
# exim -bp ---> emails that are currently in queue
/usr/sbin/exim -bpr | grep “<” | wc -l ---> Number of emails in the que
/usr/sbin/exim -bpr | grep frozen | wc -l ---> How many Frozen mails on the queue
exim -bpr | grep "<>" | awk '{print $3}' | xargs exim -Mrm -----> remove the fail email from server
/usr/sbin/exim -bpr | grep frozen | awk '{print $3}' | xargs exim -Mrm ---> Deleteing Frozen Messages
TO check mails :-
-----------------
exim -bpc
exim -Mvh mail-id
exim -Mvb mail-id
tail -f /var/log/exim_mainlog | grep domain_name ===> (For mail delivery monitoring purposes, you may execute this command)
grep [**] /var/log/exim_mainlog
vi /etc/remotedomains ===> (To add the domain_name in list)
tail -f /var/log/maillog ===> (To view mailbox you can use mail command)
grep something /var/log/maillog
exigrep [email protected] /var/log/exim_mainlog ===> (To check the sent email status)
To check mail logs:-
--------------------
#cat /var/log/exim_mainlog
#exigrep example.com /var/log/exim_mainlog
#grep [email protected] /usr/local/psa/var/log/maillog |more
#tail -f /usr/local/psa/var/log/maillog
Restart Command:-
-----------------
/etc/init.d/service restart ===> (stop, start, status by using service)
systemctl restart service ===> (stop, start, status by using service)
service <service> restart ===> (stop, start, status by using service)
/script/restartsrv_service ===> (stop, start, status by using service)
If Webmail.domainname.TLD is showing default page then do following:-
---------------------------------------------------------------------
Go to WHM >> Main >> Server Configuration >> Tweak Settings >> serach for "proxy subdomains" >> ON
Roundcube database error:- ------> (DATABASE ERROR: CONNECTION FAILED!)
==========================
rpm -e --nodeps cpanel-roundcubemail
/usr/local/cpanel/scripts/check_cpanel_rpms --fix
/usr/local/cpanel/bin/update-roundcube-sqlite-db --force
IP blacklist check URL:-
------------------------
link : http://www.blacklistalert.org/
link : http://whatismyipaddress.com/blacklist-check
link : http://www.mxtoolbox.com/blacklists.aspx
Access Apache logs:-
--------------------------------------
cat /usr/local/apache/access_log | grep <ip> | wc -l
-------------------
chattr code for .htaccess:-
===========================
chattr +aiu .htaccess
Set chatter to all files/folder inside folder:-
===============================================
chattr -R +aui public_html/
to remove chatter:-
===================
chattr -R -aui public_html/
-------------------
To check a permission and ownership of file,folder or path of configuration file:-
----------------------------------------------------------------------------------
stat /etc/named.conf
stat <file name>
how to increase phpmyadmin import file size :-
-----------------------------------------------
pico /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
post_max_size = 55M
upload_max_filesize = 55M
To block country IP:-
---------------------
go to configure firewall >> seach for cc_deny and put country code there and update
All country code link : http://webstore.lexi.com/s.nl/ctype.KB/it.I/id.378/KB.3234/.f
cloudlinux documentation:-
--------------------------
Read this 4 times
link : http://docs.cloudlinux.com/index.html?cagefs.html
--------------------------------------------------------------------------------------------------
inode commands :-
-----------------
1) For dedicated customers you can check the inodes of an account on your server by using SSH:
=> quota -s <cpanel username>
2) If you have SSH access to your account you can view the inodes for a specific folder using the
following command:
=> echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf"$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
3) To display inode in the stats of Cpanel account
=> WHM -> Tweak Settings -> "Display File Usage information in the cPanel stats bar (inode count)"
----------------------------------------------------------------------------------------------------
Bitninja SSL issue:-
====================
Recently there was an issue on divine, where SSL on domain names was showing SSL mismatch error. Restarting bitninja used to fix the issue.
However, permanent fix is to apply commands below on the server. This is when newly installed SSL shows Certificate mismatch error
------------------------------+
rm -f /opt/bitninja-ssl-termination/etc/haproxy/certs/*
rm -f /opt/bitninja-ssl-termination/etc/haproxy/cert-list.lst
rm -f /opt/bitninja-ssl-termination/etc/haproxy/haproxy.cfg
bitninjacli --module=SslTerminating --regenerate
bitninjacli --module=SslTerminating --reload
------------------------------+
To remove all the install which has been perform on server:- ----> (Make a clean vps server)
============================================================
yum history list|awk '$1 ~ /[0-9]+/ {print $1}'| while read a; do yum history undo -y $a; done
==============+
** To change the PHP Version
$ update-alternatives --config php
select php version and ennter
$ a2dismod php7.2
$ systemctl restart apache2
$ a2enmod php5.6
$ systemctl restart apache2
==============+
*************************************************************************************