Jaime Frutos Morales's blog


Tip: Learning VIM with vimtutor

Filed under: Linux — acidborg @ 12:41

If you are interested in learning VIM (VI iMproved) basics, you should try vimtutor,an easy and nice VIM tutorial.


  • Debian based distros: apt-get install vim vim-runtime
  • Red Hat based distros: yum install vim-enhanced


  • Just type vimtutor to get started.
  • You can also specify the language in which the tutorial is written using vimtutor [2-letters language code]. Example: vimtutor es

Enjoy VIM!


How to connect to Cisco devices via serial port using GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 10:17

Description: to connect your computer to a Cisco device via its console port, you usually need a RJ45 rolled cable. You can use a RJ-45 to DB-9 Female if your computer has a serial port.

RJ-45 to DB-9 Female

To communicate through the serial port with the Cisco device, you need Minicom, a terminal emulator software.


  • Debian/Ubuntu based distros: sudo apt-get install minicom
  • Red Hat/Fedora based distros: sudo yum install minicom


  1. Check whether your serial port is detected by the kernel: dmesg | grep ttyS

    [ 0.485378] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
    [ 0.485739] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
  2. Run Minicom: sudo minicom
  3. Press Ctrl+A Z to enter Minicom’s menu.
  4. Press O to enter configuration submenu.
  5. Enter the serial port setup.
  6. Set the serial device (/dev/ttyS0 in this example).
  7. Press E to set the “Bps/Par/Bits”.
  8. Press C (9600 bps) and Q (8-N-1).
  9. Set software flow control to NO.
  10. Save the configuration as “cisco” (for example)
  11. Press Q to quit Minicom
  12. Run Minicom with the new configuration: sudo minicom cisco

Tip: if you need to send a “Break” through Minicom (on a password recovery operation, for example), use Ctrl+A F .


How to force a file system check on the next reboot on GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 14:52

Description: sometimes you need to force a file system check after you reboot your computer. This can be done in two ways:

If you are going to reboot right now:

  • Execute this command (the -F argument forces a file system check): sudo shutdown -Fr now

If you aren’t going to reboot right now:

  • Execute this command: sudo touch /forcecheck
  • Next time you reboot or start your computer, a file system check will be performed.

Alternatively, if you want to avoid a file system check, use this command to reboot your machine: sudo shutdown -fr now


The Humble Indie Bundle #2

Filed under: Linux — acidborg @ 00:37

The Humble Indie Bundle strikes back. As I did before, I’ve already contributed by purchasing my copies of their cross-platform games (GNU/Linux, Windows, Mac).

I totally recommend them.


How to bind a process to a specific CPU(s) on GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 13:07

Disclaimer: This recipe is focused on SMP computers only.

Description: CPU affinity is a scheduler property that binds a process to a given set of CPUs on the system, so that the system scheduler won’t run this process on any other CPUs. By default, the scheduler tries to keep processes on the same CPU as long as it makes sense for performance reasons, so forcing CPU affinity is useful only in some cases (per processor licensing, testing, broken hardware, etc).

CPU affinity is represented as a bitmask (given in hexadecimal), with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Examples:

  • CPU #0: 0x00000001
  • CPU #1: 0x00000002
  • CPU #2: 0x00000004
  • CPU #3: 0x00000008
  • CPU #0 and CPU #1: 0x00000003
  • CPU #2 and CPU #3: 0x0000000C
  • All CPUs: 0xFFFFFFFF

Taskset is a command used to set or retrieve the CPU affinity of a running process given its PID or to launch a new command with a given CPU affinity.


  • Debian/Ubuntu systems: sudo apt-get install util-linux
  • Red Hat/ Fedora systems: sudo yum install util-linux


  • Retrieve the CPU affinity of a running process: taskset -p PID
    taskset -p 1276
    pid 1276's current affinity mask: 3
  • Set the CPU affinity of a running process: taskset -p MASK PID
    taskset -p 0x00000001 9030
    pid 9030's current affinity mask: 3
    pid 9030's new affinity mask: 1
  • Run a new command with a given CPU affinity: taskset MASK COMMAND

You can check if taskset is working using top and pressing “1” to show all CPUs.


How to upgrade from Ubuntu 10.04 (Lucid) to Ubuntu 10.10 (Maverick)

Filed under: Linux, Ubuntu — acidborg @ 11:47

The upgrade is similar to the previous ones:

  1. Replace “lucid” for “maverick” in /etc/apt/sources.list : sudo sed -i 's/lucid/maverick/g' /etc/apt/sources.list
  2. Upgrade your system: sudo apt-get update && sudo apt-get -y dist-upgrade
  3. Reboot: sudo shutdown -r now


How to install and configure Ganglia on Red Hat Enterprise Linux 5

