Tutorial - Bash For Beginners

Name: Matthew Franklin

Brief Description Of Your Talk: Tutorial on BASH for Beginners

Running Time: About 30min


To present a simple tutorial for beginners to bash, covering the basics. I want to start by showing how to use such commands as ls, cd, pwd, etc. Then I will move on to slightly more advanced material like using options (e.g., ls -la. This will show how a very simple command can become very powerful.

What is Bash?

Bash is a shell. The word Bash stands for Bourne Again SHell. A shell provides an interface to the OS. In Bash's case it's a command line interface. This means that you control the computer, through the OS, by entering in a series of text commands. For example when you type in ls, this will tell the OS that you want a list of what's in the directory (also called a folder) that you're under. The OS fetches the information and hands it back to the bash shell which then spits it out in a human readable form.


A couple of things we need to talk about before we begin typing in commands.

The Unix file system is hierarchical. That means that Unix file systems, if you would draw them out, have a tree like structure. The main directory or as I'll sometimes refer to it is the / directory. This directory contains all the other directories. You use commands under Bash to move between these directories and to alter the contents of the directories.

Another concept we need to look at is prompts. If you take a look at a Bash screen you will see that before the flashing cursor is what they call the prompt. The prompt is there waiting for you to enter a command. In Bash it often contains useful information. Depending on how it's been setup it might contain your username, the machine name. At the end of the prompt you will see a $ or a # sign. The $ indicates that your a normal user. If you have # that mean that your in superuser or admin mode.

This then brings us to an important point. Unix was designed from the outset to be a multiuser OS. Right from the word go it was decided to divide users into 2 main groups.

Standard user: These are users that have just enough access to get what they need done done. They are prevented from modifying system files etc.

Admin/Superuser: This user (because you only tend to have one of them) has full permissions under Linux to modify the system files etc.

Basic Bash Commands

Bash commands are entered in a very simple format. Often but not always in the form of command -Options A good example of this is the ls command. ls -la where ls is the list command and -al is the options.

ls is the list command. It provides a simple list of what is in the directory. "List"

pwd shows you where you are in the directory tree. "Print Working Directory"

cd Allows you to move between directories. cd .. will take you down one directory cd subdir/ will move you up to the subdirectory called subdir and cd /etc/network/ will move you from your current place to a new trunk. "Change Directory"

cp This command copies files from one place to another. example cp /home/me/mytestfile.txt /home/me/testdir/. This leaves a copy in the original place. "Copy"

mv Very similar to cp except it doesn't leave a copy. It can also be used to rename a file. "Move"

rm Removes unwanted files. Example rm mytestfile.txt will delete or remove the file "mytestfile.txt". Be very careful with this command as you can delete the entire system. "Remove"

mkdir This command creates directories. Example mkdir mytestdir. "Make Directory"

rmdir This will remove directories provided there are no files contained within. "Remove Directory"

man command This will give you a list of the options contained within the command. Example man ls will show you that there is an option called a that gives you a complete list of all the files and l that gives more information about the files in the directory. "Manual"

cat Useful if you want to take a quick look at what's contained in a text file.

nano/vi/emacs These are very simple text editors.

A couple of tricks.

Tab Key The tab key is useful. The tab key will try to complete the command you have typed in. If it can't it will produce a list of possible options.

Up/Down Keys These enable you to cycle through the commands that you have entered. These are stored in the .bash_history file.