Tip:
Highlight text to annotate it
X
Most of you are probably used to the way that Windows handles hard drives.
Under Windows each physical hard drive gets its
own letter. Most familiar is the C Drive
which usually represent the main hard drive for the computer that you working on.
If you were to add a second drive it would be possible that second drive will be
given the letter D.
Optical drives also receive
letters. This idea can be valuable because it's pretty easy to say well if
I'm on the C Drive I'm dealing with this hard drive and if I'm on the D Drive I'm
dealing with this hard drive but with that said you also need to have some level
of knowledge of the underlying system. UNIX takes a different approach
in UNIX all the drives in the machine are mapped under a single
directory called root and what that does is it makes it really nice because it
makes it look like
all the hard drives in the machine are a single
storage unit. Now this doesn't stripe the drives together this doesn't do
anything like RAID it doesn't do anything fancy
but what it does do is it represents to the user
separate drives as just folders underneath of
a common top level hierarchy
and so there's no need to think like oh is that file on the C Drive
all you have to do is remember the directory it's in and you don't really have to
worry about
the actual Drive the data is on.
In this case the root directory is represented by
a forward slash so whenever I say let's go to the root directory
of our UNIX system what i'm saying is let's go to the directory
represented by slash. In UNIX there are a couple different ways that we can
refer to files. The terms that I use are absolute and relative paths
and so we need to kinda know the difference between the two of these.
When you have an absolute path
you are actually giving a full description of where to find the file
starting at the root directory so whenever you give someone an absolute
path on UNIX you always start with
root, home, slash. jason, slash
stuff and that's the directory that I've got listed here.
So the reason why this is absolute is i'm saying go back up to the top
most level directory and start from there to find the file.
In Windows if you were to give an absolute path that would start with a drive
letter like C:
home whatever so the idea is that absolute paths
always start with the root directory.
We can also give relative paths in UNIX in relative paths are based on where you
currently are located within the filesystem
so you can say you know based on where I currently am
go up a directory or go down a directory and get this file
so absolute paths always start with root relative paths
are given in relationship to where you are within the file system hence the name
relative we'll talk a little bit more about how you'd navigate relative and
absolute paths when we talk about
commands like cd once we get into actually navigating the filesystem.
So what does the file structure look like on UNIX.
I have broken this down into a file hierarchy tree
and one of the things you have to get used to on UNIX is that you need to keep
a mental representation of where you are within the filesystem.
One of the nice things about a graphical user interfaces is that
they use the folder metaphor
allows us to have a visual representation of this idea that one folder is inside
another folder
so in this case if I were to give you the absolute
path to wear mp3s are stored I would say okay
root home jason
mp3 and what this says is the mp3 directory
or folder is inside of the jason directory or folder
and the jason and directory or folder is inside of the home directory or folder
and the home directory or folder
you know I'll say directory but for now say home folder and directories so we
can start thinking in terms of directories
is underneath the root directory. If I said
hey we are currently located in the jason directory
what is the relative path to the bin directory where you would say
go up one directory to home then go up another directory
to the root and then jump into
the bin directory so you could define a path...
you could define a path to the bin directory as being relative to the jason directory.
So again this idea relative verses absolute paths.
Commands in UNIX follow a very standard pattern.
Although as soon as I tell you that there's a rule immediately
you're gonna find commands that break it but for the most part
every command in Unix follows this
general syntax so what we're gonna have is
the actual command name itself followed by
a dash and a series of options.
Later on you'll see some times where some commands don't require this dash
and that some commands instead of single letter options will take full word
easily readable options but the general syntax
of options is that it's a single letter preceded by a dash
and then at the end of the command we're going to see a number of
arguments. 0 or more arguments that feed into the command.
Let's take a look what this looks like in an actual command. The ls
command is for listing
the contents of the directory so ls
is the command dash l
is the option for that command
and that will list all of the items in the directory
in a long format and then finally the argument for this command is
slash etc which is a directory so what I'm basically doing as I'm saying OK ls is
the command
dash l is the option and the argument that I'm feeding into this command
is slash etc and if you think about it if I wanted to list a directory
I need to have the name of the directory to list and when I list a directory I
want to have some different ways to view that information. So one would be a long listing
one might just be a brief listing, one maybe file names only,
one might give me instead of byte counts for file sizes human-readable
megabytes and kilobytes so this is the general format for syntax and in every
following video we're going to be
seeing how this is put into action.