Linux
How to get logs from Linux
Location
/var/log
Or
/var/logs
Other Methods
sudo tail -f /var/log/syslog
sudo less -f /var/log/syslog
sudo more -f /var/log/syslog
sudo cat /var/log/syslog
Author: Eric P
Last update: 2017-10-12 22:04
How to SSH without password
For passwordless login, hit enter when asked for password then hit enter again for default name.
mkdir .ssh #not needed in most cases
ssh-keygen -t rsa -b 4096
Or just ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub username@otherserver
If on an alternative port other than default 22
ssh-copy-id -i .ssh/id_rsa.pub "user@other-server.com" -p45343
Author: Eric P
Last update: 2017-10-15 04:03
How to delete files by date
This will delete the content of the specified folder without deleting folders, just files.
find /var/Vol1/* -mtime +29 -exec rm -f {} \;
Author: Eric P
Last update: 2017-10-12 22:09
How to backup home directory
cd /home/
find . -depth -print0 | cpio --null --sparse -pvd /backup/home/
Author: Eric P
Last update: 2017-10-12 22:11
How to Mount Windows shares from fstab
This works well on Centos
//192.168.1.50/temperature /var/www/html/hot cifs password=ASF1f02@2,username=KoocooMonster
This works for Ubuntu
//192.168.1.50/apps /media/192.168.1.50 cifs workgroup=NDS2K,password=ASF1f02@2,username=KoocooMonster 0 0
Author: Eric P
Last update: 2017-10-12 22:18
How to split large files
To split
split /media/storage1/Largefile.zip /media/APPS2/slize/export.1
To join
cat export.1* > NEWFILENAME
Author: Eric P
Last update: 2017-10-12 22:22
How to rename a file with date stamped
Assuming that you have a directory /logs
This is the actual command that runs on one of my cron jobs.
logwatch --detail=High --range=Today >/logs/watchdog.txt && mv /logs/watchdog.txt /logs/"´date +%Y-%m-%d_%H´.txt"
To rename a file
mv /logs/watchdog.txt /logs/"´date +%Y-%m-%d_%H´.txt"
OR
dt=$( date +%Y%M%d ) && cp /var/Vol1/backup/pdf_form /var/Vol1/backup/"$dt"_pdf_form ;
Author: Eric P
Last update: 2017-10-12 22:24
Squid Proxy
Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.
Thanks to Jayson for this guide
Complete Steps in Setting up UBUNTU Server 10 with SQUID 3 as a Transparent Proxy.
Step 1. Install the Ubuntu Server 10, include LAMP if you want
Step 2. Change the network interfaces from dhcp to static
sudo nano /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.250
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.88
post-up iptables-restore < /etc/iptables.up.rules
auto eth1
iface eth1 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
Step 3. Install Web Admin (webmin) (Optional)
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
dpkg –install webmin_1.510-2_all.deb
sudo apt-get -f install
https://localhost-IP ADDRES:10000
*Note Make sure you give permission to the IPTABLES ruleset to for you to access webmin over the net.
Step 4. Install ClamAV and ClamAV-freshclam
sudo apt-get install clamav clamav-freshclam
Step 5. The first step is to install squid 3
sudo apt-get install squid3
edit the squid 3 configuration file in your favorite editor
sudo nano /etc/squid3/squid.conf
and set the transparency and the allowed hosts
http_port 3128 transparent
acl our_networks src 192.168.2.0/24
acl localnet src 127.0.0.1/255.255.255.255
http_access allow our_networks
http_access allow localnet
where 192.168.2.0/24 is the IP range of local network. Probably you need to adjust the swap size
cache_dir ufs /var/spool/squid3 7000 16 256
here the first number denotes the size of cache in megabytes. Save you changes and restart the squid proxy by
sudo /etc/init.d/squid3 restart
Step 6. Edit the /etc/sysctl.conf
sudo nano /etc/sysctl.conf
Uncomment the line that enable packet forwarding for IPv4 and IPv6
Net.ipv4.ip_forward = 1
Net.ipv6.conf.all.forwarding = 1
Step 7. Edit the IPTABLE ruleset of NAT and FILTER
sudo nano /etc/iptables.up.rules
*nat
-A PREROUTING –i eth1 –p tcp –m tcp –dport 80 –j DNAT –to-destination 192.168.2.1:3128
-A PREROUTING –i eth1 –p tcp –m tcp –dport 80 –j REDIRECT –to-ports 3128
-A POSTROUTING –s 192.168.2.0/24 –o eth0 –j MASQUERADE
*filter
-A INPUT –i lo –j ACCEPT
-A INPUT –m state –i eth0 –state REALATED,ESTABLISHED –j ACCEPT
-A INPUT eth1 –j ACCEPT
-A INPUT –p tcp –m tcp –dport 22 –j ACCEPT # permit ssh using putty
-A INPUT –p tcp –m tcp –dport 10000 –j ACCEPT # permit webmin access
-A INPUT –j LOG
-A INPUT –j DROP
-A FORWARD –i eth1 –j ACCEPT
-A OUTPUT –o lo –j ACCEPT
-A OUTPUT –o eth1 –j ACCEPT
-A FOWARD –o eth1 –j ACCEPT
-A FORWARD –s 192.168.2.0/24 –o eth0 –j ACCEPT
-A FORWARD –d 192.168.2.0/24 –m state –state ESTABLISHED,REALTED –I eth0 –j ACCEPT
STEP 8. Edit rc.local
sudo nano /etc/rc.local
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 –o eth0 -j MASQUERADE
Step 9. reboot the server
Step 10. Configure the workstation for static IP Address making the LAN IP of the Ubuntu box as the gateway. Make sure that the IP Address of the workstation is within the network you setup.
Extracted from http://www.ubuntugeek.com/setting-up-ubuntu-10-04-lucid-server-with-squid-3-as-a-transparent-proxy.html
Author: Eric P
Last update: 2017-10-12 22:27
How to add remote SMTP server to Postfix
Edit 'main.cf' file, create/edit a line as follows:
Centos and Ubuntu location /etc/postfix/main.cf
relayhost = smtp.west.cox.net
Author: Eric P
Last update: 2017-10-12 22:31
How to check memory in Linux
This is helpful to see the type of memory you need to purchase, in case of upgrades or replacements.
sudo dmidecode --type 17
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.6 present.
Handle 0x0034, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 16384 MB
Form Factor: DIMM
Set: None
Locator: DIMM1_CPU1
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Samsung-00CE
Serial Number: 122AD394
Asset Tag: 031443
Part Number: M393B2G70QH0-CMA
Rank: 2
Handle 0x0036, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: DIMM3_CPU1
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 364997DC
Asset Tag: 011211
Part Number: HMT325R7CFR8C-PB
Rank: 1
Handle 0x0038, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: None
Locator: DIMM2_CPU1
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 429962C5
Asset Tag: 011218
Part Number: HMT31GR7CFR4C-PB
Rank: 2
Handle 0x003A, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: DIMM4_CPU1
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 365997F5
Asset Tag: 011211
Part Number: HMT325R7CFR8C-PB
Rank: 1
Handle 0x003C, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: None
Locator: DIMM1_CPU2
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 2C30AD87
Asset Tag: 011232
Part Number: HMT31GR7CFR4C-PB
Rank: 2
Handle 0x003E, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: DIMM3_CPU2
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 367997F5
Asset Tag: 011211
Part Number: HMT325R7CFR8C-PB
Rank: 1
Handle 0x0040, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 16384 MB
Form Factor: DIMM
Set: None
Locator: DIMM2_CPU2
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Samsung-00CE
Serial Number: 122AD346
Asset Tag: 031443
Part Number: M393B2G70QH0-CMA
Rank: 2
Handle 0x0042, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0032
Error Information Handle: No Error
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: DIMM4_CPU2
Bank Locator: Not Specified
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1067 MHz
Manufacturer: Hyundai-00AD
Serial Number: 367997DD
Asset Tag: 011211
Part Number: HMT325R7CFR8C-PB
Rank: 1
Author: Eric P
Last update: 2017-10-12 22:42
How to reset Linksys/Sipura Modems
- Dial ****73738#
- Dial 1# to confirm
Author: Eric P
Last update: 2017-10-12 23:01
How to obtain IP address from a Linksys Sipura - SPA Phones by dialing
From the Phone dial **** then press 110# - this will say the current IP
Author: Eric P
Last update: 2017-10-12 23:00
How to find the best proxy for Broadvoice sip server
Run this and select the lowest ping
ping proxy.lax.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.dca.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.mia.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.atl.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.chi.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.bos.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.nyc.broadvoice.com -i 3 -c3 >>ping.txt && cat ping.txt
-----------
PING proxy.lax.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=107 ms
--- proxy.lax.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10323ms
rtt min/avg/max/mdev = 104.382/105.642/107.827/1.573 ms
PING proxy240.dca.broadvoice.com (147.135.0.128) 56(84) bytes of data.
64 bytes from 147.135.0.128: icmp_req=1 ttl=242 time=90.9 ms
64 bytes from 147.135.0.128: icmp_req=2 ttl=242 time=160 ms
64 bytes from 147.135.0.128: icmp_req=3 ttl=242 time=92.2 ms
--- proxy240.dca.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10398ms
rtt min/avg/max/mdev = 90.959/114.509/160.352/32.420 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=72.0 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=204 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=70.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13510ms
rtt min/avg/max/mdev = 70.356/115.807/204.973/63.054 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=71.6 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=83.5 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=69.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13295ms
rtt min/avg/max/mdev = 69.373/74.843/83.552/6.225 ms
PING proxy.chi.broadvoice.com (147.135.32.221) 56(84) bytes of data.
64 bytes from 147.135.32.221: icmp_req=1 ttl=242 time=207 ms
64 bytes from 147.135.32.221: icmp_req=2 ttl=242 time=701 ms
64 bytes from 147.135.32.221: icmp_req=3 ttl=242 time=124 ms
--- proxy.chi.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 11242ms
rtt min/avg/max/mdev = 124.754/344.544/701.431/254.605 ms
PING proxy.bos.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=105 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=107 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=105 ms
--- proxy.bos.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10340ms
rtt min/avg/max/mdev = 105.190/106.172/107.374/0.943 ms
PING proxy.nyc.broadvoice.com (147.135.20.221) 56(84) bytes of data.
64 bytes from 147.135.20.221: icmp_req=1 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=2 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=3 ttl=242 time=126 ms
--- proxy.nyc.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10368ms
rtt min/avg/max/mdev = 125.297/125.955/126.629/0.616 ms
Author: Eric P
Last update: 2017-10-12 23:08
How to find the best proxy for Broadvoice sip server
Run this and select the lowest ping
ping proxy.lax.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.dca.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.mia.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.atl.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.chi.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.bos.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.nyc.broadvoice.com -i 3 -c3 >>ping.txt && cat ping.txt
-----------
PING proxy.lax.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=107 ms
--- proxy.lax.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10323ms
rtt min/avg/max/mdev = 104.382/105.642/107.827/1.573 ms
PING proxy240.dca.broadvoice.com (147.135.0.128) 56(84) bytes of data.
64 bytes from 147.135.0.128: icmp_req=1 ttl=242 time=90.9 ms
64 bytes from 147.135.0.128: icmp_req=2 ttl=242 time=160 ms
64 bytes from 147.135.0.128: icmp_req=3 ttl=242 time=92.2 ms
--- proxy240.dca.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10398ms
rtt min/avg/max/mdev = 90.959/114.509/160.352/32.420 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=72.0 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=204 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=70.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13510ms
rtt min/avg/max/mdev = 70.356/115.807/204.973/63.054 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=71.6 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=83.5 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=69.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13295ms
rtt min/avg/max/mdev = 69.373/74.843/83.552/6.225 ms
PING proxy.chi.broadvoice.com (147.135.32.221) 56(84) bytes of data.
64 bytes from 147.135.32.221: icmp_req=1 ttl=242 time=207 ms
64 bytes from 147.135.32.221: icmp_req=2 ttl=242 time=701 ms
64 bytes from 147.135.32.221: icmp_req=3 ttl=242 time=124 ms
--- proxy.chi.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 11242ms
rtt min/avg/max/mdev = 124.754/344.544/701.431/254.605 ms
PING proxy.bos.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=105 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=107 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=105 ms
--- proxy.bos.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10340ms
rtt min/avg/max/mdev = 105.190/106.172/107.374/0.943 ms
PING proxy.nyc.broadvoice.com (147.135.20.221) 56(84) bytes of data.
64 bytes from 147.135.20.221: icmp_req=1 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=2 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=3 ttl=242 time=126 ms
--- proxy.nyc.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10368ms
rtt min/avg/max/mdev = 125.297/125.955/126.629/0.616 ms
Author: Eric P
Last update: 2017-10-12 23:08
How to get Bios info
sudo dmidecode
sudo biosdecode
Handle 0x0000, DMI type 4, 35 bytes
Processor Information
Socket Designation: LGA 775
Type: Central Processor
Family:
Manufacturer: Intel(R) Corporation
ID: F6 06 00 00 FF FB EB BF
Version: Intel(R) Core(TM)2 CPU 6420 @ 2.13GHz
Voltage: 1.6 V
External Clock: 266 MHz
Max Speed: 4000 MHz
Current Speed: 2133 MHz
Status: Populated, Enabled
Upgrade: Socket LGA775
L1 Cache Handle: 0x0003
L2 Cache Handle: 0x0001
L3 Cache Handle: Not Provided
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Author: Eric P
Last update: 2017-10-12 23:11
Troubleshooting SIP
sudo apt install sipsak
$ sipsak -vv -s sip:2444@yourvoip.server.com
Source https://sourceforge.net/projects/sipsak.berlios/
Author: Eric P
Last update: 2017-10-12 23:18
SSH as a quick and cheap VPN using tsocks
Very simple:
sudo ap-get install tsocks -y
Once installed, edit config file
nano /etc/tsocks.conf
Go all the way down and replace, server with your loopback IP and server port, to whatever you want as long as it not being used by other apps.
server = 127.0.0.1
# The port defaults to 1080
#Change port as needed
server_port = 1098
Now to connect from another location
ssh -D 1098 yourusername@yourTsocksMachine.com -p22 ;
Note: you don't need to change or add any forwarding to port 1098 from the router, you only need to forward port 22 or whatever you use for SSH to that machine.
Once you have successfully connected, open a new terminal (Don't use the same) and type:
tsocks firefox
or try any other browser or compatible app.
such as
tsocks midori
tsocks google-chrome
tsocks thunderbird
tsocks filezilla
Make sure these apps are not already open, for example for my local browsing I use chrome, and for my tsocks connections I use firefox or midory, you can create independent links to these apps so you know where you are connecting to.
Author: Eric P
Last update: 2017-10-12 23:28
How to obtain wireless info from the console
To get info such as, speed, quality, etc.
iwconfig
iwconfig wlan0
iwconfig wlan0 | egrep -e "Quality" -e "Rate"
wlan0 IEEE 802.11abgn ESSID:"Marissa1"
Mode:Managed Frequency:2.437 GHz Access Point: 00:24:B2:71:CB:EC
Bit Rate=54 Mb/s Tx-Power=14 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=59/70 Signal level=-51 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:58 Missed beacon:0
<!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } -->
wlan0 IEEE 802.11abgn ESSID:"It-Hertz-When-IP"
Mode:Managed Frequency:2.437 GHz Access Point: 00:24:B2:71:CB:EC
Bit Rate=54 Mb/s Tx-Power=14 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=59/70 Signal level=-51 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:58 Missed beacon:0
Author: Eric P
Last update: 2017-10-12 23:52
How to synchronize folders
Rsync I use this alot to synchronize several machines,
A basic way
rsync -rtvaz --delete /var/www/Vol1 root@192.168.1.102:/var/Vol1 > /var/rsync.txt |
To limit the Bandwidth
rsync -rtvaz --delete --bwlimit=1000 -e 'ssh -p 22' lnxbox.yourdomain.com:/var/Vol1/MEDIA/ /Vol0/MEDIA
From your local machine to a machine with alternate SSH port, excluding folders complete and incomplete
rsync -e 'ssh -p 3426' -rtva /srv/storage/downloads/ root@remote.azt.com:/var/Vol1/TV/ --exclude 'complete' --exclude 'incomplete' --stats --progress
To sync specific type of files, on this case only MKV files
rsync -rtv -a --include '*/' --include '*.mkv' --exclude '*' /var/Vol1/MEDIA/ root@192.168.1.58:/var/Vol1/MEDIA/
Author: Eric P
Last update: 2017-10-12 23:58
Slow SSH connections
disable UseDNS by editing /etc/ssh/sshd_config
UseDNS no
Author: Eric P
Last update: 2017-10-13 00:00
How to run VirtualBox on a headless Server
VBoxHeadless -startvm servername
Or
nohup vboxheadless -startvm Windows7 < /dev/null > /dev/null 2>&1 &
nohup vboxheadless -startvm Windows7 < /dev/null > /dev/null 2>&1 &
Author: Eric P
Last update: 2017-10-13 00:02
Raspberry Pi SD card configuration
This is old, but still useful
df -h
umount /dev/mmcblk0p1
sudo dd bs=1M if=archlinuxarm-13-06-2012.img of=/dev/mmcblk0p1
Author: Eric P
Last update: 2017-10-13 00:05
Start and Stop service Motion from crontab
Create a cron job
cd /etc/init.d && motion start
Then create another one to kill it at determinated time.
killall motion &&
chmod 777 -R /var/Vol1/Motion/
chmod 777 -R /var/Vol1/Motion/;
Author: Eric P
Last update: 2017-10-13 00:07
How to get tcpdump on port 5060 or any other port
tcpdump -n "dst host 192.168.10.1 and dst port 5060" -vw /var/log/asterisk/capture.cap
Another way
tcpdump -n "port 5060" -vw sip.dump
Author: Eric P
Last update: 2017-10-13 00:10
How to convert wave files for Asterisk
From Ubuntu
sox sourceStereo.wav -r 8k -c 1 out-mono8kfile.wav
Author: Eric P
Last update: 2017-10-13 00:13
How to import export OST PST files
Most sites out there have multiple comments about so called freeware to open OST files, the fact is that most of them are nothing but scams to get you to purchase the real application, the easiest way to open a OST or PST file is with the email client Evolution, I don’t know if available for Windows but If you have a computer and a pendrive, just bootup a live Linux version that has Evolution included, do an Import –select Import a Single file and select the OST file, it will take a while to finish the import.
The reason I needed to open the file was to get the contacts from an old email address that was no longer available, nor I had access to the server.
Author: Eric P
Last update: 2017-10-13 00:17
Voicemail attachment that don't play on Iphone or Droid phones
Perhaps too old, but could be useful
This was extracted from http://nerdvittles.com/?tag=piaf
MP3 Playback . Log into your server as root and issue the following commands. If you want to activate the transcription feature, edit the downloaded script and change transcribe=0 to transcribe=1.
cd /root
wget http://pbxinaflash.com/installmp3stt.sh
chmod +x installmp3stt.sh
./installmp3stt.sh
Once you have run the installation script, you’ll need to make a couple of adjustments in the FreePBX GUI. Log into FreePBX 2.11 and choose Settings, Voicemail Admin, Settings and make the following changes:
format: wav|wav49
mailcmd: /usr/sbin/sendmailmp3
Author: Eric P
Last update: 2017-10-13 00:21
Hard drive failure notification
cd /root
nano hd-monitor.sh
#!/usr/bin/perl
$to='some@yourown.com';
$from='hdfail@whatever.com';
my $command_output = ´/usr/sbin/smartctl -a /dev/sda1´;
if ($command_output =~ /PASSED/ && $? == 0) {
print "No issues with /dev/sda1";
}else{
´echo "Subject:HD Failure \n$command_output" | /usr/sbin/sendmail -f $from $to´;
}
sudo chmod +x /root/hd-monitor.sh
sudo crontab -e
0 3 * * * /root/hd-monitor.sh > /tmp/hd-monitor.log
Author: Eric P
Last update: 2017-10-13 00:24
How to send SSH commands to remote host, ssh Automation
This is very useful for automating tasks in remote machines or to gather remote info from many machines at once.
ssh root@192.168.1.48 'uptime'
For multiple commands
ssh root@192.168.1.48 'uptime ; df -h'
Works best with passwordless SSH
Author: Eric P
Last update: 2017-10-15 03:58
How to take a picture from terminal
Something easy to use fswebcam
apt-get install fswebcam
fswebcam -r 1080x780 --jpeg 90 -D 1 snap.jpg
Author: Eric P
Last update: 2017-10-13 00:40
Partition larger than 2 TB drives
If you try to partition a large drive and get this error
sectors exceeds the msdos-partition-table-imposed maximum of ....
The solution is to partition using "gpt"
Using GParted:
Device --> Create Partition Table and select "gpt"
After that, Format the drive with whatever you need, in my case I use several of these drives for rotational backups as external removable drives on windows systems, so I use NTFS, but if you are going to be using the drive for Linux, EXT4 is probably going to be your best choice.
Author: Eric P
Last update: 2017-10-13 00:41
How to measure Internal Network speed
First you need to install Iperf on all the machines that you wish to test throughput.
sudo apt-get install iperf
Once you have it installed, select a machine to be the server and run the following command
iperf -s or iperf --server
From the other computers run:
iperf -c 192.168.50.15 -f M
More info https://iperf.fr/
Author: Eric P
Last update: 2017-10-13 00:43
How to remove blank spaces on files, folders and subfolders
cd into directory
find . -depth -name '* *' \ | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done
Taken from Here, works great for Piwigo
Author: Eric P
Last update: 2017-10-13 00:46
How to get Navit working on Raspberry Pi with a USB GPS device
To install Navit and GPSD
sudo apt-get install navit gpsd gpsd-clients python-gps -y
Copy to your home directory
cp /etc/navit/navit.xml ~/.navit/navit.xml
cd /home/pi/.navit
Get a map (using your browser)
http://maps.navit-project.org (zoom and select the desired area and hit download)
Rename the downloaded file to something like Phoenix.bin and place it under
/home/pi/.navit/
Disable sample maps
CHANGE TO:
<!-- If you dont want to use the sample map, either set enabled="no" in the next line or remove the xml file from the maps directory -->
<mapset enabled="no">
<xi:include href="$NAVIT_SHAREDIR/maps/*.xml"/>
</mapset>
Enable your Map
<!-- Mapset template for openstreetmaps -->
<mapset enabled="yes">
<map type="binfile" enabled="yes" data="/home/pi/.navit/Phoenix.bin"/>
</mapset>
To get a USB GPS working
Works for Navit and other GIS software, such as kismet and others.
sudo nano /etc/default/gpsd
START_DAEMON="true"
# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="true"
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyUSB0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="/dev/ttyUSB0"
GPSD_SOCKET=”/var/run/gpsd.sock”
--------------------------------------------------------------------------------------------------------------------------------------------------
Author: Eric P
Last update: 2017-10-13 01:01
Change ACL from terminal
icacls "X:\apps\Test" /grant dom1\Standard_users:F
Author: Eric P
Last update: 2017-10-13 01:40
Windows
How to import export OST PST files
Most sites out there have multiple comments about so called freeware to open OST files, the fact is that most of them are nothing but scams to get you to purchase the real application, the easiest way to open a OST or PST file is with the email client Evolution, I don’t know if available for Windows but If you have a computer and a pendrive, just bootup a live Linux version that has Evolution included, do an Import –select Import a Single file and select the OST file, it will take a while to finish the import.
The reason I needed to open the file was to get the contacts from an old email address that was no longer available, nor I had access to the server.
Author: Eric P
Last update: 2017-10-13 00:17
Missing windows\system32\config\system
Boot from XP CD - Select the repair option:
copy c:\windows\repair\system c:\windows\system32\config\system
It will require to reactivate windows and most likely to install SP3
Author: Eric P
Last update: 2017-10-13 01:17
Auto login for Windows 7
-
Click on Start and then enter the following command in the search box:
netplwiz
Press the ENTER key.
Follow the options.
Author: Eric P
Last update: 2017-10-13 01:19
How to backup My Documents on Windows 7 using batch script
The following script will create a folder on the D: drive named as today's date in numeric format, this is great if you need to schedule your PC to run Backups on a specific time of the day and provide you with several versions of My Document folder, you could send them to your Dropbox folder, Mega, etc.
-----> Save the script bellow as MYDocs.bat and run it.
set myDate=%date:~4,2%%date:~7,2%%date:~10%
mkdir h:\%myDate%
robocopy "c:\users\%username%"\Documents\ H:\%myDate% /e /R:1 /v /np /eta /w:2 /PURGE /XD TEMP >c:\users\%username%"\Desktop\MYDocs.txt
set myDate=%date:~4,2%%date:~7,2%%date:~10%
mkdir D:\%myDate%
robocopy "c:\users\%username%"\Documents\ D:\%myDate% /e /R:1 /v /np /eta /w:2 /PURGE /XD TEMP >c:\users\%username%"\Desktop\MYDocs.txt
curve
curve
Author: Eric P
Last update: 2017-10-13 01:21
Hidden folder after copying from external drive
This problem occurs sometimes when using robocopy , sometimes I Can't even see files in external drive and they are not hidden.
My solution is to run:
attrib -H -S /L h:\folder
Author: Eric P
Last update: 2017-10-13 01:38
Change ACL from terminal
icacls "X:\apps\Test" /grant dom1\Standard_users:F
Author: Eric P
Last update: 2017-10-13 01:40
VOIP
How to reset Linksys/Sipura Modems
- Dial ****73738#
- Dial 1# to confirm
Author: Eric P
Last update: 2017-10-12 23:01
How to obtain IP address from a Linksys Sipura - SPA Phones by dialing
From the Phone dial **** then press 110# - this will say the current IP
Author: Eric P
Last update: 2017-10-12 23:00
How to find the best proxy for Broadvoice sip server
Run this and select the lowest ping
ping proxy.lax.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.dca.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.mia.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.atl.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.chi.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.bos.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.nyc.broadvoice.com -i 3 -c3 >>ping.txt && cat ping.txt
-----------
PING proxy.lax.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=107 ms
--- proxy.lax.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10323ms
rtt min/avg/max/mdev = 104.382/105.642/107.827/1.573 ms
PING proxy240.dca.broadvoice.com (147.135.0.128) 56(84) bytes of data.
64 bytes from 147.135.0.128: icmp_req=1 ttl=242 time=90.9 ms
64 bytes from 147.135.0.128: icmp_req=2 ttl=242 time=160 ms
64 bytes from 147.135.0.128: icmp_req=3 ttl=242 time=92.2 ms
--- proxy240.dca.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10398ms
rtt min/avg/max/mdev = 90.959/114.509/160.352/32.420 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=72.0 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=204 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=70.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13510ms
rtt min/avg/max/mdev = 70.356/115.807/204.973/63.054 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=71.6 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=83.5 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=69.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13295ms
rtt min/avg/max/mdev = 69.373/74.843/83.552/6.225 ms
PING proxy.chi.broadvoice.com (147.135.32.221) 56(84) bytes of data.
64 bytes from 147.135.32.221: icmp_req=1 ttl=242 time=207 ms
64 bytes from 147.135.32.221: icmp_req=2 ttl=242 time=701 ms
64 bytes from 147.135.32.221: icmp_req=3 ttl=242 time=124 ms
--- proxy.chi.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 11242ms
rtt min/avg/max/mdev = 124.754/344.544/701.431/254.605 ms
PING proxy.bos.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=105 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=107 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=105 ms
--- proxy.bos.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10340ms
rtt min/avg/max/mdev = 105.190/106.172/107.374/0.943 ms
PING proxy.nyc.broadvoice.com (147.135.20.221) 56(84) bytes of data.
64 bytes from 147.135.20.221: icmp_req=1 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=2 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=3 ttl=242 time=126 ms
--- proxy.nyc.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10368ms
rtt min/avg/max/mdev = 125.297/125.955/126.629/0.616 ms
Author: Eric P
Last update: 2017-10-12 23:08
How to find the best proxy for Broadvoice sip server
Run this and select the lowest ping
ping proxy.lax.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.dca.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.mia.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.atl.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.chi.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.bos.broadvoice.com -i 3 -c3 >>ping.txt
ping proxy.nyc.broadvoice.com -i 3 -c3 >>ping.txt && cat ping.txt
-----------
PING proxy.lax.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=104 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=107 ms
--- proxy.lax.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10323ms
rtt min/avg/max/mdev = 104.382/105.642/107.827/1.573 ms
PING proxy240.dca.broadvoice.com (147.135.0.128) 56(84) bytes of data.
64 bytes from 147.135.0.128: icmp_req=1 ttl=242 time=90.9 ms
64 bytes from 147.135.0.128: icmp_req=2 ttl=242 time=160 ms
64 bytes from 147.135.0.128: icmp_req=3 ttl=242 time=92.2 ms
--- proxy240.dca.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10398ms
rtt min/avg/max/mdev = 90.959/114.509/160.352/32.420 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=72.0 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=204 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=70.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13510ms
rtt min/avg/max/mdev = 70.356/115.807/204.973/63.054 ms
PING proxy.atl.broadvoice.com (206.15.140.221) 56(84) bytes of data.
64 bytes from 206.15.140.221: icmp_req=1 ttl=243 time=71.6 ms
64 bytes from 206.15.140.221: icmp_req=2 ttl=243 time=83.5 ms
64 bytes from 206.15.140.221: icmp_req=3 ttl=243 time=69.3 ms
--- proxy.atl.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13295ms
rtt min/avg/max/mdev = 69.373/74.843/83.552/6.225 ms
PING proxy.chi.broadvoice.com (147.135.32.221) 56(84) bytes of data.
64 bytes from 147.135.32.221: icmp_req=1 ttl=242 time=207 ms
64 bytes from 147.135.32.221: icmp_req=2 ttl=242 time=701 ms
64 bytes from 147.135.32.221: icmp_req=3 ttl=242 time=124 ms
--- proxy.chi.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 11242ms
rtt min/avg/max/mdev = 124.754/344.544/701.431/254.605 ms
PING proxy.bos.broadvoice.com (147.135.32.128) 56(84) bytes of data.
64 bytes from 147.135.32.128: icmp_req=1 ttl=242 time=105 ms
64 bytes from 147.135.32.128: icmp_req=2 ttl=242 time=107 ms
64 bytes from 147.135.32.128: icmp_req=3 ttl=242 time=105 ms
--- proxy.bos.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10340ms
rtt min/avg/max/mdev = 105.190/106.172/107.374/0.943 ms
PING proxy.nyc.broadvoice.com (147.135.20.221) 56(84) bytes of data.
64 bytes from 147.135.20.221: icmp_req=1 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=2 ttl=242 time=125 ms
64 bytes from 147.135.20.221: icmp_req=3 ttl=242 time=126 ms
--- proxy.nyc.broadvoice.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10368ms
rtt min/avg/max/mdev = 125.297/125.955/126.629/0.616 ms
Author: Eric P
Last update: 2017-10-12 23:08
Troubleshooting SIP
sudo apt install sipsak
$ sipsak -vv -s sip:2444@yourvoip.server.com
Source https://sourceforge.net/projects/sipsak.berlios/
Author: Eric P
Last update: 2017-10-12 23:18
How to get tcpdump on port 5060 or any other port
tcpdump -n "dst host 192.168.10.1 and dst port 5060" -vw /var/log/asterisk/capture.cap
Another way
tcpdump -n "port 5060" -vw sip.dump
Author: Eric P
Last update: 2017-10-13 00:10
How to convert wave files for Asterisk
From Ubuntu
sox sourceStereo.wav -r 8k -c 1 out-mono8kfile.wav
Author: Eric P
Last update: 2017-10-13 00:13
Voicemail attachment that don't play on Iphone or Droid phones
Perhaps too old, but could be useful
This was extracted from http://nerdvittles.com/?tag=piaf
MP3 Playback . Log into your server as root and issue the following commands. If you want to activate the transcription feature, edit the downloaded script and change transcribe=0 to transcribe=1.
cd /root
wget http://pbxinaflash.com/installmp3stt.sh
chmod +x installmp3stt.sh
./installmp3stt.sh
Once you have run the installation script, you’ll need to make a couple of adjustments in the FreePBX GUI. Log into FreePBX 2.11 and choose Settings, Voicemail Admin, Settings and make the following changes:
format: wav|wav49
mailcmd: /usr/sbin/sendmailmp3
Author: Eric P
Last update: 2017-10-13 00:21