Hello everyone in this video we are going to learn.
One of the most interesting and powerful command in our Linux command line is Journey.
We are going to learn how to create and make our own commands ourselves.
How cool is that.
So remember that our Linux commands can be one of four different types.
They can be either a shell script or they can be a shell built in command or they can be an executable
program.
And finally they can be an alias.
And remember that without an alias can be used to define our own commands ourselves.
So right now we are going to learn how to create and make our own commands using the all mighty and
powerful Ilias command.
So before we do this you have to know a couple of facts or a couple of things here.
Every time or the first thing that you do whenever you want to make Eric a new command is you think
of a name right.
It's like a baby so every time a new couple have a baby they think of a name right.
So let's say that someone saying the name test.
So you want to create your new command and you want to call it test.
So before you actually go on and use this new name you have to check whether the system already uses
this name.
So and a very smart way to check for this is to use our command type.
So I will say type test and it tells me that test is already shell built in command.
So I can use it.
I have to think of another name that is not already used by the system.
So I will use something like invent.
So I would say type invent and it tells me that invent is not found.
So now I am able to use invent because it's not already used by the system.
OK so once I figured out my new command name I can go on and create my new command.
So here is the original syntax syntax on how to create a new command.
So you have to use the command Ill use then followed by your new command name.
Followed by an equal sign and there is no whitespace here.
You have to be careful with this.
And then between between double codes you can specify here what ever you want your command to do.
So for example I will call my command invent as we said invent equal between double codes.
I will tell it what to do.
So every time I enter event I wanted to change to my desktop.
I wanted to make a directory called directory one.
I wanted to make a file called file 1.
I wanted also to show the date and the calendar and that's it for now.
So as you can see I separated by every command separated by a semi colon here because we know that we
can execute multiple commands on the same line if we just separate them by a semi-colon.
So here I take advantage of the of combining multiple commands in the same line.
OK.
So now once I'm done I just hit enter.
Here is the magic.
If I type in event and hit enter every thing here will be executed.
So let's see.
As you can see it shows me the date it shows me the calendar and it already created directory 1 and
file 1.
Awesome.
Yeah that's is one example of how to create a new command.
Now let's think of another use.
So imagine that like every day I open my work directory in the morning and then I open my files directory.
Then I have to do directory and then I have a list finally I have a list here that I check regularly
every day.
It's like a to do list.
So for me as a system administrator I have to check this list every day to see what I have to do to
I have to update the system back up the system and the users remove users and change permissions etc..
So every day it will be very tedious and time consuming too.
So for example let's see.
So first I'll be at my home directory right.
So every day working on my terminal of course I have to go to the desktop.
Then I have to go to my work directory into my files to my to do.
Then finally I'm able to see my list.
OK so I think it is very time consuming.
So instead I can make a command that will open my list with just one word.
So for example I will I want to create my command and I will call it open.
So let's see it open in the really used key open or the read is already used by my system.
So I would think of another name let's say open fire.
And it tells me that open file is not found.
So I can use open file.
Actually I will use another name.
I will say to do want to do is not found awesome.
So now I can use my new command name to do to open my to do list here.
OK.
With just one word.
So it's really easy.
All I need to do is just say Ilias to do because without any spaces then I will change to my desktop.
I'll change to my Or I can do this I can say gee it
my desktop
then my files in my to do and my list.
So right now
if I execute this.
So right now if I say to do it will open my list as you can see it's magic.
Guys it's very very helpful.
So instead of every day I wake I wake up in the morning and then I have to go to work but first and
have to go to desktop.
I have to go to work load of files to do.
And then finally I'm able to open my list.
All these things are just saved when I say
so if I just say to do and hit a this just happened right.
So as you can see you can you have different.
You have like infinite possibilities for the benefits of creating of being able to create a new command.
So I will make another two or three pages and explaining the usefulness and the benefits of creating
an alias command.
But for now I want you guys to practice with the alias commands.
So yeah that's it for this video.
Ciao.