Difference between revisions of "Useful commands"

From Realm Business Systems Ltd
Jump to: navigation, search
Line 63: Line 63:
 
  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 74: Line 74:
 
  signal-event ibay-modify redirect
 
  signal-event ibay-modify redirect
  
 
+
Disable mail to a user from an external network
 
+
  db accounts setprop groupname/username Visible internal
 
+
  signal-event email-update
 
+
 
+
=== 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
+
 
+
 
+
=== .bashrc ===
+
PS1="\[\e[31m\]\h:\w#\[\e[m\] "
+
PS1="\[\e[32m\]\h:\w#\[\e[m\] "
+
PS1="\[\e[34m\]\h:\w#\[\e[m\] "
+
PS1="\[\e[36m\]\h:\w#\[\e[m\] "
+
 
+
=== 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
+
 
+
 
   
 
   
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 the check for the Date header on the internal interface: ===
+
Disable the check for the Date header on the internal interface:
 
  mkdir -p /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/local
 
  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
 
  cd /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/local
Line 141: Line 100:
  
  
=== Disable the check for the Date header on the external interface: ===
+
Disable the check for the Date header on the external interface:
 
  mkdir -p /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0
 
  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
 
  cd /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0
Line 158: Line 117:
 
  }
 
  }
  
=== 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, ===
+
Qmail retry period before return e-mail as undeliverable
 
  default is 604800 seconds = 1 week, 172800 seconds = 2 days
 
  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
Line 176: Line 128:
 
  expand-template /var/qmail/control/queuelifetime
 
  expand-template /var/qmail/control/queuelifetime
 
  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
 +
 +
 +
=== .bashrc ===
 +
PS1="\[\e[31m\]\h:\w#\[\e[m\] "
 +
PS1="\[\e[32m\]\h:\w#\[\e[m\] "
 +
PS1="\[\e[34m\]\h:\w#\[\e[m\] "
 +
PS1="\[\e[36m\]\h:\w#\[\e[m\] "
 +
 +
=== 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)
 +
  
  
Line 217: Line 218:
  
  
DEBIAN;
+
Debian;
 
  apt-get install apcupsd apcupsd-cgi
 
  apt-get install apcupsd apcupsd-cgi
 
  vim /etc/apcupsd/apcupsd.conf
 
  vim /etc/apcupsd/apcupsd.conf

Revision as of 06:58, 16 January 2023

SME

Check added RPM's

/sbin/e-smith/audittools/newrpms

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

Restoring Default Yum Repositories; Remove the current values and restore the original setting with these commands

cd /home/e-smith/db/
mv yum_repositories yum_repositories.po
/etc/e-smith/events/actions/initialize-default-databases
signal-event yum-modify
yum --enablerepo=* clean all

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

Disable mail to a user from an external network

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

cd /home/e-smith/files/ibays/redirect/html

vim .htaccess
Redirect 301 / http://www.domain.com/


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


.bashrc

PS1="\[\e[31m\]\h:\w#\[\e[m\] "
PS1="\[\e[32m\]\h:\w#\[\e[m\] "
PS1="\[\e[34m\]\h:\w#\[\e[m\] "
PS1="\[\e[36m\]\h:\w#\[\e[m\] "

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)


The public key is a one-line text file

you can transfer it from the affa server to the target server

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_keys2

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-get install apcupsd apcupsd-cgi
vim /etc/apcupsd/apcupsd.conf
vim /etc/default/apcupsd
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

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

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';