Aliases, what are those aliases?
Well, in in real life, aliases like a short name or easy a name or something easier to remember.
So I'm sure everybody has like a nickname when you were growing up.
And just like other people who are very famous, just look at 50 cents he has.
His real name is Curtis James.
And there's another one like another example would be Pitbull.
His real name is Armando Perez.
So those are the real names, but their aliases is shorter.
So the shorter version and shorter name they have is because it's easier for people to remember them
just the same way aliases work in the next two.
So they are very long commands that you run almost every day, but you need a shorter version of it.
And how do you create a shorter version or a shorter word for it is by creating aliases.
So again, this is very popular command that is used to cut down on lengthy and repetitive commands.
And some of those examples that I have listed here, we will cover those examples one by one in our
Linux machines.
And they say, you exactly know what how Elissa's work and we'll go into Arkology machine console terminal
and we will try these aliases command one by one.
So the first command I have an alias is less so oftentime if you want to know all the files with minus
L and a option to listing or a four to also show the hidden files, we will run the command s minus
L-A or A-L and you will see all the listing of the files and directories we have in our home directory.
And this is our home directory.
So we will run the command oftentime.
You'll forget the options.
So what we do will create an alias, so we'll create alias and instead of just all create l equal code
else minus l got close and just hit enter.
Once you hit enter and you don't get an error message back, it means the alias is created.
Now how do you verify if it's created by simply running an alias.
But l l was r alias and let's run it and there you go.
We got the output as if you were under your command.
Let's create another alias.
The other alias.
What it will do, it will do the D for you and also do less for you sir to come out in one shot that
you would.
You don't have to run twice so we'll do p lpl.
I picked the word just for working directly and else.
Equal code P.W. D and you separate each command with semicolon and else and code close you hit enter
and now I'm going to type L.
I should get PWP in Alaska.
Man running.
So first let's clear the screen and I'm going to write p l and there you go.
So the first command it ran was probably the next command ran ls.
So every time I log into a system I'll just do peel and it will run those two commands for me.
Let's keep going on and let's try our third one which has three commands.
Who am I.
Hostname and PWP.
So I want you to create that alias on your own.
I'm going to go on to the next one.
Next one is it will list all the directories inside of my home directory.
I can run the command ls minus L and add that and the cap right here that you see which is on top of
number six, that's, it's telling the grep group everything that starts with D, so I'll run that and
you'll see it creped everything and the output that starts with D.
So of course anything that starts with D is what is a directory.
So that's what it's getting.
So I'm going to create an alias for it and I'm going to call a D are equal.
Coat police minus L and I'm going to grab it.
The D and cleared the screen and let's see if it's working by typing Dyax and yes, it is working,
then I'm going to try the last command in my list.
So what last comment is doing?
Sorry, I just have to move this a little more and of see the last command so last command is doing
is of course it's doing D.F. minus H, let's run deep minus eight, which will output your petition's
information the size where is it mounted and how much is used.
And the next command it's doing the minus eight is printing its porking.
The last column I believe he has $ six close.
And you will see it is showing you.
Let me make this smaller to.
So it's listing all everything that is in the last column, which is a column six.
Now I want to get in that output.
I want to get only the first four characters of this output.
So I'm going to run the command again and I'm going to do cut minus see one through four and enter.
And there you go.
This is what it's telling me, that the last column these are the petitions that I have in my Linux
distribution.
Sometimes you do wire to run that command just to find out what petitions you have.
You don't want to look at other other information that Deputization gives you.
So I'm going to create an alias for that.
So I'll just hit a barrel key, of course, to bring the command back.
I'll go back all the way to the to the beginning of the line by hitting the left arrow key.
I'll type alias and I'm going to name this alias as just D equal.
Of course I have to put quotation here, double code and there is one little things you have to change
here is you see here dollar sign in Linux dollar sign has what meaning if you guys remember, dollar
sign is actually outputs a variable whatever that you have variable inside that you attach in the scripting,
it actually puts it in there.
So it will think that it's a variable too.
So we don't want to tell you it's variable.
So how we could change that or how we could tell Linux not to think it as an alias.
So he has a variable to put backslash after putting the backslash move all the way to the end and hit
quotation close hit enter and it created my alias.
Now, if I do this again, let's clear the screen.
I'm going to do a again.
And it's doing exactly the same thing we wanted to do except with the with all that long, tedious command
you to have to run it all the time.
So it's much easier every time you log into the system, you type D and you get your information.
Isn't that cool?
It is very cool because that's why most of the time people use aliases.
So it will be easier to remember and do the tedious work in a very short amount of time.
Now where are those aliases created once you type aliases without any running a creating a new Comanche's
type Eleusis hit enter, you will see right here.
It will give you all the aliases that I have created, you know, knows right here.
This is what he's done to another one right here.
And then there another one right here and the last one, no, this was are the ones that are already
created.
It's already there by the system, by default.
It's already there for us.
So I don't have to touch it.
Now, what if I wanted to remove that alias from the list of aliases that created simply there's a command
to do it as an alias and you type the alias name.
So if you notice the first alias we have, we have a list name just somewhere, just how deep it unlisted.
Let's see if it still exists.
You just type alias and see if the alias exists there or not.
It does not.
It's gone.
There's another alias dya.
I'm going to an alias as well, the IRS and then I'm going to try to check if it's there.
Nope it's gone.
So it's just that simple is masking something.
It's telling, it's creating a shortcut key for you to run in Linux environment.