Tenth day in Addis
If a machine blocks pings, use arping instead.
-
Test DHCP:
$ sudo ifdown eth0 $ sudo ifup eth0 $ ifconfig
-
Test the DNS:
# See if the DNS machine is on # The network $ ping -n 192.168.0.1 # See if the DNS resolves names $ host www.dream.edu.et
-
Test the gateway:
# Ping the gateway $ ping gateway # Ping an outside host $ ping -n 10.4.15.6
-
Test the proxy:
# Ping the proxy $ ping proxy # Open a web page and see if it displays # See if it caches http_proxy=http://proxy.dream.edu.et:3030/ wget -S -O/dev/null http://www.enricozini.org 2>&1 | grep X-Cache
-
Test the mail server:
$ ping smtp $ nmap smtp -p 25 |grep 25/tcp $ if nmap gateway -p 25 |grep 25/tcp | grep -q open ; then echo "It works"; fi $ send a mail and see if you receive it
To do more advanced network and service monitoring, try nagios
:
New useful tools seen today
wget - The non-interactive network downloader.
Special devices
/dev/null
:- On read, there is no data.
- On write, discards data.
/dev/zero
:- On read, reads an infininte amount of zero bits.
- On write, discards data.
/dev/random
,/dev/urandom
- On read, reads random bits.
- On write, discards data.
- Difference:
/dev/random
is cryptographically secure, but it can hang waiting for system events
Example uses:
wget -O/dev/null http://www.example.org
dd if=/dev/zero of=testdisk bs=1M count=50
mke2fs testdisk
sudo mount -o loop testdisk /mnt
Tiny little commands
true
- do nothing, successfullyfalse
- do nothing, unsuccessfullyyes
- output a string repeatedly until killed
Example uses:
while /bin/true; do echo ciao; done
- Using /bin/false as a shell
yes | boring-tool-that-asks-lots-of-silly-questions
Some more shell syntax
2>&1
Redirects the standard error in the standard output2>
Redirects the standard error instead of the standard output
Some people run commands ignoring the standard error: command 2> /dev/null this causes unexpected error messages to go unnoticed: please do not do it.
What to check if a machine is very slow
- See if the ram is full:
$ free
If it is, you see what are the fattest programs using
top
, pressingM
to sort by memory usage. - See if there are lots of programs competing for CPU: $ top
- Check if you have I/O bottlenecks: $ vmstat (but I don't know how to read it)
- For a desktop on older hardware, you can try xubuntu instead of ubuntu
More VIM command mode
Command mode allows to perform various text editing functions.
You work by performing operations on selected blocks of text.
Some common operations:
y
: copy ("yank")p
: pasteP
: paste befored
: cut ("delete")c
: changei
: insert- `a: append
.
: repeat last operation
Some common blocks:
w
: word}
: paragraph- left and right arrow: one character left or right
- up and down arrow: this line and the one on top or below
f
letter: from the cursor until the given letterv
: selectionV
: line selection^V
: block selection
Examples:
yw
: copy worddw
: cut wordyy
: copy linedd
: cut lineV
(select lines) y: copy a selection of linesV
(select lines) d: cut a selection of linesp
: paste
The best way to learn more vim is always to run vimtutor
.
Installing squirrelmail
To install squirrelmail:
apt-get install squirrelmail
-
/usr/sbin/squirrelmail-config
and configure IMAP and SMTP.In our case, since we use IMAPS, the IMAP server is imap.dream.edu.et, port 993, secure IMAP enabled and SMTP is smtp.dream.edu.et. 3.
Read /usr/share/doc/squirrelmail/README.Debian.gz
(with zless) for how to proceed with setup. A short summary: * link/etc/squirrelmail/apache.conf
into the apache conf.d directory * customise/etc/squirrelmail/apache.conf
for example setting up the virtual hosts, or running it only on SSL
To have different virtual hosts over HTTPS, you need to have a different IP for every virtual host: name based virtual hosts do not work on HTTPS.
You can configure multiple IP addresses on the same computer: use network interfaces named: eth0:1, eth0:2, eth0:3... These are called interface aliases.
You cannot setup interface aliases using the graphical network configuration
and you need to add them in /etc/network/interfaces
:
iface eth0:1 inet static
address 192.168.0.201
netmask 255.255.255.0
gateway 192.168.0.3
auto eth0:1
This is the trick commonly used to put different virtual HTTPS hosts on the same computer.
Links
squid documentation:
- http://www.squid-cache.org/Doc/
- http://www.squid-cache.org/Doc/FAQ/
- http://www.deckle.co.za/squid-users-guide/Main_Page
Shell programming:
- http://www.freeos.com/guides/lsst/
- http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
- http://www.tinker.ncsu.edu/LEGO/shell_help.html
Performance analysis:
- http://flaviostechnotalk.com/wordpress/index.php/2005/06/05/performance-analysis-on-linux/
- http://www.cyberciti.biz/faqs/2006/07/linux-performance-tools-to.php
- http://searchopensource.techtarget.com/tip/1,289483,sid39_gci952332,00.html (not reviewed)
Setting up mail services: