Monday, March 3, 2008

Bash and command line (terminal)

OK, so you've undoubtedly come across some problem and found a post which says you need to open a terminal and run some series of commands. You ask yourself, what is this terminal and why am I typing commands and what do they mean?

Well, using a terminal program like konsole or xterm simply allows you to access the bash shell from your session. Think of the bash shell as a DOS session on steroids.

Bash stands for the "Bourne Again SHell", and is a collection of commands which allow you to program via a series of commands, scripts and system programs which can either be called directly from the CLI (command line interface) or saved in a text file and executed directly from there or at some later time.

In fact, all the core start-up scripts for Ubuntu's (and most Linux) system are bash scripts, which tell the system what services to start/stop and when to do this.

I highly recommend that anyone using a Linux distro learn at least some basic bash. There are plenty of great resources on the net, like the Linux Documentation Project and the Bash homepage.

To give you a brief example, I'll explain some common commands:

cd - change directory (ex: cd /etc/apt). Use this command to specify a directory to work from called CWD (current working directory). You can also type 'cd' by itself to return you to your home directory, or use 'cd ..' to go up/back one directory.

ls - list contents of the CWD or directory/file (if specified) (ex: ls *.odt).

rm - remove a file (i.e. delete it) (ex. rm test.txt)

mv - move/rename a file (ex. mv *.odt Documents/)

man - man page which give more explanations than I have on above (ex. man ls)

Anyway, be adventurous and read a litle on bash. You will find it is not all that difficult or scary to perform simple and basic tasks with ease.