Difference between revisions of "Useful commands"

From Realm Business Systems Ltd
Jump to: navigation, search
(SME)
(APC)
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
===SME===
+
=== SME ===
  
SME Check added RPM's
+
Check added RPM's
 
  /sbin/e-smith/audittools/newrpms
 
  /sbin/e-smith/audittools/newrpms
 +
/sbin/e-smith/audittools/newrpms | grep smeserver
  
SME Check templates
+
Check RPM's
 +
rpm -qa smeserver* | sort -d
 +
rpm -qa e-smith* | sort -d
 +
 
 +
Check templates
 
  /sbin/e-smith/audittools/templates
 
  /sbin/e-smith/audittools/templates
  
SME RPM initial install date
+
RPM initial install date
 
  rpm -qa --last | grep -v "initial install date"
 
  rpm -qa --last | grep -v "initial install date"
  
SME Check Repositories  http://wiki.contribs.org/SME_Server:Adding_Software
+
Check Repositories  http://wiki.contribs.org/SME_Server:Adding_Software
 
  /sbin/e-smith/audittools/repositories
 
  /sbin/e-smith/audittools/repositories
  
SME List Repositories
+
List Repositories
 
  db yum_repositories show
 
  db yum_repositories show
 
  cat /home/e-smith/db/yum_repositories
 
  cat /home/e-smith/db/yum_repositories
  
Restoring Default Yum Repositories; Remove the current values and restore the original setting with these commands
+
Restore Default Yum Repositories
 
  cd /home/e-smith/db/
 
  cd /home/e-smith/db/
 
  mv yum_repositories yum_repositories.po
 
  mv yum_repositories yum_repositories.po
 +
 
  /etc/e-smith/events/actions/initialize-default-databases
 
  /etc/e-smith/events/actions/initialize-default-databases
 +
 
  signal-event yum-modify
 
  signal-event yum-modify
  yum --enablerepo=* clean all
+
 +
  yum update
  
 
Yum; There are unfinished transactions remaining
 
Yum; There are unfinished transactions remaining
Line 29: Line 37:
 
  yum-complete-transaction --cleanup-only
 
  yum-complete-transaction --cleanup-only
  
SME Check RPM Package owning FILE
+
Check RPM Package owning FILE
 
  rpm -qf /usr/bin/nmap
 
  rpm -qf /usr/bin/nmap
  
Line 51: Line 59:
 
  nmap -p 42526 -sT -P0 <domain>
 
  nmap -p 42526 -sT -P0 <domain>
  
unzip
+
Squid Log Date
  tar -xvf xxx.tar
+
  perl -pe 's/[\d\.]+/localtime($&)/e' /var/log/squid/access.log
tar -zxvf xxx.tar.gz
+
unzip xxx.zip
+
bunzip2 xxx.bz2
+
bzip2 -d xxx.bz2
+
  
tar create
+
Check Apache modules loaded;
  tar -zcvf archive-name.tar.gz (/directory-name/)file(s)
+
  apachectl -t -D DUMP_MODULES
 
+
scp
+
scp -rp -P 44 root@192.168.1.1:/.../filename .
+
 
+
rsync
+
rsync -aH /affa/smesvr /media/affa/affa/
+
rsync -aHvzhe ssh --progress root@10.10.15.1:/var/affa/archive /var/affa/
+
rsync -avzhe "ssh -p 22222" --progress root@123.45.67.89:/mnt/backups/dump/vzdump-qemu-101-2021_09_25-00_00_09.vma.zst /mnt/4TB1/abc
+
 
+
 
+
.bashrc
+
PS1="\[\e[31m\]\h:\w#\[\e[m\] "
+
PS1="\[\e[32m\]\h:\w#\[\e[m\] "
+
PS1="\[\e[36m\]\h:\w#\[\e[m\] "
+
 
+
Processor info
+
cat /proc/cpuinfo
+
 
+
Software RAID status
+
cat /proc/mdstat
+
  
 
Custom Network
 
Custom Network
 
  config setprop ExternalInterface EthtoolOpts "speed 10 duplex full autoneg off"
 
  config setprop ExternalInterface EthtoolOpts "speed 10 duplex full autoneg off"
  
Linux check maximum MTU
+
Server Default Backup List
ping -M do -s 1434 google.co.uk
+
Windows check maximum MTU
+
ping google.co.uk -f -l 1434
+
 
