Browsing the blog archives for August, 2008.

Configure Linux Hostname

Config

If you want to change your Linux hostname and you’re running Fedora or Red Hat, the steps are listed below.

Immediate Change

echo 'some.host.com' > /proc/sys/kernel/hostname

Persisted Change

This is for non-DHCP nodes.

Add your name to /etc/sysconfig/network

NETWORKING=yes
HOSTNAME="some.host.com"

If you’re node gets an IP address from a DHCP server then you can set:

DHCP_HOSTNAME="some.host.com"

in the /etc/sysconfig/network-scripts/ifcfg-eth0 file (or whatever your primary device is).

Notes

You can also add your hostname to your /etc/hosts file

10.1.1.10 some.host.com some
No Comments

Linux – Programmatically Change Password

Examples

If you need to script a password change you have two main options:

  1. Write a script that interacts with the command line and executes passwd
  2. Use the usermod command

Option one is a bit of a mess and option two requires an encrypted version of the password. At first, we couldn’t figure out how to encrypt the password but then we realized that you could use the Perl crypt function.

An example of number two:

#!/bin/bash

usermod -p `perl -e 'print crypt("test", "salt")'` root;

That’s all there is to it!

2 Comments

Cronolog

Tools

Cronolog is a handy file rotation tool for Apache.

To create daily log files, add something like this to your httpd.conf file.

CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/%Y/%m/%d/access.log" combinedio

Installation is simply:

configure && make && make install
No Comments