Filed under: Linux, SysAdmin — acidborg @ 13:34

Description: Although Gangliais a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids” (from its web), I’m going to explain how to set up Ganglia as a monitoring system for a group of computers which are neither part of a cluster nor a grid. Ganglia has very low per-node overheads and high concurrency, which makes it perfect to monitor a huge group of servers. I’m going to use one server to collect all data from the nodes. The collector server will run the web front-end for simplicity reasons, although you can install the web front-end on any other server if you need it.


  1. Add the EPEL repositories to your systems.
  2. Install the data collector (gmetad), the monitoring daemon (gmond) and the web front-end on the collector server: yum install ganglia ganglia-gmetad ganglia-web ganglia-gmond
  3. install gmond on each node you want to monitor: yum install ganglia ganglia-gmond

Configuration on the collector server (for example: collector.mycompany.com):

  1. Edit /etc/gmetad.conf and modify the line which begins with “data_source“. Example:
    data_source "my servers" 60 localhost

    This will collect data from the groups of machines tagged as “my servers” every 60 seconds. It will use localhost as the source of the info.

  2. Edit /etc/gmond.conf and modify the following part:
    cluster {
    name = "my servers"
    owner = "unspecified"
    latlong = "unspecified"
    url = "unspecified"
    udp_send_channel {
    host = collector.mycompany.com
    port = 8649
    udp_recv_channel {
    port = 8649
    tcp_accept_channel {
    port = 8649

    This allows collector.mycompany.com to receive monitoring data from every node on port 8649(UDP).

  3. Restart the collector daemon (gmetad): service gmetad restart
  4. Restart the node daemon (gmond): service gmond restart

Configuration on each node you want to monitor (except collector.mycompany.com):

  1. Edit /etc/gmond.conf and modify the following part:
    cluster {
    name = "my servers"
    owner = "unspecified"
    latlong = "unspecified"
    url = "unspecified"
    udp_send_channel {
    host = collector.mycompany.com
    port = 8649
    /*udp_recv_channel {
    tcp_accept_channel {

    This tells gmond to send the info to collector.mycompany.com on port 8649(UDP).

  2. Restart gmond: service gmond restart

After a few minutes, you will have your monitoring data available through: collector.mycompany.com/ganglia .


How to automatically start KVM virtual machines on boot

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:18

Description: when you have a host machine running KVM and it runs several guests (virtual machines), it’s very useful to make them start on boot so that you don’t have to start them manually.

Just execute the following command for each guest you want to autostart on boot: virsh autostart guest_name .


How to install and configure Apt-Cacher NG on Ubuntu Server 10.04

Filed under: Linux, SysAdmin, Ubuntu — acidborg @ 13:34

Description: Apt-Cacher NG is a caching proxy specialized for package files from GNU/Linux distributors, primarily for Debian and Debian based distributions (like Ubuntu). This means that if you have many Debian/Ubuntu machines on your network, you just have to download the deb packages (new software, updates, distro upgrades, etc) from the internet once and the rest of the Debian/Ubuntu machines get them from Apt-Cacher NG cache, saving time and internet bandwidth. To install it, follow these simple steps:


  1. Installation: apt-get install apt-cacher-ng
  2. Configuration: Edit /etc/apt-cacher-ng/acng.conf with the following content:
    CacheDir: /var/cache/apt-cacher-ng
    LogDir: /var/log/apt-cacher-ng
    Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
    Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
    PidFile: /var/run/apt-cacher-ng/pid
    ExTreshold: 4
  3. Restart Apt-Cacher NG: /etc/init.d/apt-cacher-ng restart
  4. Create on the rest of the Debian/Ubuntu machines on the network the file /etc/apt/apt.conf.d/02proxy with the following content:
    Acquire::http { Proxy "http://your-apt-cacher-ng-server:3142"; };

Next time any of your machines needs a deb package, it will ask Apt-Cacher NG for it. If this package was asked previously by any of the other machines, Apt-Cacher will have a copy and will deliver it. Otherwise, it will fetch it from the internet repositories, keep a local copy and deliver it.


How to lock a RPM package installed on Red Hat 5

Filed under: Linux, SysAdmin — acidborg @ 13:17

Description: if you have a RPM package installed and you want to lock its version (you don’t want to update it even if a newer version is available), there is a yum plugin which can do this for you: yum-versionlock


  1. Install the plugin: yum install yum-versionlock
  2. Enable it: make sure enabled = 1 appears in /etc/yum/pluginconf.d/versionlock.conf
  3. Add the packages you want to lock to /etc/yum/pluginconf.d/versionlock.list , including version and architecture. For example: nagios-plugins-1.4.11-1.el5.rf.x86_64
  4. Test it by trying to update a locked package: yum update nagios-plugins
Older Posts »

Create a free website or blog at WordPress.com.