+
SME Server Default Backup List
+
 
  perl -e 'use esmith::Backup;$b=new esmith::Backup;print join("\n",$b->restore_list)."\n"'
 
  perl -e 'use esmith::Backup;$b=new esmith::Backup;print join("\n",$b->restore_list)."\n"'
  
SME Server Reset Initial Restore
+
Server Reset Initial Restore
 
  config delete PasswordSet
 
  config delete PasswordSet
 
  config setprop bootstrap-console Run Yes
 
  config setprop bootstrap-console Run Yes
Line 105: Line 84:
 
  cd /home/e-smith/files/ibays/redirect/html
 
  cd /home/e-smith/files/ibays/redirect/html
 
  vim .htaccess
 
  vim .htaccess
 
 
  Redirect 301 / http://www.domain.com/
 
  Redirect 301 / http://www.domain.com/
 
Set domain to redirect ibay
 
  
 +
Disable mail to a user from an external network
 +
db accounts setprop groupname/username Visible internal
 +
signal-event email-update
  
 
Disable the check for the Date header on the internal interface:
 
Disable the check for the Date header on the internal interface:
Line 126: Line 105:
 
     $OUT .= " $days" if ($days);
 
     $OUT .= " $days" if ($days);
 
  }
 
  }
 
  
 
Disable the check for the Date header on the external interface:
 
Disable the check for the Date header on the external interface:
Line 133: Line 111:
 
  echo "# 17check_basicheaders disabled by custom template" > 17check_basicheaders
 
  echo "# 17check_basicheaders disabled by custom template" > 17check_basicheaders
 
  signal-event email-update
 
  signal-event email-update
 
  
 
cat /etc/e-smith/templates/var/service/qpsmtpd/config/peers/0/17check_basicheaders
 
cat /etc/e-smith/templates/var/service/qpsmtpd/config/peers/0/17check_basicheaders
Line 145: Line 122:
 
  }
 
  }
  
Disable mail to a user from an external network
+
List contents of queued email
db accounts setprop groupname/username Visible internal
+
signal-event email-update
+
 
+
Symbolic link
+
ln -s /path-to-folder(file) foldername(filename)
+
 
+
SME - List contents of queued email
+
 
  # /var/qmail/bin/qmail-qread
 
  # /var/qmail/bin/qmail-qread
 
  14 Dec 2014 03:35:51 GMT  #165184302  2886
 
  14 Dec 2014 03:35:51 GMT  #165184302  2886
 
  # find /var/qmail/queue -name 165184302| xargs cat | less
 
  # find /var/qmail/queue -name 165184302| xargs cat | less
  
SME qmail retry period before return e-mail as undeliverable, default is 604800 seconds = 1 week, 172800 seconds = 2 days
+
Qmail retry period before return e-mail as undeliverable
 +
default is 604800 seconds = 1 week, 172800 seconds = 2 days
 
  mkdir -p /etc/e-smith/templates-custom/var/qmail/control
 
  mkdir -p /etc/e-smith/templates-custom/var/qmail/control
 
  echo 172800 > /etc/e-smith/templates-custom/var/qmail/control/queuelifetime
 
  echo 172800 > /etc/e-smith/templates-custom/var/qmail/control/queuelifetime
Line 163: Line 134:
 
  sv t qmail
 
  sv t qmail
  
 +
=== unzip ===
 +
tar -xvf xxx.tar
 +
tar -zxvf xxx.tar.gz
 +
unzip xxx.zip
 +
bunzip2 xxx.bz2
 +
bzip2 -d xxx.bz2
 +
 +
=== tar create ===
 +
tar -zcvf archive-name.tar.gz (/directory-name/)file(s)
 +
 +
=== scp ===
 +
scp -rp -P 44 root@192.168.1.1:/.../filename .
 +
 +
=== rsync ===
 +
rsync -aH /affa/smesvr /media/affa/affa/
 +
rsync -aHvzhe ssh --progress root@10.10.15.1:/var/affa/archive /var/affa/
 +
rsync -avzhe "ssh -p 22222" --progress root@123.45.67.89:/mnt/backups/dump/vzdump-qemu-101-2021_09_25-00_00_09.vma.zst /mnt/4TB1/abc
 +
