server maintenance commands

Feb 2, 03:44 AM

su command================= — 2020-01-24

su – comptonpeslonline.com —command=‘whoami’ ;

don’t forget that “crontab -e -u comptoneslonline.com” so each user can have their own crontab!

bootup commands go in /etc/rc.d/rc.local — 2015-02-16

yum —nogpg ; ## 2015-03-18 – ignore the gpg key

yum clean all ; ## 2015-04-28 – clean everything
—and/or—
for a in $(rpm —query —all ); do rpm —verify $a ; done | grep missing > rpm-results.txt ;
yum —assumeyes reinstall whatever-needed-fixing ;

=======================
server monitoring:

upTimeRobot.com – watches websites and server itself
gotSiteMonitor.com – watches the apache server
StatusCake.com

pingdom.com – watches the server 2019-01-10 – no longer FREE!
DEAD – taken over by logMeIn: monitor.us – sends daily reports
UNUSED: abbbeat.io

===============================

rebooting the server – 2013-03-11

/sbin/shutdown -r now ;
/sbin/shutdown -r now “rebooting immediately” ;
/sbin/shutdown -h ;
-h – halt
-r – reboot
-t – time in seconds

2013-02-03

postfix start ; #start postfix mail
postfix stop;
postfix status;
postfix flush ;

all mail activity goes in /var/log/maillog

vi /etc/postfix/main.cf
always_bcc = edwardsmark@gmail.com
this will send blind-carbon-copies to an email address

mailq – shows all outgoing mail in the queue

postsuper -d ALL ; ## removes all mail in the queue postsuper -d ALL deferred ; ## removes all the mail waiting in the deferred queue

blacklist test

= (re)start mysql =======

/etc/init.d/mysqld restart ;
/etc/init.d/mysqld stop ;
/etc/init.d/mysqld start ;
mysqladmin -u root password NEWPASSWORD ;

=============================

2015-07-04 – to limit the number of concurrent processes, edit

/home/DOMAIN.org/fcgi-bin/php5.fcgi

add this line:

ulimit -u 10

=============================
adrive mount commands

umount:
umount /usr/local/backup/offSiteStorage/adrive.com.interServerBackup ;

mount:
mount -t davfs https://www.adrive.com/webDAV.php /usr/local/backup/offSiteStorage/adrive.com.interServerBackup ;
=============================

syncing files across server using rsync:

rsync -ae ssh
/home/mark/virtualmin/comptonpeslonline.com/ root@199.231.184.26:/tmp/adrive/comptonpeslonline.com/ ;

rsync —archive —rsh-ssh (same as -ae)

creating a key: ssh-keygen — 2014-09-16
cat /root/.ssh/id_rsa.pub ; – copy/paste this right into adrive public key area

/usr/bin/rsync —list-only mark@edwardsmark.com@rsync.adrive.com:interServerBackup/ ; NOTICE NO LEADING SLASH after COLON ! ! ! ! interServerBackup/ is the top of the directory hierarchy.

=============================

processor usage:

ps -ef ;
ps aux ;
free; ## shows free server memory 2013-02-13
free -m; ## shows free server memory in megabytes
pstree ; shows processor status tree 2013-07-06

========================

to inspect a database: (2013-02-01)

mysqlcheck —verbose —user=mysqluser —password=mysqlpassword mysqldb ;

to repair a database:
myisamchk /var/lib/mysql/mysqldb/wp_posts.MYI ;

============

csf firewall: 2013-02-02

## Failed to start firewalld.service: Unit is masked. – new error 2018-02-28 to fix: unmask:
systemctl unmask firewalld ; ## new command !
systemctl start firewalld ;
systemctl status firewalld ;
systemctl stop firewalld ;

#vi /etc/csf/csf.conf ## for allowed IP numbers
#csf —start ; ## start firewall
#csf —stop ; ## stop firewall csf —restart ; ## 2016-05-04

#csf —status ; ## status of firewall
  1. csf -x ; ## disable firewall
  2. csf -e ; ## enable firewall csf —disable ; csf —enable ; ## stop and restart full flush
  3. iptables -L -n ; ## similar to status
/etc/csf/csf.conf — set this value to stop DoS attacks — 2013-09-29 SYNFLOOD_RATE SYNFLOOD_BURST

CONNLIMIT 80;20 — set this value to also stop DoS attacks – 2014-03-27

==

lfd ( login failure daemon) 2014-04-05

lfd stop;
lfd start;
lfd restart;

