Category Archives: UNIX

Posts regarding UNIX and Linux systems

ASUS 1001P

So I finally bought an ASUS 1001P last month. It came with Windows 7 and I was able to install Ubuntu using wubi. After the installation it didn’t erased anything in the Windows partition. It took 16 GB of an additional extra disk, but still being formated as NTFS. Here is the /etc/fstab output.

[23:51:54] xavi@ubuntu:~ $ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/host/ubuntu/disks/root.disk /               ext4    loop,errors=remount-ro 0       1
/host/ubuntu/disks/swap.disk none            swap    loop,sw         0       0
[23:51:59] xavi@ubuntu:~ $ 

And here goes fdisk.

[23:57:58] xavi@ubuntu:~ $ sudo fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xabf319e9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       13055   104857600    7  HPFS/NTFS
/dev/sda2           13055       29094   128834560    7  HPFS/NTFS
/dev/sda3           29094       30399    10485760   1b  Hidden W95 FAT32
/dev/sda4           30399       30401       17088+  ef  EFI (FAT-12/16/32)
[23:58:03] xavi@ubuntu:~ $ 

This netbook comes with a 250 Gb hard drive and after the Ubuntu installation everything basically works out of the box. One really nice thing is that the wireless works out of the box. From previous experiences I would have to download firmware and recompile the kernel.

The keyboard is a little small, but is quite easy to get used to it. The screen resolution is 1024×600. It can be a little small if you have multiple windows opened, but this gets compensated with the netbooks 2.80 pounds weight.

I`m really happy with this netbook. I was becoming a weight lifter when I walked around with my 12 inch Powerbook.

Playing around with Nagios

I have been playing around with Nagios lately. This is the most widely used monitoring tool. I’m not going to write another howto, but clarify some things I found missing in the configuration manuals I used.

First you need the PHP module on the apache server for Nagios to work. Else you will find yourself downloading a phtml file to some directory in your box. This is because of the following files in the nagios directory.

xavi@server:~$ sudo find /nagios/ -type f -name "*.php"
/nagios/share/side.php
/nagios/share/includes/utils.inc.php
/nagios/share/main.php
/nagios/share/config.inc.php
/nagios/share/index.php
xavi@server:~$ 

Another issue I found was the with nrpe plugin. This plugin allows us to run commands on remote hosts. Issue is that default compilation values don’t allow us to pass arguments. To pass arguments from the server to the monitored host it must be compiled with the –enable-command-args argument when compiling the nrpe source. Another thing that must be done is setting the dont_blame_nrpe to 1 in the nrpe.cfg file.

dont_blame_nrpe=1

This changes allows us to run checks with arguments remotely. Example:

server:/nagios/libexec# ./check_nrpe -H 212.34.95.23 -c check_procs -a 100 120
PROCS OK: 96 processes
server:/nagios/libexec#

Questions and suggestions are always welcome. 🙂

Restoring IPtables when box reboots

Todays post is also going to be short.
I have a VPS server running and the other day they had to reboot my host because of maintenance. Things is I lost my running iptables when the box was rebooted. So how do we get this fixed? You can create a script and us update-rc.d and make it run on the default runlevel. However, we are going to do it different. We will use /etc/network/interfaces and iptables-restore.
Continue reading

Useful sed

This is going to be a really small post. Sometimes there are a lot of comments on files. How do we clean it up a little? Using sed. Lets show an example.

[14:21:55] xavi@NewYork:/tmp $ sed -e '/^#/d' /etc/ssh/sshd_config | sed -e '/^$/d'
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
[14:22:06] xavi@NewYork:/tmp $

First sed removes lines starting with a #. Our input file is the sshd config file, but it can be any other. The output is then piped to remove the empty lines leaving us with a clean configuration file.

Comments are always welcome. Yes, I know there are some security flaws in the config file, but that is not what we are dealing with in this howto. 🙂
References:

  1. http://www.grymoire.com/Unix/Sed.html
  2. http://en.wikipedia.org/wiki/Sed