rsync -avzhe "ssh -p 22222" --progress --partial root@123.45.67.89:/mnt/mirror1/dump/fri/SAGESVR.qcow2 /media/owner/WEEKLY/abc
 +
 +
=== .bashrc ===
 +
PS1="\[\e[30m\]\h:\w#\[\e[m\] "        BLACK
 +
PS1="\[\e[31m\]\h:\w#\[\e[m\] "        RED
 +
PS1="\[\e[32m\]\h:\w#\[\e[m\] "        GREEN
 +
PS1="\[\e[34m\]\h:\w#\[\e[m\] "        BLUE
 +
PS1="\[\e[36m\]\h:\w#\[\e[m\] "        CYAN
 +
 +
export HISTTIMEFORMAT="%d%m%y %T "
 +
 +
Processor info
 +
cat /proc/cpuinfo
  
The public key is a one-line text file - you can transfer it from the affa server to the target server
+
Software RAID status
 +
cat /proc/mdstat
 +
 
 +
Linux check maximum MTU
 +
ping -M do -s 1434 google.co.uk
 +
 
 +
Windows check maximum MTU
 +
ping google.co.uk -f -l 1434
 +
 
 +
=== Symbolic link ===
 +
ln -s /path-to-folder(file) foldername(filename)
 +
 
 +
=== Public key ===
 
  on the HOST server:
 
  on the HOST server:
 
  affa --send-key targetsvr
 
  affa --send-key targetsvr
Line 171: Line 184:
 
   
 
   
 
  cat /root/.ssh/id_rsa.pub
 
  cat /root/.ssh/id_rsa.pub
 
+
 
  on the TARGET server: add  
 
  on the TARGET server: add  
 
  mkdir -p /root/.ssh
 
  mkdir -p /root/.ssh
 
  cd /root/.ssh
 
  cd /root/.ssh
  vim authorized_keys2
+
  vim authorized_keys
 
   
 
   
 
  config setprop sshd PasswordAuthentication no
 
  config setprop sshd PasswordAuthentication no
Line 181: Line 194:
 
  config show sshd
 
  config show sshd
  
Squid Log Date
+
=== MySQL ===
perl -pe 's/[\d\.]+/localtime($&)/e' /var/log/squid/access.log
+
 
+
Check Apache modules loaded;
+
apachectl -t -D DUMP_MODULES
+
 
+
===MySQL===
+
 
  mysql
 
  mysql
 
  use icinga
 
  use icinga
Line 200: Line 207:
 
  mysql -u root -p wcuk < wcuk.sql
 
  mysql -u root -p wcuk < wcuk.sql
  
===APC===
+
=== APC ===
 
Update BATTDATE to the current date.
 
Update BATTDATE to the current date.
 
  Kill the apcupsd daemon first, Run apctest to update the UPS eeprom.
 
  Kill the apcupsd daemon first, Run apctest to update the UPS eeprom.
  
 
+
Debian;
DEBIAN;
+
  apt install apcupsd
  apt-get install apcupsd apcupsd-cgi
+
 
  vim /etc/apcupsd/apcupsd.conf
 
  vim /etc/apcupsd/apcupsd.conf
 
  vim /etc/default/apcupsd
 
  vim /etc/default/apcupsd
 +
systemctl restart apcupsd.service
 +
 
  cd /etc/init.d/
 
  cd /etc/init.d/
 
  ./apcupsd start
 
  ./apcupsd start
Line 246: Line 254:
 
  additional package removed gcc
 
  additional package removed gcc
  
===IPv6===
+
IPv6
http://www.tldp.org/HOWTO/html_single/Linux+IPv6-HOWTO/
+
 
  ipv4="192.168.0.1"; sla="5"; printf "2002:%02x%02x:%02x%02x:%04x::1" `echo $ipv4 | tr "." " "` $sla
 
  ipv4="192.168.0.1"; sla="5"; printf "2002:%02x%02x:%02x%02x:%04x::1" `echo $ipv4 | tr "." " "` $sla
  
===Vigor===
+
=== Vigor ===
 
vigor sip_alg
 
vigor sip_alg
 
  sys sip_alg ?
 
  sys sip_alg ?
Line 262: Line 269:
 
  WAN / General Setup / VLAN Tag Insertion = Enable / Tag Value = 101
 
  WAN / General Setup / VLAN Tag Insertion = Enable / Tag Value = 101
  
