-
Hey, what's going on guys? I wanted to
-
make a video for people that are new to
-
Linux and new to the command line to
-
maybe help you out a little bit and show
-
you how to navigate the terminal and do
-
some very basic tasks. So a lot of people
-
ask me why I work on Windows in most of
-
my videos, and let me just clarify by
-
saying that I'm in no way of shape or
-
form a Windows Fanboy. I actually like
-
working on Linux better for web
-
development programming. There is a
-
few reasons why I have Windows installed
-
on my main machine. One is for the
-
recording software. I use Camtasia
-
which works flawlessly for what I need it
-
to do. And I haven't found a Linux-based
-
solution that works how I need it
-
to and processes the videos as fast
-
as I need them to. I also use Adobe
-
Photoshop and then a lot of other
-
Windows-based tools. I also have six
-
monitors, and it's a pain in the ass to
-
try and get them working with the Ubuntu
-
and working with the drivers.
-
I know I could do it if I really
-
tried, but it's just something that
-
hinders me. Another reason is gaming. I
-
have a pretty beefy system with SLI
-
graphics cards. And, obviously, if you
-
play games, you want to run Windows. Now,
-
that's not a huge deal because I very
-
rarely play games anymore because I'm so
-
busy. But that is one of the issues.
-
And then the main reason I use Windows
-
in a lot of my videos is because I'm
-
trying to reach everybody of all skill
-
sets. And chances are, a person that is
-
just learning HTML and front-end
-
development is running Windows. And they
-
may get lost if I'm using Linux or Mac.
-
Now, I know many of you do use Linux
-
or Mac, but I think that there's more of
-
a chance of a Linux or Mac user knowing
-
and understanding what I'm doing in
-
Windows than the other way around. So
-
that's probably the biggest reason. For
-
my own personal development, I do work on
-
Linux in a virtual machine. And
-
I'm going to start using Linux more in
-
my videos. So anyway, let's jump in and
-
learn some basic commands. Now, if you're
-
a Windows user I would suggest getting
-
something like VMware or VirtualBox and
-
installing a Linux distribution. You may
-
not want to go as far as to install it
-
on your main machine for your everyday
-
use, but you should get into it and start
-
to experiment with it. As far as distros, I
-
prefer Ubuntu or Debian, and there's
-
also- there's a lot to choose from, okay?
-
For beginners, I would recommend Debian,
-
Ubuntu, or even Linux Mint, openSUSE- sorry,
-
openSUSE, however you say it, is a little
-
more complicated, but I do like that as
-
well. So let's get into it.
-
Currently Ubuntu is using the Unity
-
desktop interface, but you can use a
-
different environment if you want. And
-
we're going to go and open the terminal.
-
Now, I use a program called Terminator. So
-
that's what I'm going to be using. If you
-
install Ubuntu fresh, you're going to
-
just have the regular terminal which
-
is this right here, but it doesn't really
-
matter. You use the same commands. All
-
right, so let's go ahead and just make
-
that a little bigger. Now, when you first
-
open your terminal, you're going to
-
be in your home directory, okay? Every
-
user on a Linux system has a home
-
directory, much like on Windows, if you go
-
to users, you have your usernames
-
for each account. So Linux does the same
-
thing. In fact, if we look at the file
-
manager, and you can see that actually
-
opens in the home directory as well.
-
If we go to the actual root directory,
-
it's going to be in home. And you'll see
-
I have a folder called 'brad', okay? I
-
only have one user on this system. So
-
over here, you can actually check your-
-
what path you're in with the command PWD,
-
okay? You can see I'm in home brad. So
-
that's the First Command. Now if you
-
want to show the listings like you do in
-
file manager in your command line, you
-
can use the ls, okay, the listing command.
-
And you can see that these are the same
-
folders that we're seeing here, all right?
-
Now, with commands, you also have options,
-
okay? Most commands have some options you
-
can use. Now with ls, we have an option
-
of -a. And what that does is it'll show
-
everything, even the hidden files, the
-
system files that begin with the dot,
-
it'll show those as well. By
-
default, those are hidden, okay? Much like
-
hidden files in Windows. Now we can
-
also use the -l. So if we say ls -l, and
-
that just shows us some extra
-
information. The time it was created, the
-
date, the size. Now, this here at the
-
beginning, this looks kind of weird.
-
What this is is the permissions of the
-
folder or file. Basically it's broken up
-
into three parts. The first is for the
-
owner, the permissions of the owner of
-
the folder or file. Then the permissions
-
for the group, okay, because you can also
-
have user groups and then the permission
-
for everyone else, for the rest of the
-
world, or the public. Now, these basically
-
stand for delete. The D is delete. Read,
-
write, and execute, okay? So basically the
-
owner of the folder or file has all these
-
permissions. They can do whatever they
-
want. The group can only execute and read,
-
and then the rest of the world can only
-
execute, okay? So they can't change
-
anything at all. That's what that is.
-
And then here you'll see brad brad.
-
The reason it says it twice is because
-
one is the user and then one is the
-
group, okay? So there's actually a group
-
called 'brad'.
-
And you can change these with
-
certain commands, but I'm not really
-
going to get into that today. I just want
-
to be- I want to keep things very basic.
-
So that's the ls command.
-
Now, the next command I want to
-
look at is mkdir, okay? And that is make
-
directory and it does just that. It
-
will create a directory, so let's create
-
a folder or a directory inside of our
-
home and let's call this- we'll call it
-
dir1, all right? And over here you can
-
see that now we have dir1. If we do ls,
-
you see dir1, all right? Let's create
-
another one called dir2.
-
Okay so now we have these two
-
directories. And the next command we're
-
going to look at is cd and that's change
-
directory. So if we want to go into
-
dir1, we can say CD dir1.
-
And you'll see that the prompt here
-
has now changed. It shows us where we are.
-
If we do pwd, it'll show us we're in
-
directory one, okay?
-
Now, if we want to go back one level,
-
back into the home, we can do CD space
-
dot dot. And so you can see now we're
-
back in the home, okay? If you want to
-
navigate to the absolute root of your
-
system, you could do cd and then slash.
-
And now if we do ls, you'll see we're in
-
the actual root of the entire system,
-
all right? If you want to go back home,
-
you could just do cd, and that'll bring
-
you back home. You can also do cd and
-
then this tilde, which is the key
-
that's to the left of the number one
-
key. And that basically represents
-
home. So we can do that. If we want to go
-
into dir2, let's say in the home, we
-
could do- from anywhere we could do the
-
tilde slash dir2, okay? And if we want to
-
go back out, go cd dot dot. And then let's
-
go back into dir1,
-
okay? Another helpful command is
-
clear. If we do clear, it'll just do just
-
that. It'll clear out the terminal,
-
all right? So you know how to
-
find your path. You know how to create
-
directories, how to list the contents, how
-
to change directories. That's very
-
basic. Now what we're going to do is
-
I'm going to show you how to create a
-
file. So let's say we want to create a
-
text file.
-
We could use the touch command. So we say
-
touch, we'll say file one dot text. And now
-
if we do an ls, you can see we have that
-
file one. Now, if we want to edit that
-
file, of course, you could do that from
-
within your file manager. So you could
-
just go to file one dot text, and I think,
-
yeah, it'll open with gedit if you open
-
it here. But you can also use command
-
based- command line-based text editors. So
-
the one that I would recommend for
-
for beginners is Nano, okay? It's very
-
easy to use. Now if we say Nano
-
file one dot text, it's going to bring
-
us into a screen like this. So this is
-
the Nano editor. And like I said, it's
-
pretty easy to use. Basically we could
-
just- let's just say hello world,
-
okay? Now, if we wanted to exit out, we
-
want to do a control 'x', and then it's going
-
to ask if we want to to save or not, okay?
-
So we're going to say y for yes and then
-
enter, and then that will edit the file
-
and save it, okay? So control 'x' to escape,
-
yes or no to save,
-
okay? And you won't get prompted if
-
you don't edit it at all, you won't get
-
prompted to save or not. Now, you can also
-
use the cat command to see what's in a
-
file. So we'll say cat file1.txt, and
-
it'll show us what's in it.
-
It basically takes the input and puts
-
it to standard output, which is what's
-
shown here. Now, if this is a really,
-
really long file and you have to page
-
down, you can use less instead of cat. So
-
file one
-
dot text, and you could- you'd be able to
-
page down, okay, and see the whole file.
-
And then to get out of it, you just want
-
to hit 'q' and that'll quit, okay? So that's
-
cat and less.
-
Now, let's say we want to rename
-
this file, okay? So there's a command to
-
move files and rename, and that's mv. So
-
if we say mv file1.txt
-
and space file2.txt,
-
okay? And then we do an ls. You can see
-
that uh file one has now been renamed to
-
file two and if we say cat
-
file2.txt you can see it's the hello
-
world
-
now we can also copy files so let's say
-
we want to take file two and create file
-
one but also keep file two then we could
-
do CP okay that's the copy command file
-
2.txt and we want to copy it to file
-
one.txt and now if we look at the
-
contents we have both files and if we
-
say cat file
-
one hello world okay so let's clear this
-
out
-
now we can move and copy to other
-
locations as well so if we want to let's
-
say copy file one.txt we want to copy it
-
to let's say um till day for the home
-
and then slash
-
dir2 SL
-
file1.txt
-
okay and then we'll switch directories
-
let's say
-
CD dot dot and then CD dir2
-
wh CD dur 2 and LS and there's the file
-
one okay so we can do that as
-
well now if you want to delete a file or
-
remove a file you can use the RM command
-
say Okay so let's say we want to delete
-
file one we can say RM file1.txt
-
and now if we look now it's gone all
-
right now if you want to remove a
-
directory let's go out to our home and
-
let's say we want to remove directory 2
-
we can do
-
rmd dur 2 okay so now if we do
-
LS directory 2 is now gone now I'm going
-
to put it back we're going to make
-
directory dir 2 and then I'm going to go
-
into
-
it and I'm going to create a
-
file so touch file1.txt and I'm going to
-
go back out to my rout and I'm going to
-
try to
-
delete dir
-
2 and now you see it says failed to
-
remove dir 2 directory is not empty so
-
this command isn't going to work if the
-
directory is empty if it's if it has
-
files in it and you want to delete it
-
you want to use RM but if you just do RM
-
dir2 it'll say can't remove it so you
-
need to add the dash capital r uh option
-
which is for recursive so you want to do
-
um rm- R and then dir 2 and now if we do
-
an LS dir2 is gone as well as all the
-
files that are in
-
it so let's clear that out and then the
-
next command I want to look at is which
-
so what witch does is it'll search for
-
um a a file or a folder's location and
-
give you that location so uh let's see
-
say we want to look for the mongod d uh
-
application which is the the mongod DB
-
server we could say which mongod D and
-
that'll show you exactly where it's in
-
it's in the the USR bin mongod D okay so
-
um that can come in pretty
-
handy uh so what else let's say let's
-
use the history command and history will
-
basically show you your last uh what is
-
it 500 or so 400 well I think it's your
-
last 500 commands
-
okay so that's that can be handy see
-
what you've been doing um or to see what
-
someone else has been
-
doing let's see what else so we we've
-
went over pretty much all the basics of
-
you know moving files and folders around
-
and deleting them and renaming them so
-
those those are the most important those
-
are the things that you absolutely need
-
to know um now some things you can't run
-
as your user you have to run it as the
-
root user and you never want to be
-
really you know mess around with stuff
-
logged in as the the the root user so
-
for that you could use pseudo so let's
-
try to run for instance app get update
-
which I'll go over in a minute um it's
-
not going to let us basically it says
-
that we don't have the permission to so
-
if we do
-
pseudo app get update it's going to ask
-
for our
-
password and then it'll run it okay uh
-
and that's just updating our packages
-
and I'll get to that in a second um so
-
you want to use pseudo to run run as
-
root let's clear this
-
out now let's look at some system
-
commands so these are you don't need
-
these to be able to to navigate or
-
anything but uh they're good to know so
-
first one is if
-
config and this is just like ip config
-
on Windows it basically it's going to
-
give you all your network information
-
your ethernet cards um your IP address
-
your local IP address um your loop back
-
things like that um pretty much
-
identical to IP config in Windows if
-
you've ever used that for wireless you
-
can do IW
-
config and that's going to show you I
-
don't have any Wireless on this machine
-
but if you did it would show you that
-
stuff okay um now if you want
-
to Ping another machine or uh over the
-
either over the Internet or on your
-
local network you could say ping for
-
instance let's say
-
google.com to see if that's online you
-
can see we're getting a we're getting a
-
response back from our request okay and
-
it's just going to keep going like this
-
but if you want to stop it you can do a
-
contrl c okay so if we try to Ping
-
something that's most likely not a
-
domain you'll see we get unknown host
-
okay so that's how you can tell if if
-
you can actually reach a certain machine
-
or not okay so let's look at some other
-
system commands um let's see we have
-
uname let's do un name- a that's going
-
to just basically give us a summary of
-
our system the operating system the
-
version uh things like that okay we also
-
have uh let's
-
do
-
BL uh BL I'm sorry
-
Blk and what that does is it basically
-
shows us our hard drive so I have a um
-
an uh my regular hard drive and then
-
what's called a swap okay so when Linux
-
partitions your drive it it puts a
-
little bit aside for a swap file here
-
um let's see what else if we do top
-
that's another command that's basically
-
going to show us our processes and um
-
how much memory and CPU they're taking
-
up things like that um kind of like the
-
the Task Manager in Windows even though
-
there is a a system
-
monitor right here that you can use in
-
Linux as well and that'll show you
-
resources stuff like that the running
-
processes okay and to get out of this
-
you just want to hit
-
Q let's see what else what else did I
-
want to do uh DF is another command
-
that'll show us our um available and
-
unavailable dis space we have lsusb
-
which will show devices like USB hubs
-
things like that um for PCI stuff you
-
can use LS PCI and that'll I'll show you
-
all that crap uh a lot of which I don't
-
even understand but it's available to
-
you um let's see I think that's that's
-
pretty much
-
it oh package managers packages managers
-
are are a big part of of most Linux
-
distributions um different distributions
-
use different managers Debbie auntu uses
-
apt get so we can say
-
pseudo apt get and then install and then
-
we can install any package that's
-
available so let's say we want to
-
install filezilla which is an FTP client
-
okay so as long as it's available it'll
-
go ahead and install that for us on our
-
system all right and now if we go to up
-
here and we search for filezilla there
-
it is okay we can move it over here if
-
we want and it's as easy as that um
-
which is much easier than in in you know
-
in Windows having to go to the site
-
download it go through the installer um
-
this is one of the the best reasons to
-
use Linux um now if we want to get rid
-
of it we could simply do
-
pseudo AP get
-
remove
-
filezilla and that will we'll say
-
yes and that will remove it you can see
-
it just disappeared okay um now if you
-
want to update or see if there's
-
available updates for um packages on
-
your system you can do
-
pseudo appt get update and it'll run
-
through and check everything um
-
and uh if it finds something it'll let
-
you
-
know so I think that's pretty much it
-
guys um I don't want to get too deep
-
into anything here this is meant to be
-
just for you know a beginner guide um oh
-
we also have the shutdown command we
-
could say pseudo
-
shutdown and if you wanted to restart
-
you could do a dasr but I'm going to
-
Halt shut the whole thing down so I'm to
-
do Dash and then you could also set a
-
time if you wanted to do like 10 minutes
-
you could do that but I'm just going to
-
do
-
now okay and it's going to go ahead and
-
shut down so hopefully you guys enjoyed
-
this and um if you did and you're not
-
subscribe please do so if if you feel
-
like it uh if you liked it leave a like
-
if you didn't you can leave a dislike
-
and that's it thanks for watching