Find Large Files in Linux

This doesn’t work perfectly, but I often use it to start tracking down disk hogs:

To return the 10 largest items in a given directory:

du -cksh * |sort -rn |head -11

Some times it’s helpful to view all

du -cksh * |sort -rn

If someone has a better approach, please comment.

Find Failed Login Attempts in Logs

Looking for a log to show you failed login attempts to your Linux machine? Look in:

/var/log/btmp

You can access it by running:

/usr/bin/lastb

It’s similiar to the wtmp log of user login/logouts and the utmp log showing who is currently logged in.

Change Runtime Settings for Linux Servers

I install RHEL on all my production machines and CentOS on all my test/development boxes. Installing the GUI is helpful for configuration, but you sure don’t want to run them that way all the time. So after everything is installed, configured and tested, I make the following change:

nano /etc/inittab

Change

id:5:initdefault:

To

id:3:initdefault:

Save the file and reboot the machine. When you want to launch a GUI, just run:

startx

Add a Virtual IP Address in Linux

nano /etc/sysconfig/network-scripts/ifcfg-eth0

Should look something like this


DEVICE=eth0
BOOTPROTO=static
BROADCAST=172.16.0.255
HWADDR=00:00:00:00:00:00
IPADDR=172.16.0.2
NETMASK=255.255.255.0
NETWORK=172.16.0.0
ONBOOT=yes

Duplicate that and open the new file

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
nano /etc/sysconfig/network-scripts/ifcfg-eth0:0

Change device name, set new IP, remove reference to hardware


DEVICE=eth0:0
BOOTPROTO=static
BROADCAST=172.16.0.255
IPADDR=172.16.0.3
NETMASK=255.255.255.0
NETWORK=172.16.0.0
ONBOOT=yes