Difference between revisions of "Useful commands"

From Realm Business Systems Ltd
Jump to: navigation, search
Line 166: Line 166:
  
  
 
+
=== Public key ===
=== 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:
 
  on the HOST server:
Line 180: Line 178:
 
  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
 
  signal-event remoteaccess-update
 
  signal-event remoteaccess-update
 
  config show sshd
 
  config show sshd
 
  
  
Line 204: Line 201:
 
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;

Revision as of 07:03, 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
rsync -avzhe "ssh -p 22222" --progress --partial root@123.45.67.89:/mnt/mirror1/dump/fri/SAGESVR.qcow2 /media/gary/WEEKLY/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)


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