From the category archives:

Code

Using Linux Tail to Trim Your Files

by Ron on October 24, 2008

This tip is for my friend Scarb. For years I’ve used the Linux command “tail -f” for watching logs… but only recently did I discover its versatility for extracting parts of files.
Need to grab only the last 25 lines of a file?
tail -n 25 somefile.txt
How about the last 200000 bytes redirected to another file?
tail -c [...]

{ 1 comment }

Set Zabbix to Run at Startup on Linux

by Ron on October 20, 2008

nano /etc/rc.local
and add
/etc/init.d/zabbix-agent start

{ 0 comments }

Sync your files across multiple machines

by Ron on September 15, 2008

Dropbox is a service that allows you to keep files synchronized across multiple machines (and multiple platforms).

Click through and checkout the video. It’s pretty slick!
Here is some additional info from ars technica.

{ 0 comments }

I contributed to a Handbrake forum a while back. Thought you might find it useful too.
This is my evolving script for transcoding DVDs from MacTheRipper.
1) Save the file in a logical place (I keep it in the Movies Folder… same place I rip movies to). It will loop through all titles longer than X.
#!/bin/sh
# usage [...]

{ 0 comments }

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 }

Use cURL instead of wget on Mac OS X

by Ron on July 2, 2008

I use wget all the time on my Linux machines, but was surprised to find it missing on my MacBook Pro. Since Mac OS is based on BSD, it uses cURL instead. Here’s a good way to scrape files from a remote server.
curl -O http://www.gutenberg.org/files/21171/mp3/21171-[01-24].mp3
Man page is available at: http://curl.haxx.se/docs/manpage.html

{ 0 comments }