Shell Navigations for Beginners
Tags: shell, tutorial, beginners, programming
Published: 2022-11-16 16:47:55

---
title:Shell Navigations for Beginners
published: true
tags: #shell #tutorial # beginners #programming
canonical_url: https://dev.to/sarahokolo/shell-navigations-for-beginners-2p3a
---
Shell navigations is all about being able to navigate the shell through a series of in-built commands that are used to perform various tasks.

## What is a Shell?

A shell is a computer program that serves as an interface which allows for direct interaction with the computer's operating system.

It can be referrenced to an actual real life shell in the sense that what it does is it acts as  the outermost layer of the operating system, just right after the kernel. 


![operating system hierarchy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5m4z5beu6yfgmdwturnf.gif)

In this article i would be focusing only on the Bash UNIX/Linux shell.

## What is Bash?
This is a command line interpreter based of the UNIX(UNiplexed Information Computing System) operating system.

This is one on the most commonly used shells out there.

> There are also other shells available as well like: **zshell**, **Cshell**, **KornShell**, **powershell** etc.

What it basically does, is that It reads commands typed in by the user and executes programs based on those commands. When a program finishes executing, it displays a new prompt to signify that it is ready to take in another command as it's done executing the previous one.

There are a set of in-built commands, that are used to communicate differenly with the operating system, and we are going to look at a few of the most basic of them that you are going to be needing quite often the more you interact with the shell.

##10 Basic Bash commands

- **ls** 

<u>*stands for*</u>: (list)

This command is used to list out contents of a directory.

<u>*typical usage and sample output:*</u> 

```
$ ls

file1 f1le2
file3 file4
```

- **pwd**

<u>*stands for*</u>: (**p**rint **w**orking **d**irectory)

This command is used to print out the current directory you're in.

<u>*typical usage and sample output:*</u> 

```
$ pwd

/root/home
```

- **cd**

<u>*stands for*</u>: (**c**hange **d**irectory)

This command is used to change from the current directory you're in to another directory.

<u>*typical usage and sample output:*</u> 

```
$ cd demoDirectory

demoDirectory $ 
```

- **mkdir**

<u>*stands for*</u>: (**m**ake **dir**ectory)

This command is used to create a new directory.

<u>*typical usage and sample output:*</u> 

```
$ mkdir newDirectory

```

- **cat**

<u>*stands for*</u>:(concatenate)

This command is used to print unto the standard output the contents of the file specified.

<u>*typical usage and sample output:*</u> 

```
$ cat file1

I am the content of file1.
```

- **rm**

<u>*stands for*</u>: (**r**e **m**ove)

This command is used to remove (delete) files from a directory.

<u>*typical usage and sample output:*</u> 

```
$ rm file1

```

- **touch**

<u>*stands for*</u>: (touch)🤷‍♀️
This command is used to create, change and modify timestamps of a file.
But it is most commonly used to create a new file that does not already exists.

<u>*typical usage and sample output:*</u> 

```
$ touch newfile

```

- **echo**

<u>*stands for*</u>: (echo)🤷‍♀️

This command is used to write a string to a file. If a file is not specified, it writes to the standard output by default.

<u>*typical usage and sample output:*</u> 

```
$ echo "hello world"

hello world 
```
Writing to a file.

```
$ echo "hello world" > file1

```
Now **file1** contains the string  

> hello world 

It can also be used to print out the value of an environment variable.

```
$ echo $variableName

value of variableName
```

- **mv**

<u>*stands for*</u>: (move)

This command is used to change the name of a file from one name to another. 
It can also be used to move a file from one directory to another.

<u>*typical usage and sample output:*</u> 

```
$ mv file1 file2
```
This has renamed the file **file1** to now become **file2**.

moving a file from one directory to another:

```
$ mv file1 someDirectory
```
This has moved the file **file1** from the current directory to a directory called **someDirectory**.


- **whoami**

<u>*stands for*</u>: (who am i)

This command is used to print out the name of the current user of the shell.

<u>*typical usage and sample output:*</u> 

```
$ whoami

username1
```

### <u>Basic Exercise</u>
Let have a look at a very basic exercise.

For instance let's say we want to change our  working directory to the **/root** directory, then create an empty file called **so_cool** in that directory.
All you have to do is:

```
$ cd /root
```
Now we are in our root directory, so let's create our new empty file now.

```
$ touch so_cool
```
This has created our file.
To check out if the file was created, you can simply just run the **ls** command to display the list of files in the root directory, your newly created file should be among.😊

> There a still a whole number of  bash commands out there that are used to perform various other tasks, but we can't cover them all.


That's it for this article guys...if you found it helpful, please don't forget to leave a like and also, don't forget to follow me for more content... see you next time 😊😊♥️