Check out a free preview of the full Full Stack for Front-End Engineers, v3 course:
The "Update & Restart Server" Lesson is part of the full, Full Stack for Front-End Engineers, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Jem walks through updating a new server's software and how to restart a server.

Get Unlimited Access Now

Transcript from the "Update & Restart Server" Lesson

>> So next we haven't done anything with our server, it is a blank canvas. So what we're gonna do now on any brand new server for the first time, we need to one, update our software. Two, we're gonna restart our server. Then we're gonna create a new user because we don't wanna operate as roots.

[00:00:17] That's very, very, very dangerous and I'll explain why. We want to create a user that is a super user who can use root. We want to enable login for the new user. And we want to disable the root login. It sounds like a lot. It's kind of a lot, but once you do it once, you'll be like, okay, I kind of get where we're going here.

[00:00:36] So, I laid all the steps I'll walk through them, I'll talk through them and then we will execute them. I'll do them with you. So, and I'll move slowly. So follow along. Let me know if I'm going too fast. So obviously, the first thing we need to do is we need to SSH into our server.

[00:00:51] We've already done that. Next thing we need to do is we're gonna update our software. So we're gonna say apt update and then apt upgrade. apt is just the package manager for Ubuntu and the Linux distributions. And then we're gonna restart our server, kinda how you have to turn it off and on again.

[00:01:07] We're gonna say, shutdown now -r. So that sounded like a lot. Let's do it together. So I'm going to ssh into my server. And like I said, I always go through history. It's so much faster. I could just do this a different way, but I just like doing the up arrow.

[00:01:28] So ssh into root. And then the next thing we're going to do is, we're still root, that's okay for now. We're going to apt update. So this is just kind of a fetch and saying like, what are the latest libraries? This might take a few seconds here. So I'm running APT updates So now I'm ready for actually upgrading the software.

[00:02:04] So I'm gonna run apt or APT upgrade and clear. And we'll just say, yes. And this just gonna check all the built-in libraries and libraries that are installed on our current operating system, and just bring them up to the latest version. We want to do that first because if we do it after we install the software, it could turn out to breaking change somewhere along the way.

[00:02:32] So we do this the first thing we do is make sure all our software is up to date. That way later down the line, we can just iterate and not have to worry about it. The good news is we generally only have to do this once. Later in the course, we'll figure out how to do this automatically, unattended, which will be nice.

[00:02:51] So you're probably going to run into something like this. It's going to throw up a window saying, hey, there's a newer version. We're just going to keep the local version installed, because the local version works, and we don't really want to mess with it. So we'll just say, OK.

[00:03:11] And pending kernel upgrade. Remember we talked about what the kernel is, that's the second lowest layer between the hardware. So the kernel talks to the hardware. So we'll just say okay, not much else we can do here. And we're just gonna restart all the services by default. So we're just going to scroll down.

[00:03:33] And tab to move to the OK. If you get stuck, it'll say OK. I usually don't mess with it too much. It works just fine. So hopefully, all your upgrades ran fine. There's no issues. So next thing we're gonna do is we're gonna restart the computer. So we're gonna shut down, but we need to say want to shut down when.

[00:04:05] If we just say shut down, it'll say by default scheduled it for a day in advance because assuming you don't want to pull the plug immediately it's not something you do very often on a server naturally. So we want to say shut down right now, but we want to make sure we restart it.

[00:04:19] So the -r will let us restart. So I'm going to hit that is going to take me from the server because it's rebooting. And it'll take a few seconds to come back online. But when it does, we'll have a nice clean install with the latest libraries, and hopefully nothing broke along the way.

[00:04:35] I don't think so, but you just don't know you saw those packages and commands being run. You never know when somebody's gonna go a little bit aray. If so, we can probably get you back. Now if you forget the -r, you can always manage your server from the control panel in DigitalOcean.

[00:04:50] You can bring it up, bring it down from there. But we try to do as much as possible from the command line. So I'm gonna ssh back in. Nope, still not up. So still coming back online.
>> I connected through New York. New York has rebooted already so just FYI.

[00:05:06] [LAUGH]
>> New York is faster and SFO is backup.