(soothing music)
- [Voiceover] Hey, y'all, it's Riley again.
Today we're going to go over basic commands to use
in the Linux terminal window and a little bit more
about how Linux works in general.
So obviously I'm not using a Linux computer right now.
This is Windows, but I have one running using Virtual Box.
If you weren't around for my last two videos
and you're just here to learn Linux things,
don't worry about this part.
But if you're curious about how I can have a Linux
computer running inside of my Windows computer, sort of,
I have a video about how to set one up.
You can click the middle of your screen right now.
There should be a pop-up that'll send you to
that video first, and then you can come to this video
and follow along with me.
So the image that I'm running right now
was created specifically to run a software called Qiime.
But the things I'm gonna tell you about
work for any Linux terminal window.
As long as it's a Linux machine,
then most of these codes should work.
Most of the commands are going to be
the exact same in Unix.
So if you have a Mac and you're doing this,
pretty much everything should work the same.
You might be wondering why someone would want
to type things in, you know, the old way,
straight into a terminal like this one instead of
clicking around in a folder system like this one.
It's probably been a long time since you've used
a command line interface to use a computer.
Unless, of course, you're a programmer or a mathematician,
you know, there's a few exceptions to that.
But most people use graphical interfaces
like the one on the right here.
You can click on things.
There's cute little icons.
It hides the things you don't need to see.
In general, it's much easier to work this on the right
than it is on the left, especially because you don't
have to memorize anything.
You can just point and click.
But there are definite perks to
using command line interface.
For example, if you're doing something besides
just moving and copying files, it's really hard
to get commands or script into these on the right.
Really, you have to use one.
Even if you right click, you only get
a few options of things you can do
to your folders and your files.
But by typing commands into a terminal like this,
you can do almost anything.
It also lets you do a lot of repetitive things
with a lot less effort, but I'm not really
gonna get into those right now.
I'm gonna teach you the basics of using
an interface like this, how to see where you are
in the file system, how to move and copy files,
how to delete things, and a few little
tips and tricks about how to do it more efficiently.
So when you pull up your terminal window,
you should pretty much see a dark purple box.
It might be black.
In any case, you should have the name
of your user and then at the end,
you should have a dollar sign.
If you see a pound symbol or a hashtag sign
instead of that dollar sign, you're currently
running the terminal as a super user,
and that's pretty dangerous unless you know
exactly what you're doing.
Trust me, you really don't want to be doing that.
So anyway, you should see something similar to this.
If you're running a Qiime image like I am,
you should see pretty much exactly this.
So the very first thing I'm gonna teach you
how to do is to virtually look around.
This first command is called print working directory,
and the abbreviation is pwd.
That means if you want to do this command,
just type the letters pwd and press enter or return.
Now you might be wondering, "Well, what did it do?"
It didn't look like it did much of anything.
What it did was print where you are on your machine.
So right now, we are in the same spot on both places.
We're in the home folder for the Qiime user in both spots.
This might not seem significant now,
but it's actually pretty easy to get lost using
a command line interface because you can't,
quote, unquote, "see" your way around.
So it's always good to check you are
where you're supposed to be.
The next thing I'm gonna show you
is called the list command.
The abbreviation is ls.
Type ls into your terminal and type enter.
I have the window open on the right
just so that we can check that what we're doing
on the left is right.
If you noticed, I had it list the contents of the folder
we were in, and that line did exactly with
the folders over here.
It says desktop, documents, downloads,
music, public, videos.
Basically, it told us what we knew all along over here.
Now I'm going to show you
something a little more interesting.
What if we wanted to see all the files
that weren't shown on the right?
You might not know this, but for all the files
you see, there are probably four or five that you don't.
All the little files that keep your computer
running smoothly, that you don't actually have to see
because you don't need to manipulate it all.
They're automatic.
But what if we wanted to see them anyway?
Let's type our command ls.
We're gonna do something called a dash option.
Basically, it makes your command a little bit more specific.
The dash option that we're gonna use is dash a.
A stands for all.
Now press enter.
We got a lot more files this time.
That's because we're seeing all the files,
including the hidden ones.
But what if we wanted to see a little more
information about all of these files?
What if we wanted, for example, how big
they were or when they were made?
There's another dash option for that.
Ls dash l.
L is short for long format.
Now I didn't do a this time, so I didn't get
all of the files, but this tells us some more information
about the size and timestamp on the folders
that we see over here on the right.
Okay, so we have a list of things
and we have more details on them.
You might be wondering, "Can you combine these in any way?"
As it turns out, you can, and it's very easy.
Type in ls, space.
Do your dash, now type in al, so you have
both the all command and the long format command.
Now we have all the files and we have their long versions.
I'm gonna show you one more dash option for the
list command, but I do have one more important thing to say.
When typing in dash options, you need to put them
in alphabetical order or it's not gonna work.
For example, the one I wanna show you is called
human readable, and it has to do with
these numbers you see on this column.
Those are actually the sizes, but it's hard to
understand since they're just like a long list of numbers.
So we're gonna do ls
dash ahl.
H is for human readable, a is for all,
and l is for long-form, like we did before.
Press enter.
It looked like the line just shrunk.
Actually, it printed again, but it was the same information,
slightly altered, which is why it gave that impression.
If you noticed these numbers now,
they have kilobytes.
They would also do mega and gigabytes if you wanted.
This posts numbers in perspective a little bit.
At least I think so.
But just to test out the rule that I told you,
let's type in ls and dash,
let's do hal.
Since that includes all of them, it should work, right?
If you press enter, it doesn't work.
It just deletes it.
The order of your letters in your commands
is super important in this.
For example, if you're trying to overwrite
file b using file a, and you accidentally get it backwards,
then you'll have twice the number of bad files
and you'll have accidentally deleted your good one.
All I'm saying is keep your wits about you.
The next command I'm gonna show you is called cd.
It's short for change directory.
Let's say we wanted to move to the
desktop from our home folder.
Well right now, if we did pwd to make sure
we're in the right spot, it would show us that
we're in our home folder/qiime.
And using the list, we know that going to the desktop
is an option, so let's use the cd command.
Type in cd, space, desktop.
Use a capital d.
Make sure that your capitalization matches.
Desktop, and press enter.
So now we're in the desktop.
If we were to print the working directory right now...
it would deliver home/qiime/Desktop.
It's exactly where we want to be.
I'll do the same thing over here on the right.
Okay, so I've basically showed you how to do the
equivalent of clicking on a folder.
But what if we wanted to get to a specific place
that was maybe in a different branch of the tree?
Well, it turns out you can type in the exact
location of whatever directory you wanna be in.
So say I wanted to get into the shared folder.
You can see it over here.
I could type in cd, space,
/home/qiime
/desktop/
Shared_Folder, and press enter.
If I wanna check that I'm actually
in the shared folder.
I could print working directory.
Now, I'm gonna do the exact same thing on the right
just so that we can follow along.
Now, you might be distracted visually
by this increasingly long line here.
If you wanna get rid of that, it's pretty easy.
Type in ps1=
'$'
and that should simplify things for you.
Now it's just a dollar sign.
There's more space to type instead of that
very long username slash location.
There are a few shortcuts you can use
when referring to file locations in Linux.
The first one is the tilde.
Experiment by typing in ls, so list,
and then tilde.
The tilde represents your home directory.
If you ever wanna refer to something and skip the
/home/username/, you can just do ~/.
It's the exact same thing.
That saves you a little bit of typing.
In a similar vein, if you ever want to refer
to the directory you're in for whatever reason,
that's gonna be a dot.
So if I did ls and then ., that lists
all of the things that are in the shared folder right now.
So that are all the things that are in the shared folder.
Now, here's a tricky one.
What if you wanted to list all the files
in the parent folder to the one you're currently in?
So for us, that would be the desktop.
Well, the shortcut to that is two dots.
So ls space, two dots, enter.
And we can check, if we go up to the desktop,
it's just those two folders.
You can use those in file locations
to save yourself a little bit of typing.
(soothing music)