Posts tagged as:

linux

Find what version of Linux

by Ron on August 13, 2008

To find what flavor of Linux you’re using:
cat /etc/*-release
To find the version, use:
uname -a

{ 0 comments }

Find Large Files in Linux

by Ron on August 1, 2008

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.

{ 0 comments }

Find Failed Login Attempts in Logs

by Ron on August 1, 2008

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.

{ 0 comments }

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. [...]

{ 0 comments }

Add a Virtual IP Address in Linux

by Ron on July 5, 2008

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

{ 0 comments }

Restart Ensim via CLI

by Ron on July 1, 2008

After a few months of continuous use, I’ve found Ensim to start using too much swap space and getting sluggish. A quick restart via command line, always fixes both:
/etc/init.d/epld restart

{ 0 comments }

Pause a Linux Shell Script using Sleep

by Ron on June 26, 2008

It’s easy to pause a shell script during execution. Just add:
sleep 10
(where 10 is the number of seconds you want the script to pause.)
Some code for testing would be…
#!/bin/sh
before=”$(date +%s)”
echo $before
sleep 3
after=”$(date +%s)”
echo $after
elapsed_seconds=”$(expr $after - $before)”
echo Elapsed time for code block: $elapsed_seconds

Have other ideas? Please comment.

{ 1 comment }

Files > 50M older than 4 years

by Ron on June 26, 2008

find /somedir -type f -size +50000k -mtime +1095 -exec ls -lh {} \; | awk ‘{ print  $6 “/” $8 ” ” $9 $10  $11 “: ” $5 }’

{ 0 comments }

Shell script date calculations

by Ron on June 23, 2008

#!/bin/sh
before=”$(date +%s)”
echo $before
sleep 5
Ymd=”$(date ‘+%Y%m%d’)”
echo $Ymd
after=”$(date +%s)”
echo $after
elapsed_seconds=”$(expr $after - $before)”
echo Elapsed time for code block: $elapsed_seconds

{ 1 comment }

I occasionally get this error when trying to run a heyu command from CLI. This should fix your problem:
(As root)
chmod 777 /dev/ttyS0

{ 1 comment }