Tips & Tricks

By Jun Salen

This is a compilation of tips and tricks I got from reading the mailing list from CentOS and PLUG which I will update from time to time.

How to Get Users List in a Linux Machine

As local user

  1. cat /etc/passwd

– Seperated by username, password, UID, GID, home directory, shell

  1. cat /etc/group

– Use this to see group information.

getent passwd
– This handles everything nsswitch.conf does (NIS, LDAP, xyzzy, whatever).

getent passwd | cut -d: -f1 | sort -u
– To get just a list of usernames

To check what is the IP address of the DHCP server where assigned IP leased from:

For CentOS 5, the command:

  1. grep dhcp-server-identifier /var/lib/dhclient/dhclient-eth0.leases

or for CentOS 4, the command:

  1. grep dhcp-server-identifier /var/lib/dhcp/dhclient-eth0.leases

To list all PCI device:


To determine the change log of installed software:
rpm -qi –changelog <packagename>

yum install yum-changelog

Then …

man yum-changelog


repoquery –changelog foo

Robert Moskowitz Tips on Private Network IP Addresses:

If you use addresses from the 192.168 range, avoid the nets:,,, and These are commonly used by various ‘appliances’. Choose something ‘wierd’ like (or some other prime number less than 255). Though I tend to use,, or

Also avoid the 172.16 and 10. ranges. These are commonly used in Company internal private networks, and if you want to ‘VPN’ to them, it an cause unwanted results (like it won’t work).

This is general advice to anyone using private addresses for small usages.

To Get Memory Usage and Information:

free – for summary information

cat /proc/meminfo – for detailed information

To get hardware info in Linux:


To test for disk I/O performance:

Download ‘disktest’ utility from Linux Test Project(LTP) and do the ff:

Sequential reads:
disktest -B 4k -h 1 -I BD -K 4 -p l -P T -T 300 -r /dev/sdX

Sequential writes:
disktest -B 4k -h 1 -I BD -K 4 -p l -P T -T 300 -w /dev/sdX

Random writes:
disktest -B 4k -h 1 -I BD -K 4 -p r -P T -T 300 -r /dev/sdX

Random writes:
disktest -B 4k -h 1 -I BD -K 4 -p r -P T -T 300 -w /dev/sdX

Description of the options used:
-B 4k = 4k block ios
-h 1 = 1 second heartbeat
-I BD = block device, direct io
-K 4 = 4 threads, or 4 outstanding/overlapping ios, typical pattern
(use -K 1 for the raw performance of single drive, aka dd type output)
-p <l|r> = io type, l=linear, r=random
-P T = output metrics type “Throughput”
-T 300 = duration of test 300 seconds
-r = read
-w = write

These tests will run across the whole disk/partition and the write
tests WILL BE DESTRUCTIVE so be warned!

To determine PCI information and replacing LAN card info:


In /etc/modprobe.conf

Put or replace alias entries for LAN card and restart network.

To get driver info of 3Ware Card:

/sbin/modinfo 3w-9xxx

How to know what version of CentOS

Option 1:

cat /etc/redhat-release

Option 2:

rpm -q centos-release

How-to Linux Upgrade

Step 1: # screen

Step 2: # yum upgrade yum\* rpm

Step 3: # yum clean all

Step 4: # yum upgrade

Step 5: # exit

Step 6: # reboot

How to compile Postfix file to BDB

/opt/zimbra/postfix/sbin/postmap protected_recipients

How-To Configure Yum Using Proxy

Add the following entry in /etc/yum.conf:

Where: = IP Address
yyyy = Port Number

To connect to the Internet through proxy:

Edit /etc/profile

export http_proxy=” port/


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s