This post will house basic usage commands for CentOS 5.4. It is a ‘living doc’, meaning that it will be updated over time so bookmark if interested.

YUM

Yum is the package manager built into CentOS distros and by package manager I don’t mean your local delivery guy, I mean how you can install, update, and remove software packages from your system.  Listed here are YUM commands you may find useful.

Update package repo:

yum update

View installed packages:

rpm -qa
#OR
yum list installed

View available updates:

yum list updates

Remove existing i386 apps from x64 system (USE WITH CAUTION!)


yum list installed | fgrep i386 > tmp.txt

yum remove $(awk '{print $1}' tmp.txt | xargs)

To only install 64 bit apps, add following line to /etc/yum.conf:

exclude=*.i386 *.i586 *.i686

Install yum-utils. (Useful set of utilities including package-cleanup)

su -c 'yum install yum-utils'

If you ever get a “missing dependency” error when trying to update a package via yum, check to make sure you have the right version installed (i686 vs x86_64). I had this issue when trying to update glibc-common. It wouldn’t update because the version of glibc was i686, which I explicitly removed via the yum.conf file (explained above).

yum list <package name>

Remove a package:

yum remove <package name>

Check available updates:

 yum check-update

Misc

Check CentOS version:

cat /etc/redhat-release

Reboot:

reboot

Delete User (-r will remove home dir):

userdel -r <username>

If user is logged in, force log them out:

pkill -KILL -u <username>

Change timezone:

Note: Personally, I highly recommend you set your system's local timezone to UTC. This will avoid any issues where some logs are in UTC, some are in local time, and will ensure a consistent time construct across all apps and modules such as php and mysql. Not to mention if you happen to move the server to a different timezone...


sudo rm /etc/localtime

sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime

RPMForge

If you need to install apps like irssi you will have to use rpmforge repo. To install follow the instructions @ http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

To keep your system as pristine as possible, I would edit the /etc/yum.repos.d/rpmforge.repo file and change enabled=1 to enabled=0. This will ensure you are not overriding centos approved packages with newer rpmforge packages. To install a package that resided in rpmforge only, do the following:

yum install <some_package> --enablerepo=rpmforge

This will allow you to use rpmforge on a case-by-case basis giving you much more control over what gets onto your system.

IRSSI

In order to get irssi to work on centos you may have to create a symlink:


cd /usr/lib64

ln -s perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so

IPTables

If you are running httpd and can't connect, try disabling IPTables:

/etc/init.d/iptables stop

SELinux

Determine if SELinux is currently running:

sestatus