From the course: Learning Linux Command Line

Creating a Linux virtual machine - Linux Tutorial

From the course: Learning Linux Command Line

Creating a Linux virtual machine

- [Instructor] Throughout this course, I'll be using the free VirtualBox virtualization software to make a virtual machine that runs Ubuntu Desktop. I enjoy using VirtualBox because it runs on all major platforms. So if you're using Windows or macOS or Linux, you can use this software. Working in a virtual machine allows us to keep our learning work separate from our real computer. So we're free to make changes and mistakes that won't affect anything else, though, it takes a bit of work to get up and running. I think it's worth it though. You can decide for yourself. Within my virtual machine, I'll be using the Ubuntu Desktop Linux distribution because I find it to be accessible for beginners. Again, if you have other preferences, by all means, use the distribution of your choice, but you'll be on your own for installation and troubleshooting. We can download the files we need from virtualbox.org and ubuntu.com. If you choose to use different software or a different distro, you'll need to download the files your software choices require. Let's take a look at the process of setting up a virtual machine. Depending on the speed of your hardware, this could take up to 20 minutes or so. Here's the VirtualBox website, and I can click on the big blue button to download the current version. There's a few different options for the platform. So if you're using Windows, click the Windows one. If you're using a Mac, click the option for that system. And if you're installing VirtualBox on Linux, click the Linux distributions one. Take a minute to download and install the software on your computer. Then head over to ubuntu.com, where we can download the Ubuntu installer or ISO image. This is a pretty big file, so I've already downloaded it on my computer, but you'll want to take a few minutes to download it. You'll need the file to be completely downloaded before you continue. I can find the download link under the Download menu, and then I'll find the Ubuntu Desktop section and choose the LTS option. In my case, the file's version is 20.04, the latest version that has long-term support at the time I'm recording this, but there are new releases that come out now and then. So if yours has a higher number than mine, that's just fine. Once I've installed VirtualBox, I'll open it up, and I see the Manager window. If you'd like to find out more about VirtualBox, take a look at my course Learning VirtualBox, which focuses on how the software works and how to use it. Let's build a virtual machine. I'll click on New, and I'll give my machine a name. In this case, I'll call it My Ubuntu Desktop. I'll make sure the type is set to Linux and the version is set to Ubuntu 64-bit. Then I'll click Next. VirtualBox recommends that I give this machine 1024 megabytes of memory. Ubuntu will run with that, but it's not a great experience. So I'll give it 4,096 megabytes, or 4 gigabytes, and I'll click Next. Then I'll choose to create a virtual hard disk. I'll choose VDI and make sure that Dynamically allocated is selected. VirtualBox recommends 10 gigabytes, but I'll set this to 100 gigabytes instead. This space isn't being taken up on my computer yet, so it doesn't really matter. But I'd like to give myself a little bit more space than VirtualBox suggests here. 10 gigabytes would be used up really quickly, once we start actually using the virtual machine. And then I'll click Create. I'll click on my virtual machine here in the left, then I'll choose Settings. Under the Storage section, I'll find the empty slot under the IDE controller. Then I'll click on the CD icon over here on the top right, and I'll click Choose a disk file. I'll navigate to my Downloads directory and choose the Ubuntu installer that I downloaded previously. Then I'll click Open, I'll click OK, and I'll click the green start arrow to start my virtual machine. And in order to make the display a little bit larger on my screen, I'll go to View, choose Virtual Screen 1, and I'll choose a scaling factor. Then I'll double-click to maximize the window. Once the installer loads, I'll click the button Install Ubuntu. I'll make sure to change the language that I want to use, and then I'll click Continue down here in the bottom right. I'll choose to start with a normal installation and to download updates while I'm installing Ubuntu. This will save us some time later. Then I'll click Continue. On the next screen, Erase disk and install Ubuntu is selected, and that's the option that I want. This will erase the virtual disk that we just created. To continue, I'll click Install Now down here in the bottom right. I'll confirm the changes to my disk by clicking Continue. I'll select my location, and I'll click Continue. Then I'll create an account for myself. I'll give my system a name, and then I'll set a password for myself. When I'm done, I'll click Continue. This is the user I'll use to log into the system. Now we'll wait for the installation to finish. We'll speed up the video here while the installer progresses. You might choose to take a quick break while you wait. Now Ubuntu Desktop is installed. I'll click the Restart Now button, and the virtual machine will restart. When I'm prompted to remove the installation medium, I can just press Enter because VirtualBox has taken care of this step for me. When the system starts, I'm presented with a login screen. So I'll click my user account name and then type the password that I set. The first time I log in, I'll be presented with a series of prompts. I'll just skip these for now, and then I'll click Done. Once the virtual machine's installed, and we've logged in, there's a few more steps we'll need to take. The first is to make sure that our software is all up to date. In my case, the software updater has popped up on the screen. If it doesn't pop up for you, you can go into Activities and type software update and then find the gray icon with the A on it. When that opens, I'll click Install Now. This'll take a moment. Once that process finishes, I'll click OK, and then move to the top right of the screen and click the downward facing arrow. Then I'll find Power Off/Log Out and click it. Under that, I'll click Power Off, and then I'll choose Restart. When the system starts again, I'll click on my username and then type in my password to log back in. At this point, we could continue using the virtual machine just as it is, or we can take some more steps to make it look a little bit better. We'll do that by installing VirtualBox's guest additions. This does involve using the command line. So at this point, just follow along with me. I'll explain all the commands that I'll use later in the course. To get started, I'll move up to Activities in the top left corner, click on the search bar, and type terminal. Then I'll click on the icon that appears below it. In order to make the text a little bit easier to see, I'll press Control + Shift + Plus two times, and then I'll write sudo apt install gcc make perl, and I'll press Enter. I'm being asked for my account password, so I'll type it here. When I type, no characters appear, but the characters are going to the computer. Once I've typed my password, I'll press Enter. And then, when I'm asked if I want to continue, I'll press Y and then press Enter. Again, this will take a few moments. Once that process is complete, I'll close the window by clicking the little orange circle up in the top right of the screen. Then, I'll move to the VirtualBox interface and choose Devices and then click Insert Guest Additions CD image. When I'm prompted, I'll click Run. And then I'll type in my password. Once this process is completed, I'll be prompted to press Return to close the window. So I'll do that, and I need to restart the system again. Again, I'll go to the top right, click the downward facing arrow, click Power Off/Log Out, and then choose Power Off. And again, I'll click Restart. When the system restarts, I'll click my account name and then type my password. We can see from the change in the screen that something's different. That's a good sign. Now, if I navigate to the View menu, I can see that there's a checkbox next to Auto-resize Guest Display. This is what we want. Now that we're done using the guest additions CD image, I'll right-click it here in the dock on the left and choose Eject. Now, I'll take a few steps to make my screen a little bit easier to see. You could follow along if you'd like, but you don't have to. In order to make the changes that I want to make, I'll need to shut down this machine a third time. Then I'll go into the virtual machine settings, go into the Display menu, and increase the video memory. I'll set mine to 128 megabytes. I'll click OK, and then I'll click Start again. When prompted, I'll log in. And then I'll go to the View menu at the top of the screen. I'll choose Virtual Screen 1 and set my screen back to Scale to 100%. Then I'll go to View again and choose Full screen Mode. I'll right-click on the desktop, choose Display Settings, and change my scale to 200%. Then I'll click Apply. I'll click Keep Changes, and then I'll close the Settings window. Then, to download the exercise files for the course, I'll open up the Firefox web browser here from the dock. It's the first item in the list on the left. I'll visit the repository on GitHub, and I'll find the green button. I'll click it, and then I'll find the option to download ZIP. This will download the files from GitHub. I'll choose Save File and then click OK. Once I'm done with that, I'll close the web browser. From the dock on the left, I'll find the Files icon, and I'll click it. Here, I'll find my Downloads directory, and within that, I'll see the ZIP file. I'll right-click it, and I'll choose Extract Here. I'll click on the directory that appears when I extract the file, and then I'll look for the Exercise Files directory. This contains the files we'll use in the course, so I'll move it to my Documents folder. Then I'll click on Documents, then Exercise Files, and here's the files. This is where we'll find them throughout the rest of the course.

Contents