 Now I feel like I've sort of been holding out on you guys because I haven't ever done a video on R-Sync. It's one of the most important programs for you to know how to use. It's one of the, usually I'm not a big fan of like, you know, command line programs that aren't like part of the basic UNIX operating system, but R-Sync is so very useful. It does many things. Let me explain. I'll give you examples. I'll show you how to use this in a second. But here's the things it does. It can copy files, but unlike a simple program like CP for copying files, R-Sync can copy files from one computer to another, to another computer on your network or to a server or an IP address or your website or something like that. It has the ability to partially copy files or at least to, let's say you have a really big file that's like five gigabytes. If you stop R-Sync in the middle of it processing, it will actually, you'll be able to pick it up next time you restart the transfer. So you don't have to wait for individual files to transfer. It also has really nice abilities like archive mode and update, I'll just show you how it works. All right. So here, first off, we'll go ahead and make a file. We'll just say, you know, file, here is some content. Now what we can do with, I mean, as we know from commands like copy, you can just copy a file into another file, right? You can do the same thing with R-Sync. You can say cat or, excuse me, you can copy our file file into a new location. All right. So now we have new, new file. But as I said, you can actually copy it to other computers. So right now I have my desktop in the other room running and its name is just desktop. It's, you know, like my computer here is named art. The one in the other room is named desktop. And I can actually sync that file. I can actually transfer that file into desktop and you just give a colon and it will transfer this file over there. So if I run that, now first off, if you just run that, there are a couple of things you need to know. First off, by default, if you just transfer a file over, it's going to assume that you're using the same username. If you're using a different username, you might want to say, you know, whatever the username is, at, and then the location, okay. But in my case, I just transferred over my, you know, my GPG key, like my logins are the same basically. I have an SSH key that's on the other computer. Now if we want to check that, we can actually SSH over to desktop, okay. And what that has done is it has put that file in our directory over here, okay. It's transferred over. So that's what that did. Now to be specific here, you can give any file location, let's say I want to move it to temp or something like that or I want to move it to home slash billy slash whatever, you can move it to any file location. If you don't include, or directory location, if you don't include one, it just assumes to be, it puts it in the, you know, the user's home directory, just to be totally clear. Now additionally, you can do stuff like this. Let's actually, you know, let's transfer new, new file over. This is set for, we can also give our sync, of course, different options, so we can give it like the V option and V as in many other programs, it just shows you what's happening. So that's nice. We can look at our, over here and we see we do in fact have this file. And to be clear, I can also transfer to either IP addresses or websites. So for example, I can say this, let's transfer a new, new file to root at lukesmith.xyz. So that's my website. And it's going to be putting this in a roots home directory. Okay. So I just run that it'll take a second. And what it does is it actually uses SSH to log into this server. Now the reason if you don't have SSH login or like key pair login set up, it'll ask for your password. It'll ask for roots password and it'll attempt to log in as if it were using SSH. Now the only thing important you need to know is that you need, of course, you know, SSH running and you are an SSH daemon on the computer you're connecting to. And also you need rsync installed. And I think usually rsync actually automatically starts a daemon. I don't think you actually need to do that, but yeah, that is something that you might want to look into. Okay. So in addition to just transferring transferring files, we can for example, let's make a new directory. So new directory and I'm actually going to move all those files that I just created into this directory. So I'm just going to move them into newdir. So now in newdir we have all the stuff. If you want to transfer entire folders with rsync, you just give it the r option and I'm going to give it the v option so we know what we're doing and I'm going to transfer newdir. I'm going to transfer it over to my desktop. And it shows me all the stuff that's happening. Now here's the other cool thing you can do that's very nice. Now if you're just transferring files with any other kind of command, I use this to update my website. And one nice thing about rsync is that let's say I make one change to one of those files. Let's say I go into new new file and I add some stuff. Here's some new stuff. The nice thing about rsync is that when you, let's say I run this rsync command again, what it actually, oh actually sorry, I should actually do it this way. Hold on. Let me, I forgot to give it an option. I'm going to add, oops, I'm going to add newdir, new new file, I'll just add some more stuff. Okay. Now the important thing is you want to run rsync with the u option. And what the u option does is it says only re-upload those files that have changed since I last edited them. So if I run it this time we see that the only file that has been updated is that file that I made a change to. And that's the same in any case. I mean like for example I have, so I'm actually, oops computer, I have a little script here. This is, I'm actually making a new version of my website and whenever I update something I just run this command, an rsync command that basically just updates the directory where I keep my website up with that server. And of course it's not going to re-upload anything. Let's say I make a new file, I'll just say new file, okay, not two words. And if I run this command again, this is called upn, is the name of the script. It's going to log into my server and only update the files that I've changed because I've given it the u option here. It took a second to connect, but you know. So another super important thing, as I mentioned at the beginning of the video, rsync has the ability, if you're uploading a really big file, you can actually tell rsync, if I break the, if rsync crashes, if the internet connection is lost, keep that file in it's half downloaded state on the thing I'm uploading it to. And so when I restart the command it will start back up as usual. And that is with the capital P option. Actually capital P does two things if you look at the manual. It does, let's see, oops, yeah, it, well it does partial, that's what I'm talking about, like upload files. And you can break the upload and then restart it and it'll start back up where it's finished. And then progress also just shows you the percentage of the thing that you're downloading. That's another option. But yeah, I usually just use capital P. Now in addition to all of this stuff, so rsync is great for transferring files. It's fantastic. Like if you're using a website, if you're following my like make your own website tutorial, I feel stupid for not mentioning rsync before because this is actually how I manage it all the time. I just, I have a copy on my website on my own computer. I don't like having the SSH into my own server to make little changes. I make it on my computer. Then I run an rsync command just like this and it updates everything. But in addition to all that rsync is also really good at making archives of stuff. In fact, it actually has an archive mode which is A. And what this does is I think I use this in a couple. Let's see. Mail. Arc. Yeah. So let's say, for example, when I'm my mail, I keep in one directory on my computer. But also if I have like, let's see, where is it? Yeah. If I have an external drive that I sometimes have connected. And if I have the script that runs, if that drive is connected, I actually use rsync to copy over everything with the A option. Now what the A option does is it really just turns on a bunch of different options. It turns on the recursive option. It turns on just a couple things. And mainly it preserves permissions and metadata of files. So it's very good. If you just want to make an archive of, let's say, where did our directory go? Oh, over here. If we just want to make an archive of this new directory, we can just say archive or something like that. And it will create a new archive here. And that's going to share the metadata of everything and everything else. So it's nice and convenient. I use this all the time. Rsync is really fantastic just in terms of, it's scriptable since it's running on the command line. So you can have your computer's update stuff whenever something happens or you plug up something or you're connected to the internet. And I use it basically all the time. It's one of the only, like I'm totally against these new modern replacements for Unix core utilities. Like people have this stuff like RIP-GREP and RIP-SED and SOI-GREP and all this kind of stuff basically. And I mean, I guess they do cool stuff, but I don't like abandoning traditional Unix tools. But Rsync is just so nice. It's very easy to get stuff out of it that I can't resist. I enjoy using it. But anyway, that's Rsync. I encourage you to use it. Use it especially with your website. Go check out my series on creating your own website and Rsync is good for that. But even for transferring files, making archives, making backups, Rsync is the best. All right, see you guys next time. Actually, one little other use case. If you're a lazy boomer like me and you don't like getting in the other room or messing with other computers, I usually take my videos that I make and I put them on my desktop so that I can convert them to the right codecs and upload them quickly. So I don't even have to get up and go over there. I can just do something like, you know, I'll just, I'll do partial and then visual and I'll take this screencast file here and I will take it over to the desktop and upload it there. And so that's a much quicker way, an easier way of like transferring stuff without getting up and going somewhere else or, you know, anything like that. My home internet is still slow, though. Actually, you know, how big are these files anyway? That is, how is that, six gigs? What am I recording in? Okay. Clearly I've been messing up. I don't, I don't know what I have been recording this stuff in. Anyway, so yeah, it's just a nice, yeah, just use Rsync. There's so many uses for it. It's great.