===vTiger===
+
vTiger
 
vTiger delete demo data SQL command
 
vTiger delete demo data SQL command
 
  update vtiger_crmentity set deleted = 1
 
  update vtiger_crmentity set deleted = 1

Latest revision as of 06:48, 22 July 2023

SME

Check added RPM's

/sbin/e-smith/audittools/newrpms
/sbin/e-smith/audittools/newrpms | grep smeserver

Check RPM's

rpm -qa smeserver* | sort -d
rpm -qa e-smith* | sort -d

Check templates

/sbin/e-smith/audittools/templates

RPM initial install date

rpm -qa --last | grep -v "initial install date"

Check Repositories http://wiki.contribs.org/SME_Server:Adding_Software

/sbin/e-smith/audittools/repositories

List Repositories

db yum_repositories show
cat /home/e-smith/db/yum_repositories

Restore Default Yum Repositories

cd /home/e-smith/db/
mv yum_repositories yum_repositories.po

/etc/e-smith/events/actions/initialize-default-databases

signal-event yum-modify

yum update

Yum; There are unfinished transactions remaining

yum install yum-utils
yum-complete-transaction --cleanup-only

Check RPM Package owning FILE

rpm -qf /usr/bin/nmap

RPM erase single package

rpm -e --nodeps xxx

Check Domain

host -t mx <domain>
host -t a <domain>
host -t soa <domain>
host -t txt <domain>
host -t ns <domain>
host -t txt _dmarc.<domain>
host -t txt default._domainkey.<domain>

Network packet capture and test

tcpdump
tcpdump -i eth1 port 42526 -v
tcpdump -i br0 port 42526 -v
nmap -p 42526 -sU -P0 <domain>
nmap -p 42526 -sT -P0 <domain>

Squid Log Date

perl -pe 's/[\d\.]+/localtime($&)/e' /var/log/squid/access.log

Check Apache modules loaded;

apachectl -t -D DUMP_MODULES

Custom Network

config setprop ExternalInterface EthtoolOpts "speed 10 duplex full autoneg off"

Server Default Backup List

perl -e 'use esmith::Backup;$b=new esmith::Backup;print join("\n",$b->restore_list)."\n"'

Server Reset Initial Restore

config delete PasswordSet
config setprop bootstrap-console Run Yes
signal-event reboot

Redirect website

create redirect ibay 
db accounts setprop redirect AllowOverride all
db accounts setprop redirect FollowSymLinks enabled
signal-event ibay-modify redirect

cd /home/e-smith/files/ibays/redirect/html
vim .htaccess
Redirect 301 / http://www.domain.com/

Disable mail to a user from an external network

db accounts setprop groupname/username Visible internal
signal-event email-update

Disable the check for the Date header on the internal interface:

mkdir -p /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/local
cd /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/local
echo "# 17check_basicheaders disabled by custom template" > 17check_basicheaders
signal-event email-update

cat /etc/e-smith/templates/var/service/qpsmtpd/config/plugins/17check_basicheaders

{
    $OUT = "check_basicheaders";

    # Note: You can't specify a maximum offset of 0 days, but that's fair
    my $days = $smtpd{MaximumDateOffset} || ;

    $OUT .= " $days" if ($days);
}

Disable the check for the Date header on the external interface:

mkdir -p /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0
cd /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0
echo "# 17check_basicheaders disabled by custom template" > 17check_basicheaders
signal-event email-update

cat /etc/e-smith/templates/var/service/qpsmtpd/config/peers/0/17check_basicheaders

{
    $OUT = "check_basicheaders";

    # Note: You can't specify a maximum offset of 0 days, but that's fair
    my $days = $smtpd{MaximumDateOffset} || ;

    $OUT .= " $days" if ($days);
}

List contents of queued email

# /var/qmail/bin/qmail-qread
14 Dec 2014 03:35:51 GMT  #165184302  2886
# find /var/qmail/queue -name 165184302| xargs cat | less

Qmail retry period before return e-mail as undeliverable

default is 604800 seconds = 1 week, 172800 seconds = 2 days
mkdir -p /etc/e-smith/templates-custom/var/qmail/control
echo 172800 > /etc/e-smith/templates-custom/var/qmail/control/queuelifetime
expand-template /var/qmail/control/queuelifetime
sv t qmail

