10 Good UNIX Usage Habits

Michael Stutz has a very nice article on IBM that covers 10 Good UNIX Usage Habits for the command line.

Adopt 10 good habits that improve your UNIX® command line efficiency — and break away from bad usage patterns in the process. This article takes you step-by-step through several good, but too often neglected, techniques for command-line operations. Learn about common errors and how to overcome them, so you can learn exactly why these UNIX habits are worth picking up.

Here is an example:

Make directory trees in a single swipe

Listing 1 illustrates one of the most common bad UNIX habits around: defining directory trees one at a time.

Listing 1. Example of bad habit #1: Defining directory trees individually

~ $ mkdir tmp
~ $ cd tmp
~/tmp $ mkdir a
~/tmp $ cd a
~/tmp/a $ mkdir b
~/tmp/a $cd b
~/tmp/a/b/ $mkdir c
~/tmp/a/b/ $ cd c
~/tmp/a/b/c $

It is so much quicker to use the -p option to mkdir and make all parent directories along with their children in a single command. But even administrators who know about this option are still caught stepping through the subdirectories as they make them on the command line. It is worth your time to conscientiously pick up the good habit:

Listing 2. Example of good habit #1: Defining directory trees with one command

~ $ mkdir -p tmp/a/b/c

You can use this option to make entire complex directory trees, which are great to use inside scripts; not just simple hierarchies. For example:

Listing 3. Another example of good habit #1: Defining complex directory trees with one command

~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}

In the past, the only excuse to define directories individually was that your mkdir implementation did not support this option, but this is no longer true on most systems. IBM, AIX®, mkdir, GNU mkdir, and others that conform to the Single UNIX Specification now have this option.

For the few systems that still lack the capability, use the mkdirhier script (see Resources), which is a wrapper for mkdir that does the same function:
~ $ mkdirhier project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}

Read more..

5 Free Linux Backup Solutions

If you’ve ever lost data due to a system crash, you know how crucial backing up important files can be. Here are 5 Linux Backup Solutions you should check out. I recommend you implement at least one of these Linux Backup Solutions before it’s too late.

rsync

There are tons of Linux users and administrators out there who have customized rsync scripts to handle incremental backups automatically on a daily, weekly, or monthly schedule. From the manual, rsync is described as a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies this package.

Here are a few resources for learning how to set up a Linux backup solution using rsync:

http://www.mikerubel.org/computers/rsync_snapshots/

http://finmath.uchicago.edu/~wilder/Security/rsync/

http://www.sanitarium.net/golug/rsync_backups.html

mondorescue

Mondorescue backs up your GNU/Linux server or workstation to tape, CD-R, CD-RW, DVD-R[W], DVD+R[W], NFS or hard disk partition. In the event of catastrophic data loss, you will be able to restore all of your data [or as much as you want], from bare metal if necessary. Personally, I like using Mondorescue to create DVD disk images of my system periodically. Upon initial installation and configuration of my Linux or Windows machine, I create a DVD disk image with Mondo so that if anything ever gets screwed up, I can pop in the DVD disk and restore back to my original configuration. The mondorescue team is great and the lead developers of the project are very active on the public mailing list offering help to normal users whenever needed.

Simple Backup Suite (Ubuntu, Gnome)

If you’re running Ubuntu Linux and are looking for a quick backup solution, I suggest checking out Simple Backup Suite, or sbackup for short. Simple Backup Suite is a simple backup solution intended for desktop use. It can backup any subset of files and directories. Exclusions can be defined by regular expressions. A maximum individual file size limit can be defined. Backups may be saved to any local and remote directories that are supported by gnome-vfs. There is a Gnome GUI interface for configuration and restore.

Amanda

AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that allows the administrator to set up a single master backup server to back up multiple hosts over network to tape drives/changers or disks or optical media. Amanda uses native dump and/or GNU tar facilities and can back up a large number of workstations running multiple versions of Unix. Amanda uses Samba or Cygwin to back up Microsoft Windows desktops and servers.

Bacula

Bacula is a set of computer programs that permits the system administrator to manage backup, recovery, and verification of computer data across a network of computers of different kinds. Bacula can also run entirely upon a single computer and can backup to various types of media, including tape and disk. In technical terms, it is a network Client/Server based backup program. Bacula is relatively easy to use and efficient, while offering many advanced storage management features that make it easy to find and recover lost or damaged files. Due to its modular design, Bacula is scalable from small single computer systems to systems consisting of hundreds of computers located over a large network.

Speed up your Linux System with Preload

Techtrob writes:

Preload is an “adaptive readahead daemon” that runs in the background of your system, and observes what programs you use most often, caching them in order to speed up application load time. By using Preload, you can put unused RAM to good work, and improve the overall performance of your desktop system.

