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.
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
stands for: (list)
This command is used to list out contents of a directory.
typical usage and sample output:
$ ls
file1 f1le2
file3 file4
- pwd
stands for: (print working directory)
This command is used to print out the current directory you're in.
typical usage and sample output:
$ pwd
/root/home
- cd
stands for: (change directory)
This command is used to change from the current directory you're in to another directory.
typical usage and sample output:
$ cd demoDirectory
demoDirectory $
- mkdir
stands for: (make directory)
This command is used to create a new directory.
typical usage and sample output:
$ mkdir newDirectory
- cat
stands for:(concatenate)
This command is used to print unto the standard output the contents of the file specified.
typical usage and sample output:
$ cat file1
I am the content of file1.
- rm
stands for: (re move)
This command is used to remove (delete) files from a directory.
typical usage and sample output:
$ rm file1
- touch
stands for: (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.
typical usage and sample output:
$ touch newfile
- echo
stands for: (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.
typical usage and sample output:
$ 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
stands for: (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.
typical usage and sample output:
$ 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
stands for: (who am i)
This command is used to print out the name of the current user of the shell.
typical usage and sample output:
$ whoami
username1
Basic Exercise
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 ππβ₯οΈ
Top comments (6)
thank you
Amazing and quite clear
Thank you
Why doesn't this post have a million more likes?
Thanks reid... u're awesome π
Good Bless you Thank you really for your help Keep going
You are very welcome π. Thanks