bash

Making the Shell Play “nice”

Being a big fan of the shell, I make it work hard for me. Often times the commands I’ll issue through the shell are greedy and eat CPU cycles like candy. Sometimes those commands might take several minutes to complete, and I want my CPU’s priority to be focused on other things (like letting me get back to blogging).To handle those special situations for me, I use the “nice” command. It’s really easy. You simply precede any command with the word “nice” and it works it’s magic.

For example, when I’m backing up my email and favorites, I can use the command like this:

nice tar -cf mybackup.tar outlookdata.dat myfavorites.dat

You can tailor nice’s effectiveness to suit your needs, using the -n argument. For example, maybe I want my backup to be priority so that I can get back to what I’d rather be doing. In that case, I’d use:

nice -n=-20 tar -cf mybackup.tar outlookdata.dat myfavorites.dat

Possible values range from -20 (least “favorable”) to 19 (most “favorable”).

Edgy Eft
Feisty Fawn
Shell
Tips & Tricks
bash

Comments (0)

Permalink

bash Wednesday - alias

One of the best tips I can give on using the command line to your advantage is to grab a hold of the “alias” command. You’re going to be typing a lot of commands, and with Ubuntu, through the bash shell’s glorious “alias” command, they’ll be fewer and shorter.

The alias command allows a shell user to provide their own set of alternate commands for commonly keyed instructions.

The default install of bash includes a few basic aliases, some different modifications of a regular listing of files. Try “ll” for example. While it’s not a command included in Ubuntu and no binary exists for it, the command still provides a more verbose listing of the files. That’s because bash has already defined that alias for you (unless you’ve removed it).

I use the command to make it easy to start and stop my mail server.

alias fymail='vmware-cmd /home/vmware_machines/fymail/fymail.vmx'


Afterwards,

I can use

fymail start

or

fymail suspend

It may take a little practice and some experimenting, but they save me a lot of time and keystrokes.

You’ll want them to load in your startup of course, so I suggest using

gksu gedit ~/.bashrc

to save your alias commands for future sessions.

Shell
Tips & Tricks
Tutorial
VMWare
bash

Comments (0)

Permalink