Transfer Utilities (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, Cybrarians. Welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz.
00:00
In today's lesson, we are going to
00:00
be covering transfer utilities.
00:00
Upon completion of this lesson,
00:00
you are going to be able to understand
00:00
the purpose of data transfer utilities,
00:00
and then during our demo today,
00:00
we're going to use the SFTP,
00:00
SCP, and rsync utilities.
00:00
Data transfer utilities are important when we're
00:00
storing data offsite or on another system,
00:00
and it's just another way of performing data backup.
00:00
We can transfer that data to another system or offsite.
00:00
For the Linux plus exam,
00:00
we need to know about three data transfer utilities,
00:00
and those are SFTP, SCP, and rsync.
00:00
There are two of these data transfer utilities
00:00
that are actually provided by Secure Shell,
00:00
and those are SFTP and SCP.
00:00
Now SFTP is a secure version of the FTP protocol.
00:00
As we talked about before,
00:00
so as we know by now, it's going to be on the exam.
00:00
Now, SFTP just uses SSH encryption,
00:00
but otherwise it works the exact same as FTP.
00:00
It uses the get command to download files
00:00
and uses the put command to upload files.
00:00
SCP replaced RCP and it uses
00:00
SSH to create secure transfers,
00:00
copying a file from one system to another.
00:00
For example, if we want to send
00:00
a file locally from our system,
00:00
we say scp,
00:00
and then the name of the local file
00:00
>> or the path to that file,
00:00
>> and then we specify the user on
00:00
the remote host colon and then the target location,
00:00
the path wherever we want to
00:00
>> put that file on that system.
00:00
>> If you want to pull a file down from remote system,
00:00
we do scp user at remote host colon and
00:00
the remote locations of the path to
00:00
where that file is on the remote system,
00:00
and then the local target,
00:00
the local path or location where we
00:00
want to store the file on our system.
00:00
If this is a little unclear,
00:00
don't worry about it, we're going to
00:00
see this later in our demo.
00:00
Now the rsync utility not only allows you to copy,
00:00
but also to sync files and directories,
00:00
rsync, remote sync.
00:00
This is especially helpful when you're copying
00:00
a large number of files
00:00
because if a transfer is interrupted,
00:00
it can be resumed and it will only copy
00:00
needed changes or missing
00:00
files known as a delta transfer or rsync.
00:00
Now, rsync is also really
00:00
powerful because there are a lot
00:00
of options available to you.
00:00
You can use -a for archive mode,
00:00
and that's going to preserve permissions,
00:00
ownership, and modification times of files.
00:00
We can also compress the transfer with the -z option.
00:00
Then finally, I like to use the --dry-run option,
00:00
--dry-run or -n. What that does is it
00:00
tests the data transfer as a trial run
00:00
with not transferring any files,
00:00
and that just allows you to make
00:00
sure that you put the right options in
00:00
place and didn't screw up your syntax when using rsync.
00:00
But let's take a look at all of
00:00
these commands with some demo time.
00:00
>> Here we are back
00:00
>> in our demo environment, and right off the bat,
00:00
>> I'm going to go ahead and open a terminal,
00:00
and we're going to go ahead in SFTP to Ubuntu.
00:00
Here we are in our Ubuntu system,
00:00
it says that we're connected to Ubuntu.
00:00
>> Now if we want to see where we actually are
00:00
>> on the remote system,
00:00
>> we could do pwd.
00:00
Even though we're running pwd,
00:00
we're running that on
00:00
the remote system that we're connected to you.
00:00
When we run this, it'll actually say
00:00
the remote working directory is /home/rob,
00:00
so in my home directory on the Ubuntu machine.
00:00
If we want to see where we are on the local machine,
00:00
we can do l, l for local, pwd, and we see that
00:00
we're in the local working directory,
00:00
/home/rob/Desktop. Now it makes sense.
00:00
I launched this terminal window from
00:00
the desktop and we can see right here
00:00
it says that we're on the desktop,
00:00
so we know that's where we are.
00:00
Now if we want to see the files that
00:00
are on the directory that we landed in,
00:00
in other words, the home
00:00
directory on the Ubuntu machine,
00:00
we can just type ls and hit "Enter".
00:00
We can see a bunch of files here.
00:00
Let's go ahead and pull down the
00:00
>> file called Ubuntu file.
00:00
>> We'll do a get ubuntuFile.
00:00
Now we're going to see a pull down, and like I said,
00:00
our local present working directory run the desktop,
00:00
so now we see this bumpy file on the desktop.
00:00
Now let's go ahead and copy that file,
00:00
so we'll copy ubuntuFile.
00:00
Actually, let's get out of this SFTP,
00:00
so hit "Control B" is how you get out of SFTP.
00:00
I'm going to clear the screen by hitting
00:00
"Control L", and what we'll do
00:00
is we'll copy ubuntuFile and we'll call it new file,
00:00
and now what we'll do is we'll echo
00:00
something into this file,
00:00
I am a new file,
00:00
and will echo that into
00:00
a new file by doing our standard output redirection.
00:00
Now what we can do is we can do
00:00
>> an SFTP back to Ubuntu.
00:00
>> Now if we do an LLS,
00:00
it's going to show us what we have
00:00
locally in our local present working directory,
00:00
which is /home/rob/Desktop,
00:00
and we see that new file we just created.
00:00
Actually, let's do this first.
00:00
We're in the present working directory
00:00
/home/rob on the Ubuntu machine.
00:00
Let's use cd to change to the desktop on that system.
00:00
Now we do present working directory,
00:00
we're in /home/rob/Desktop
00:00
>> on the remote system on Ubuntu.
00:00
>> This is pretty cool. Let's do a put new file,
00:00
and now that's copied over,
00:00
let's go over to Ubuntu real quick and check this out.
00:00
Here we are over in our Ubuntu system
00:00
and we can see that new files on the desktop,
00:00
and if we opened up, it says, "I am a new file."
00:00
Let's go back over here to our CentOS machine,
00:00
and over here, we can first SEP
00:00
our file down from Ubuntu to CentOS.
00:00
Let's get out of SFTP,
00:00
let's clear our screen, and we're going to do
00:00
an scp rob@ubuntu,
00:00
>> and we're going to copy
00:00
>> /home/rob/ubuntuFile,
00:00
>> and we'll copy that into my home directory,
00:00
so we'll do Tilda.
00:00
Now if we go and do an ls -al on Tilda,
00:00
we can see that we have the Ubuntu file here,
00:00
and we can see the date is May 18th.
00:00
If I get a date, we see
00:00
that we just pulled that down because
00:00
that is 00:47 and our date here is 00:47.
00:00
Now let's copy a directory to Ubuntu.
00:00
We can do that by doing scp -r for a recursive copy,
00:00
and we'll say we're going to copy over /home/rob/dir1,
00:00
>> and make sure that directory is there.
00:00
>> Let's make sure we have a dir1 directory.
00:00
Now let's go ahead and create the directory.
00:00
First I apologize, we'll do mkdir /home/rob/dir1,
00:00
and then what we'll do is we'll do an scp -r on
00:00
>> /home/rob/dir1 over to Ubuntu,
00:00
>> and we'll put this in /home/rob on Ubuntu.
00:00
Now if we do an SSH to Ubuntu,
00:00
we're going to land in /home/rob,
00:00
and if we do an ls, we can see dir1 here.
00:00
That's basically all that we needed to know about SCP,
00:00
you can copy things to a remote system by specifying
00:00
the location of the file or directory
00:00
that you want to copy and then
00:00
the remote system that you want to copy to,
00:00
or you can copy things down to
00:00
your system by doing an SEP to that remote system,
00:00
specifying the path to
00:00
the file that you want to get off with
00:00
a remote system and
00:00
the place that you want to copy it to.
00:00
Let's take a look at one last thing,
00:00
and as I said, we were talking about rsync earlier.
00:00
>> Let's take a look at rsync.
00:00
>> Let me go ahead and make this window a little
00:00
bit bigger and clear the screen again.
00:00
We're going to transfer our directory
00:00
from CentOS to Ubuntu.
00:00
Now let's go ahead and do
00:00
an rsync -avz of /home/rob/dir1,
00:00
and we're going to send that to
00:00
>> rob@ubuntu in /home/rob.
00:00
>> We can see that that whole thing is sent over.
00:00
We also see that it says it incremental file list,
00:00
it tells us quite a bit of
00:00
information about we're sending over.
00:00
If we go over to our Ubuntu machine again,
00:00
we SSH back to Ubuntu,
00:00
we can see that that file is there again.
00:00
>> We can see dir1 is right there.
00:00
>> We can also see that it should
00:00
preserve any of the settings on this file.
00:00
If we had no specific permission set,
00:00
it would preserved here as well.
00:00
Let's do this again,
00:00
but let's get a directory on
00:00
the remote system and try sync it back.
00:00
On this remote system,
00:00
let's create a directory,
00:00
we'll call this directory dir2,
00:00
mkdir dir2.
00:00
Now let's go back to CentOS.
00:00
Now what we can do is we can do this backwards.
00:00
We do an rsync -avz,
00:00
and it's going to be rob@ubuntu:/home/rob/dir2.
00:00
We want to copy that to the directory that we're in,
00:00
so you just ./ that,
00:00
that says copy to the directory we're in right now.
00:00
Since we're actually in our
00:00
desktop where we are right now,
00:00
if we look here, now
00:00
we see that there are two directory,
00:00
we have it on the desktop.
00:00
We've reached the end of this lesson,
00:00
and in this lesson, we covered
00:00
the purpose of data transfer utilities,
00:00
and we also talked about how to use SFTP,
00:00
SCP, and rsync utilities.
00:00
Thanks so much for being here,
00:00
>> and I look forward to seeing you in the next lesson.
Up Next