Sep/090
Creating Notifications with notify-send
Last week on the Linux Journal website, a tech tip was published showing how to get notifications from your scripts with notify-send. This is a great little tool that can display a pop-up message in the bottom right corner of your screen.
On RHEL, you can install notify-send with the following command:
yum install libnotify
To create a notification, you could type the following:
notify-send "Reboot Notification" "`hostname` will be rebooted at 1700 EST."
The resulting notification will look something like this:

Aug/090
Retrieving Hard Drive Info Via Command Line
It's possible find the make, model and serial number of the hard drive(s) in a RHEL or CentOS system without having physical access to the machine. Simply type the following command as root:
smartctl -i /dev/sda
The output will look something like this:
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Caviar Second Generation Serial ATA family
Device Model: WDC WD3200AAJS-00L7A0
Serial Number: WD-WCAV28394729
Firmware Version: 01.03E01
User Capacity: 320,072,933,376 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 8
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Wed Aug 19 17:58:23 2009 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
In the above example, we are using /dev/sda. If you have multiple drives, you will need to run the smartctl command for each drive separately. You can get a list of all drives by running the following command as root:
fdisk -l | grep Disk
The output will look something like this:
Disk /dev/sda: 320.0 GB, 320072933376 bytes
Disk /dev/sdb: 320.0 GB, 320072933376 bytes
Disk /dev/sdc: 163.9 GB, 163928604672 bytes
For more information on smartctl, check out the man page.
Aug/091
Add A User Via Command Line
Adding a user in RHEL or CentOS can easily be done using the system-config-users gui tool. However, sometimes you need to add users via the command line. This can be helpful when adding a lot of users at once or for scripting.
To add a user via command line, use the useradd command. The example below uses the useradd command to add the user joe to the local machine:
/usr/sbin/useradd -u 5000 -g users -G wheel -d /home/joe \
-c "Joe's Account" -p '$1$826q9/$mBqVr.FxKdLkWr7a0OEAi0' joe
Here's a quick breakdown of the command:
- -u sets the user's unique identification number (UID)
- -g sets the user's primary group
- -G adds the user to additional groups
- -d set's the user's home directory
- -c set's the account description
- -p set's the user's password using an encrypted password hash
To create the password hash for the -p option, use the grub-md5-crypt command:
/sbin/grub-md5-crypt
It will ask you to type the new password twice and then output the encrypted hash:
$1$826q9/$mBqVr.FxKdLkWr7a0OEAi0
Once you have the password hash, you can include it in the above useradd command.
It's worth noting that you can set the user's password after account creation using the passwd command:
/usr/bin/passwd joe
Aug/091
How To Determine RHEL Version
Finding the version of Red Hat Enterprise Linux (RHEL) or CentOS you are running is easy. Simply open a terminal and type the following:
cat /etc/redhat-release
You should receive something like this:
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
That's it!
