FAQ Overview

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: 2019-06-20 20:27


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: 2019-06-20 20:46


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: 2019-06-20 20:28


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

 

  1. Dial ****73738#
  2. Dial 1# to confirm

Author: Eric P
Last update: 2019-06-20 15:49


How to obtain IP address from a Linksys Sipura - SPA Phones by dialing

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:00


How to find the best proxy for Broadvoice sip server

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:08


How to find the best proxy for Broadvoice sip server

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:08


How to get Bios info

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:11


Troubleshooting SIP

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:18


SSH as a quick and cheap VPN using tsocks

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:28


How to obtain wireless info from the console

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:52


How to synchronize folders

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2019-06-20 20:29


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

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 00:40


Partition larger than 2 TB drives

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 00:41


How to measure Internal Network speed

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 00:43


How to remove blank spaces on files, folders and subfolders

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 00:46


How to get Navit working on Raspberry Pi with a USB GPS device

This entry is in revision and can not be displayed.

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

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 01:17


Auto login for Windows 7

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 01:19


How to backup My Documents on Windows 7 using batch script

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-13 01:21


Hidden folder after copying from external drive

This entry is in revision and can not be displayed.

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

 

  1. Dial ****73738#
  2. Dial 1# to confirm

Author: Eric P
Last update: 2019-06-20 15:49


How to obtain IP address from a Linksys Sipura - SPA Phones by dialing

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:00


How to find the best proxy for Broadvoice sip server

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:08


How to find the best proxy for Broadvoice sip server

This entry is in revision and can not be displayed.

Author: Eric P
Last update: 2017-10-12 23:08


Troubleshooting SIP

This entry is in revision and can not be displayed.

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