0) modify CUSTOM2_LOG to point to /var/log/virtualmin/comptonpeslonline.com_access_log
1) add line into
/usr/local/csf/bin/regex.custom.pm – custom rules for firewall, insert this perl command into the file:

  1. 22.3.226 – - [04/Apr/2014:02:01:45 0400] “POST /wp-login.php HTTP/1.0” 500 534 “” “-”
    if (($lgfile eq $config{CUSTOM2_LOG}) and ($line =~ /(S+) – - [.] “POST /wp-login.php HTTPS” [500,403]/)) { return (‘Failed wp-login.php login from ‘,$1,“wp-login.php”,“1”,“80”,“3600”);
    }

80 – port number
3600 – number of seconds to wait

2) change line in
change /etc/csf/csf.conf
CUSTOM2_LOG = “/var/log/virtualmin/comptonpesltrainers.com_access_log”

3) restart the firewall:
csf —disable ; csf —enable ;

4) monitor activity: tail -f /var/log/lfd.log ;

=============================

https://ma.ttias.be/effectively-using-detecting-the-slowloris-http-dos-tool/

mod_qos firewall settings – 2014-03-27 (UPDATED 2016-06-27) – note that QS_SrvMinDataRate is now obsolete (2016-06-27)

==
also:
iptables -v -I INPUT -p tcp —dport 443 -m connlimit —connlimit-above 50 —connlimit-mask 20 -j DROP;

yum install mos_qos ;

added this line to httpd.conf:
LoadModule qos_module /usr/lib64/httpd/modules/mod_qos.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so ## 2016-06-27

and added this to /etc/httpd/conf.d/mod_qos.conf:

## QoS Settings
QS_LocRequestLimitMatch ^/wp-login.php 5 QS_LocRequestPerSecLimitMatch ^/wp-login.php 1 # handles connections from up to 100000 different IPs QS_ClientEntries 100000 # will allow only 50 connections per IP QS_SrvMaxConnPerIP 50 # maximum number of active TCP connections is limited to 256 MaxClients 256 # disables keep-alive when 70% of the TCP connections are occupied: QS_SrvMaxConnClose 70% # minimum request/response speed (deny slow clients blocking the server, ie. slowloris keeping connections open without requesting anything): ######################## removed 2016-06-27 !! QS_SrvMinDataRate 150 1200 # and limit request header and body (careful, that limits uploads and post requests too): # LimitRequestFields 30 # QS_LimitRequestBody 102400

## 2014-03-27 added as per forum post: ## http://sourceforge.net/p/mod-qos/discussion/697421/thread/057e5cd5/ SetEnvIf Request_URI /wp-login.php QS_Limit QS_ClientEventLimitCount 20 300

http://linuxtoolkit.blogspot.com/2014/04/using-modreqtimeout-to-make-http-server.html
https://httpd.apache.org/docs/trunk/mod/mod_reqtimeout.html

cat > http://linuxtoolkit.blogspot.com/2014/04/using-modreqtimeout-to-make-http-server.html ;

RequestReadTimeout header=10-20,minrate=500 RequestReadTimeout body=10,minrate=500

now restart apache:
systemctl restart httpd.service:

==========================

===============
ftp: (2013-03-12)
.netrc (dot-netrc) – file to create an automatic FTP login – put file in your login root directory:
machine ftp.xdrive.com login foobar password foobar

=============

red5 server 2013-03-11

red5 status:
1) ps -ef | grep red5;
2) http://edwardsmarkf.com:5080

to start red5 server at boot up, put this line into /etc/rc.d/rc.local:
/etc/init.d/red5 start >/usr/share/red5/red5.log 2>&1 &

to specify how much memory red5 uses – its in the final line of /usr/share/red5/red5.sh:
exec “$JAVA” -Xms32m “$JYTHON” -Dred5.root=”${RED5_HOME}” $JAVA_OPTS -cp “${RED5_CLASSPATH}” “$RED5_MAINCLASS” $RED5_OPTS

notice -Xms32m – specifies memory size

## manually starting red5 server:
nohup /etc/init.d/red5 start >/usr/share/red5/red5.log 2>&1 &

## stopping red5 server:
# /etc/init.d/red5 stop ;
—or—
# /usr/share/red5/red5-shutdown.sh ;

======================

webmin restart: (2013-03-23)
/etc/init.d/webmin restart ;

Mark Edwards

,

---

Commenting is closed for this article.

---