David R. Heffelfinger

  Ensode Technology, LLC

 

Linux Command Line Tricks


There are several "shells" that can be used in the command line for Linux and Unix systems.

The default shell for most Linux distributions such as Ubuntu and Fedora is called bash, which stands for "Bourne Again Shell", bash is an improved version of the Bourne Shell.

The first feature I would like to mention is tab completion.


  • Typing the first few letters of an executable command, then hitting tab completes the command.
  • After entering an executable command, hitting tab again shows a list of available arguments. Typing the first letter of the argument then hitting tab shows a list of arguments that start with that letter.
  • tab completion is especially useful to change directories, for example, to change directories to /home/david/Documents we could simply type "cd /ho<tab>/da<tab/Do<tab, saving us several keystrokes.

In addition to tab completion, the !$ character combination can be used for substitution, for example, if we were examining a file with the cat, more or less, then we realized we need to edit it, we don't need to type in the file the second time around:

less foo.txt
vi !$

The second line is equivalent to vi foo.txt, the !$ character combination is substituted for the last argument in the previous command.

The !! character combination executes the last command executed, preventing us from having to type it again.

We can view the history of the last several commands entered by using the history command, the output would look something like this:


476 ls
477 ls -larth
478 su
479 history |grep sudo
480 ls
481 ls f*
482 ls -ld fo*
483 cd
484 history

Of course, typical output is much longer, in any case, if we want to re-execute any command in the history, we simply need to enter it's number in the history preceded by an exclamation point, for example, if we wanted to re-execute command number 482, all we would need to enter is:

!482

We can also navigate through the history by simply using the up and down arrows, the up arrow shows the previous command in the history, the down arrow shows the next command in the history.

Knowing these bash shell scripts help us be very proficient with the Unix command line, which I miss dearly when I am using a Windows box (by the way Cygwin provides a bash shell for Unix systems).

Ubuntu Intrepid Ibex is coming, worth the upgrade?


Ubuntu 8.10, also known as Intrepid Ibex, is about to be released soon.

I downloaded the release candidate and installed it under VirtualBox, an open source virtual machine that allows operating systems to be installed inside other host operating systems, similar to VMWare.

My impression of Intrepid is that it is not much different from Hardy Heron, the main difference is that it has updated versions of all the included applications.

Having written three books using OpenOffice.org, my one wish list is an updated version of this free and open source office suite. Unfortunately I found out that Ubuntu Intrepid Ibex does not come with OpenOffice.org 3.0, which is the recently released latest version.

I'm sure OpenOffice.org will end up in the Ubuntu Backports repository, but it feels kind of "hackish" to have to install it that way. It would be nice if OpenOffice.org 3.0 was included by default.

I may end up upgrading anyway, just to get updated versions of other applications, however I don't have that "must update now!" feeling I've had when other versions of Ubuntu were released.

 
 
 
 
 

October 2008 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
8
9
12
14
16
18
19
20
21
24
26
28
29
30
 
       
Today

 
© David R. Heffelfinger