Check out some of the numbers,

Application “Cold” Startup Time Preloaded Startup Time
Desktop Login 30s 23s
OpenOffice.org Writer 15s 7s
Firefox 11s 5s
Evolution 9s 4s
Gedit Text Editor 6s 4s
Gnome Terminal 4s 3s

Read more..

Switching from Microsoft Office to OpenOffice.org

Great writeup on How to Switch from Microsoft Office to OpenOffice.org:

How to set up OpenOffice.org to work how you want it with templates and clip art, configurations, shortcuts, and more (download the PDF file for this article)

Switching to OpenOffice.org: Step 1

The first step, of course, is to get the software. Here are some options:

Then install OpenOffice.org. Just double-click the downloaded file, or follow the instructions for installing it for your operating system here. http://download.openoffice.org/common/instructions.html

Read more..

Quickzi: Stop Syslog from putting –MARK– in the logs

By default, the syslog daemon will place –MARK– messages in your /var/log/messages log file every twenty minutes. This can get annoying and eventually lead to a waste of space. Heres a quick tip on how to stop syslog from putting –MARK– in the messages log.

  1. Edit the syslogd file. (In Ubuntu, this file is located in /etc/default/syslogd – on some other distributions, you’ll want to edit whatever file starts up the syslog daemon.)
  2. Locate the following line that starts with:

    SYSLOGD=”"

  3. Modify this line to read:

    SYSLOGD=”-m 0″

  4. Restart syslog:

    /etc/init.d/sysklogd restart

Cheers!

Basic Linux Security Tips

William Stearns has a good write up on Linux security tips for first time Linux users.

Here are a few:

  1. Set up regular updates for your particular Linux distribution
  2. Lock your system when you step away from it. To lock the Gnome graphical desktop, run the following command, part of the “gnome-screensaver” package:gnome-screensaver-command –lockFrom a text console, run this, part of the vlock package:vlock -aFor KDE, right click on the desktop and select “Lock Session”. In Ubuntu, press Ctrl-Alt-l (the letter “Ell”, configurable in System/Preferences/Keyboard shortcuts). All require the password of the logged-in user to continue work.
  3. Do your day-to-day work with a non-root account. When you need to do root-level tasks, become root with “sudo” or “su” long enough to do the task (alternately, log in as root on a text console for this task). http://www.stearns.org/doc/sudo.current.html

Go check out the rest of the tips.

Quickzi: Get rid of the Ubuntu splash screen during boot

Ubuntu Boot Screen

Have you ever wondered what goes on behind the Ubuntu splash screen during the boot process? You know, the screen that has the orange progress bar and the Ubuntu logo. You may want to see if anything is failing during the boot process, or you may just want to see exactly what takes place behind the scenes. If you’re curious, theres a quick and easy way to get rid of it.

Get rid of the Ubuntu Splash screen temporarily:

  1. Reboot your computer
  2. Hit “Esc” when prompted in order to enter the GRUB menu.
  3. Select the proper kernel and hit the letter “e” to edit.
    Ubuntu Grub Menu
  4. Arrow down to the Kernel line, and hit the letter “e” again.
    Ubuntu Grub Menu
  5. You should see the last few words in the line. Remove the words “quiet splash” and hit enter.
    Ubuntu Grub Menu
  6. Hit the letter “b” to boot the kernel without the Ubuntu splash screen. Below is what it will look like.
    Ubuntu Grub Menu

Get rid of the Ubuntu Splash screen permanently:

  1. From the command line, edit the /boot/grub/menu.lst file. Near the bottom of the file, you will find some lines similar to this:

    title Ubuntu 7.10, kernel 2.6.22-14-generic
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=xxxx ro quiet splash
    initrd /boot/initrd.img-2.6.22-14-generic
    quiet

  2. Change the above to look like this:

    title Ubuntu 7.10, kernel 2.6.22-14-generic
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=xxxx ro
    initrd /boot/initrd.img-2.6.22-14-generic

  3. Save the file and exit.

Cheers!

Quickzi: How to determine file types on Linux

Need to find out what all the file types in a certain directory are? Simple!

Execute the following on the command line:

find /path/here/ -type f -print | xargs file

I typed: find /home/adam/test/ -type f -print | xargs file

The output will look something like this:

/home/adam/test/music.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz
/home/adam/test/package.deb: Debian binary package (format 2.0)
/home/adam/test/file.tar.gz: gzip compressed data, from Unix, last modified: Tue Jun 20 12:51:11 2006
/home/adam/test/widget.xml: ASCII text, with CRLF line terminators
/home/adam/test/logfile.txt: empty

Cheers!