Archive for February, 2010

Debian / Ubuntu package Management

You can search for a package by packagename or a word within the package description: apt-cache search apache2 apt-cache search “Apache ” You can also search by a file that is within the package: apt-file search apache2.conf Show package information: apt-cache show apache2 or apt-cache showpkg apache2 List files in a package: apt-file list apache2 […]

Linux hardware clock

You can use hwclock to synchronise the system clock with the hardware clock: hwclock –show read hardware clock and print result –set set the rtc to the time given with –date –hctosys set the system time from the hardware clock –systohc set the hardware clock to the current system time

Check RAM type without opening server

You can use dmidecode in Linux to check various hardware specs such as CPU / memory without having to physically open or power down the server. For example to see the RAM needed: dmidecode –type memory SMBIOS 2.5 present.

Ping an entire network / netblock

You can use fping to ping a netblock to see which hosts are alive: fping -g You could also put ping into a loop, but the output is less than useful: for i in {1..254}; do ping -c1 192.168.1.$i; done nmap is also a handy solution and can provide much more host information if […]

Basic AWK usage in BASH

To print a field from a file (-F is the field separator and $ is the number of the field to print): awk -F':’ ‘{ print $1 }’ /etc/passwd or awk -F':’ ‘{ print $1 $3 }’ /etc/passwd or awk -F':’ ‘{ print “username: ” $1 “\t\tuid:” $3″ }’ /etc/passwd

BASH – making tab completion case insensitive

This is very lazy, but comes in handy for example if your browsing a Windows mount with random uppercases in file/folder names. Add: make your tab completion case insensitive To your $HOME/.inputrc file (create the file if it doesn’t exist).  Alternatively you can make this userwide by adding it to /etc/inputrc . You might need […]

Using mod_proxy to avoid DNS propagation during site migration

There are a number of ways to migrate a site to a new server, whilst avoiding downtime or data concurrency issues. For a highly dynamic site, generally I would edit the old and new site connection strings to both use the same database during switchover.  mod_proxy is a useful method perhaps if a new version […]

Identifying apache process usage

When apache is running with php as an apache module rather than as a CGI, all processes will run as the apache user.  This makes it a little tricky on a busy multi-site box to identify which sites are using resources and keeping sessions open.  This little command will identify the working directory that the […]

Mounting Windows drives and shares in Linux

The following have come in handy for mounting a Windows share on a Linux computer: mount -t cifs -o username=user,password=password,umask=000 //winbox/winshare /mnt/home/ or smbmount //winbox/winshare /mnt/home/ -o username=user,password=password,rw An example of mounting a local NTFS partition held on the same machine: ntfsmount /dev/sda2 /mnt/windows -o umask=0002,silent

Yum Automatic Updates

You can install yum-cron to automatically download and install all available updates: yum install yum-cron chkconfig –list | grep yum – should show that the service is disabled chkconfig yum-cron on service yum-cron start Job Done – it will now check for and apply updates every night.  If its business critical solution though its probably […]