unzip

tar -xvf xxx.tar
tar -zxvf xxx.tar.gz
unzip xxx.zip
bunzip2 xxx.bz2
bzip2 -d xxx.bz2

tar create

tar -zcvf archive-name.tar.gz (/directory-name/)file(s)

scp

scp -rp -P 44 root@192.168.1.1:/.../filename .

rsync

rsync -aH /affa/smesvr /media/affa/affa/
rsync -aHvzhe ssh --progress root@10.10.15.1:/var/affa/archive /var/affa/
rsync -avzhe "ssh -p 22222" --progress root@123.45.67.89:/mnt/backups/dump/vzdump-qemu-101-2021_09_25-00_00_09.vma.zst /mnt/4TB1/abc
rsync -avzhe "ssh -p 22222" --progress --partial root@123.45.67.89:/mnt/mirror1/dump/fri/SAGESVR.qcow2 /media/owner/WEEKLY/abc

.bashrc

PS1="\[\e[30m\]\h:\w#\[\e[m\] "         BLACK
PS1="\[\e[31m\]\h:\w#\[\e[m\] "         RED
PS1="\[\e[32m\]\h:\w#\[\e[m\] "         GREEN 
PS1="\[\e[34m\]\h:\w#\[\e[m\] "         BLUE
PS1="\[\e[36m\]\h:\w#\[\e[m\] "         CYAN

export HISTTIMEFORMAT="%d%m%y %T "

Processor info

cat /proc/cpuinfo

Software RAID status

cat /proc/mdstat

Linux check maximum MTU

ping -M do -s 1434 google.co.uk

Windows check maximum MTU

ping google.co.uk -f -l 1434

Symbolic link

ln -s /path-to-folder(file) foldername(filename)

Public key

on the HOST server:
affa --send-key targetsvr
ssh-keygen -t ed25519
ssh-keygen -t rsa

cat /root/.ssh/id_rsa.pub

on the TARGET server: add 
mkdir -p /root/.ssh
cd /root/.ssh
vim authorized_keys

config setprop sshd PasswordAuthentication no
signal-event remoteaccess-update
config show sshd

MySQL

mysql
use icinga
REPAIR TABLE icinga_hoststatus;
REPAIR TABLE icinga_logentries;
\q

/etc/init.d/icinga stop
mysqlcheck --databases icinga

Restore mysql db

mysql -u root -p wcuk < wcuk.sql

APC

Update BATTDATE to the current date.

Kill the apcupsd daemon first, Run apctest to update the UPS eeprom.

Debian;

apt install apcupsd
vim /etc/apcupsd/apcupsd.conf
vim /etc/default/apcupsd
systemctl restart apcupsd.service
cd /etc/init.d/
./apcupsd start
http://www.apcupsd.com/manual/manual.html#red-hat-systems

Compile

SME;
yum install gcc gcc-c++
yum remove gcc gcc-c++

http://sourceforge.net/projects/apcupsd/files/latest/download?source=files

gunzip apcupsd-3.14.13.tar.gz
tar -xvf apcupsd-3.14.13.tar 
cd apcupsd-3.14.13
./configure --help
./configure --enable-usb
make
make install

DEBIAN;
apt-get install g++
apt-get install make
./configure --enable-usb
make
make install
vim /etc/apcupsd/apcupsd.conf
cd /etc/init.d
./apcupsd status
./apcupsd start
./apcupsd status

aptitude remove make
aptitude remove g++

additional package removed gcc

IPv6

ipv4="192.168.0.1"; sla="5"; printf "2002:%02x%02x:%02x%02x:%04x::1" `echo $ipv4 | tr "." " "` $sla

Vigor

vigor sip_alg

sys sip_alg ?
sys sip_alg 0
sys commit

ipsec passthrough

srv nat ipsecpass on

VDSL

WAN / General Setup / VLAN Tag Insertion = Enable / Tag Value = 101

vTiger vTiger delete demo data SQL command

update vtiger_crmentity set deleted = 1

vTiger >5.04 reset admin password to 'admin'

mysql
use <vtiger_database_name>;
update vtiger_users set user_password = 'adpexzg3FUZAk', crypt_type =  where user_name = 'admin';