-
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 file1 has now been renamed to
-
file2. 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 file2 and create file1,
-
but also keep file2, then we could
-
do cp, okay? That's the copy command.
-
File2.txt and we want to copy it to file1.txt.
-
And now if we look at the
-
contents, we have both files. And if we
-
say cat file1,
-
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 file1.txt, we want to copy it
-
to, let's say, tilde for the home
-
and then slash
-
dir2 slash
-
file1.txt,
-
Okay, and then we'll switch directories.
-
Let's say
-
cd dot dot and then cd dir2.
-
Whoop, cd dir2 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.
-
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 rmdir
-
dir2, 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 dir2, 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 route, and I'm going to
-
try to delete dir2.
-
And now you see it says failed to
-
remove dir2. Directory is not empty. So
-
this command isn't going to work if the
-
directory is empty. 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 option
-
which is for recursive. So you want to do
-
rm -R and then dir2. 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 which does is it'll search for
-
a file or a folder's location and
-
give you that location. So let's
-
say we want to look for the mongoD
-
application, which is the mongodDB
-
server. We could say which mongod, and
-
that'll show you exactly where it's in.
-
It's in the usr, bin, mongod. Okay, so
-
that can come in pretty handy.
-
So what else? Let's say let's
-
use the history command. And history will
-
basically show you your last, what is
-
it? 500 or so, 400? Well, I think it's your
-
last 500 commands.
-
Okay, so that can be handy to see
-
what you've been doing or to see what
-
someone else has been doing.
-
Let's see, what else? So 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 are the most important. Those
-
are the things that you absolutely need
-
to know. 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, messing around with stuff
-
logged in as the root user. So
-
for that, you could use sudo. So let's
-
try to run, for instance, apt get update,
-
which I'll go over in a minute. It's
-
not going to let us. Basically it says
-
that we don't have the permission to. So
-
if we do
-
sudo apt get update, it's going to ask
-
for our password,
-
and then it'll run it, okay?
-
And that's just updating our packages,
-
and I'll get to that in a second. So
-
you want to use sudo to 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 navigate or
-
anything, but they're good to know. So
-
first one is ifconfig,
-
and this is just like ipconfig
-
on Windows. It basically it's going to
-
give you all your network information,
-
your ethernet cards, your IP address,
-
your local IP address, your loop back,
-
things like that. Pretty much
-
identical to ipconfig in Windows if
-
you've ever used that. For wireless, you
-
can do iwconfig.
-
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? Now, if you want
-
to ping another machine or 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
-
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
-
control '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
-
you can actually reach a certain machine
-
or not, okay? So let's look at some other
-
system commands. Let's see, we have
-
uname. Let's do uname -a. That's going
-
to just basically give us a summary of
-
our system, the operating system, the
-
version, things like that, okay? We also
-
have- let's do
-
bld. I'm sorry,
-
blkid, and what that does is it basically
-
shows us our hard drive. So I have a
-
my regular hard drive and then
-
what's called a swap, okay? So when Linux
-
partitions your drive, it puts a
-
little bit aside for a swap file here.
-
Let's see, what else? If we do top,
-
that's another command. That's basically
-
going to show us our processes and
-
how much memory and CPU they're taking up,
-
things like that. Kind of like the
-
the Task Manager in Windows, even though
-
there is 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? Df is another command.
-
That'll show us our available and
-
unavailable disk space. We have lsusb
-
which will show devices like USB hubs,
-
things like that. For PCI stuff, you
-
can use ls pci, and that'll show you
-
all that crap, a lot of which I don't
-
even understand, but it's available to you.
-
Let's see, I think that's
-
pretty much it.
-
Oh, package managers. Package managers
-
are a big part of most Linux
-
distributions. Different distributions
-
use different managers. Debian and Ubuntu uses
-
apt get. So we can say
-
sudo 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? And we can move it over here if
-
we want, and it's as easy as that,
-
which is much easier than in, you know,
-
in Windows having to go to the site,
-
download it, go through the installer.
-
This is one of the the best reasons to
-
use Linux. Now, if we want to get rid
-
of it, we could simply do
-
sudo apt get
-
remove
-
filezilla. And that will- we'll say yes.
-
And that will remove it. You can see
-
it just disappeared, okay? Now, if you
-
want to update or see if there's
-
available updates for packages on
-
your system, you can do
-
sudo apt get update. And it'll run
-
through and check everything,
-
and if it finds something, it'll let
-
you know.
-
So I think that's pretty much it
-
guys. I don't want to get too deep
-
into anything here. This is meant to be
-
just for, you know, a beginner guide. Oh,
-
we also have the shutdown command. We
-
could say sudo
-
shutdown. And if you wanted to restart,
-
you could do a -r, but I'm going to
-
halt, shut the whole thing down. So I'm going to
-
do -h, 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 if you did and you're not
-
subscribed, please do so if you feel
-
like it. If you liked it, leave a like.
-
If you didn't, you can leave a dislike.
-
And that's it! Thanks for watching.