RootAdmin.co.uk

Learn the Linux shell – Part 1…

by Rootadmin on Jun.15, 2009, under Linux tutorial

Learn the Linux shell – Part 1…

Well I am no master in Linux by no stretch of the imagination, I can get my way around a Linux shell, perhaps slowly, but I get there. As many people have taught me some of their knowledge and helped me along in life even if they could not really afford the time, I am a big believer in helping people where I can. I start with the these rules,

· No one is stupid, and they just need some help and

· There’s no such thing as a stupid question, you won’t believe how often the answer to one question just clicks multiple other questions and answers into place

· No one is ever too old to learn

Learning is a fantastic thing and so different for each person, if you enjoy learning about learning you should look up a guy called Marc Prensky – “Marc Prensky is an internationally acclaimed speaker, writer, consultant, and designer in the critical areas of education and learning”. In particular his articles about Digital Immigrants and Digital Natives

Anyway….. Back to class.

I will presume in this article you have just installed Linux and have no prior experience of Linux and are sitting in a terminal window.

The Linux shell is a command line utility designed to allow the user to interact with the operating system, it passes any valid command (either from a user or from a file) to the Linux kernel.

There are different versions of the Linux shell; all have slight small differences from each other.

You can easily find out which version of the shell you are running by typing:

echo $SHELL.

I use bash as this is the default for Ubuntu.

NOTE: Bash is with most shells is case sensitive

We may at a later date need the date and time to be set up correctly, might as well do it now.

Ok, so let’s start with the basics, lets ensure your clock is correctly set. From the shell type

Date

Ok so first rule to Linux, never run as root. Ok so you have probably come from a windows background and can’t possibly imagine running all day long without admin rights but i promise you in Linux, you really don’t want to or need to. I’ll explain more later.

For now let’s find out which user we are currently logged in as. At the shell type

Whoami.

Ok so now lets change your password, at the shell type

Passwd

Enter your current password, your new password and confirm your new password.

Let’s move on

File structure

The files on a Linux system are stored in what’s called a hierarchical directory structure, whats a hierarchical directory structure when it’s at home? Simply put this means that files are organised in a tree like pattern of directories (or folders) which may contain more directories or files. The very first folder of the Linux file system is called the root directory. This contains multiple other directories (referred to as sub directories) and files which also contain multiple other sub directories.

Linux does not use the idea of drive letters or splitting the file system up like that and creating multiple tree structures, instead everything comes off of one tree structure.

So, when you log in to you linux box (box is just another name for a system), the working directory is set to be your home directory. This is where you put your files, alot like “My Documents” on a windows box. In most cases your home directory is simply /home/your_user_name, but this may have been changed by a system administrator (if you haven’t set up the linux box). So let’s find out.

To view your current working directory you type the command

Pwd

Pwd is short for “print working directory”

Now let’s see what files and directories we have in our home directory. To do this type

ls

ls simple lists the contents of the working directory.

Ls is a very powerful tool as it has lots of extra options available to it. We will look at more of ls in another article

For now let’s create a new directory for us to play with, let’s call this folder stuff, to create a new directory we use the command

mkdir folder_name

mkdir as in make directory. So lets make our directory by typing

mkdir stuff

now if we type ls we should see a new directory that wasn’t there before, ok so lets go into that folder. To navigate to a new directory (by which i mean a different directory from that of the working directory) we type

cd folder_name

cd simply means change directory, so to get into our “stuff” directory we type

cd stuff

Whilst on the subject of cd I will show you how to move back up the directory tree one folder at a time, so in this example our current shell prompt looks something like

liam@linux: ~/stuff

Now if we type the command cd ..

We can move backup the directory one folder at a time

I think we have learnt enough for one small lesson, so we will leave it there and return to learn some more linux shortly

:, , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop me a comment

Links!

A few links to other sites of mine...