{"id":342,"date":"2019-04-12T21:06:15","date_gmt":"2019-04-12T21:06:15","guid":{"rendered":"https:\/\/bootstrap-it.com\/blog\/?p=342"},"modified":"2020-12-10T23:55:43","modified_gmt":"2020-12-10T23:55:43","slug":"how-to-create-a-virtual-it-workspace","status":"publish","type":"post","link":"https:\/\/bootstrap-it.com\/blog\/?p=342","title":{"rendered":"How to create a virtual IT workspace"},"content":{"rendered":"<div id=\"s-share-buttons\" class=\"horizontal-w-c-circular s-share-w-c\"><a href=\"http:\/\/www.facebook.com\/sharer.php?u=https:\/\/bootstrap-it.com\/blog\/?p=342\" target=\"_blank\" title=\"Share to Facebook\" class=\"s3-facebook hint--top\"><\/a><a href=\"http:\/\/twitter.com\/intent\/tweet?text=How to create a virtual IT workspace&url=https:\/\/bootstrap-it.com\/blog\/?p=342\" target=\"_blank\"  title=\"Share to Twitter\" class=\"s3-twitter hint--top\"><\/a><a href=\"http:\/\/reddit.com\/submit?url=https:\/\/bootstrap-it.com\/blog\/?p=342&title=How to create a virtual IT workspace\" target=\"_blank\" title=\"Share to Reddit\" class=\"s3-reddit hint--top\"><\/a><a href=\"http:\/\/www.linkedin.com\/shareArticle?mini=true&url=https:\/\/bootstrap-it.com\/blog\/?p=342\" target=\"_blank\" title=\"Share to LinkedIn\" class=\"s3-linkedin hint--top\"><\/a><a href=\"mailto:?Subject=How%20to%20create%20a%20virtual%20IT%20workspace&Body=Here%20is%20the%20link%20to%20the%20article:%20https:\/\/bootstrap-it.com\/blog\/?p=342\" title=\"Email this article\" class=\"s3-email hint--top\"><\/a><\/div>\n<p><em>This article, which also <a href=\"https:\/\/medium.com\/@dbclin\">appears among my Medium articles<\/a>, is based on a chapter from my free online book, <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/learntech.bootstrap-it.com\/\" target=\"_blank\"><em>Solving for Technology: how to quickly learn valuable new skills in a madly changing technology world<\/em><\/a><em>. There\u2019s lots more where that came from at my Bootstrap IT site, including links to my book,&nbsp;<\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9\" target=\"_blank\"><em>Linux in Action<\/em><\/a><em>, and a hybrid course called&nbsp;<\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.manning.com\/livevideo\/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1\" target=\"_blank\"><em>Linux in Motion<\/em><\/a><em>&nbsp;that\u2019s made up of more than two hours of video and around 40% of the text of Linux in Action.<\/em><\/p>\n\n\n\n<p>Have you ever completely hosed your workstation or main laptop while testing out a new technology? Or do you have so many packages and their dependencies installed that you no longer have any idea what it is that makes your experiments succeed or fail?<\/p>\n\n\n\n<p>Virtualization can provide you with a clean, quick, lightweight environment where you can test to your heart\u2019s content. You\u2019re not even restricted to the operating system that\u2019s running on your host machine, so this is also a great way to see how things work on multiple platforms.<\/p>\n\n\n\n<p>When you\u2019re done\u200a\u2014\u200aor if everything collapses in glorious failure\u200a\u2014\u200ayou can simply kill off your environment and fire up a new one to replace it. No harm done.<\/p>\n\n\n\n<p>In this article, I\u2019ll explore VirtualBox and Linux Containers (LXCs) as tools for providing easily replicated and sharable virtual operating system environments. I\u2019ll finish up with a few thoughts about writing code and building software stacks directly within virtual environments<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4f6c\">VirtualBox<\/h3>\n\n\n\n<p>So say \u201chello\u201d to Oracle\u2019s free VirtualBox cross-platform hypervisor product and, in particular, to some advanced tricks for squeezing more value out of your (no-cost) investment. VirtualBox is something you can use on any operating system to create virtualized computers running just about any flavor of Windows or Linux.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>You do still have to get a license for any Windows image you decide to run, although you\u2019re generally free to install and use copies without activating the license for a month or so.<\/p><\/blockquote>\n\n\n\n<p>If you\u2019ve already read my&nbsp;<a href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9&amp;chan=freeCodeCamp1\" rel=\"noreferrer noopener\" target=\"_blank\">Linux in Action<\/a>&nbsp;book and some of this material feels a bit familiar, it\u2019s because this chapter is a scaled down version of Linux in Action\u2019s chapter 2. The content has been made available through kind permission from Manning Publications.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"0c4b\">Getting started with VirtualBox<\/h4>\n\n\n\n<p>VirtualBox provides an environment within which you can launch as many virtual computers as your physical system resources can handle. And, of course, it\u2019s a particularly useful tool for safely testing and learning new administration skills\u200a\u2014\u200awhich is our primary goal right now.<\/p>\n\n\n\n<p><strong>Installing VirtualBox<\/strong><\/p>\n\n\n\n<p>Want to try all this out from a Windows PC? Head over to the&nbsp;<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\" rel=\"noreferrer noopener\" target=\"_blank\">VirtualBox website<\/a>&nbsp;and download the executable archive. Click the file you\u2019ve downloaded and then work through a few setup steps (the default values should all work). Finally, you\u2019ll be asked whether you\u2019re OK with a possible reset of your network interfaces and then whether you want to install VirtualBox. Of course you are and do.<\/p>\n\n\n\n<p>Getting VirtualBox happily installed on an Ubuntu Linux machine is even simpler. Just two commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install virtualbox<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8397\">Defining a virtual&nbsp;machine<\/h4>\n\n\n\n<p>I\u2019m not sure whether you\u2019ve ever put together a physical computer from components, but it can get involved. Defining a new virtual machine within VirtualBox works pretty much the same way. The only significant difference is that, rather than having to get down on your hands and knees with a flashlight clenched between your teeth to manually add RAM and a storage drive to your box, VirtualBox lets you define your VM\u2019s \u201chardware\u201d specs by clicking your mouse.<\/p>\n\n\n\n<p>After clicking New in the VirtualBox interface, you will give the VM you\u2019re about to build a descriptive name and, as you can see in the figure, the software should be able to correctly populate the Type and Version fields automatically. The Type and Version you select here won\u2019t install an actual operating system, but are simply used to apply appropriate hardware emulation settings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/0*75MMkwUCV0veAz0X.png\" alt=\"\"\/><figcaption>The Create Virtual Machine dialog: VirtualBox will try to guess your OS and OS version to offer intelligent default choices&nbsp;later<\/figcaption><\/figure>\n\n\n\n<p>On the next screen you\u2019ll allocate RAM to your VM. Unless you\u2019re planning something particularly demanding\u200a\u2014\u200alike hosting a container swarm or running a busy web server\u200a\u2014\u200athe default amount (768 MB) should be fine. You can certainly give it more RAM if necessary, but don\u2019t forget to leave enough over for your host machine and any other VMs that might already live on it. So if your host only has 4 GB of physical RAM, you probably won\u2019t want to give half of that to your VM.<\/p>\n\n\n\n<p>Keep these limits in mind if you eventually decide to run multiple VMs at a time\u200a\u2014\u200asomething that will be useful for testing more complex infrastructure projects. Even if each VM is only using the default amount of memory, two or three of them can start to eat away at RAM needed for normal host operations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"eac6\">Defining your virtual hard&nbsp;disk<\/h4>\n\n\n\n<p>What\u2019s a computer without a hard disk? The VirtualBox setup process will now ask you if you\u2019d like to create a new virtual disk for your VM or use one that already exists. There may be times when you want to share a single disk between two VMs but for this exercise I\u2019m guessing that you\u2019ll want to start from scratch. So select \u201cCreate a virtual hard disk now\u201d.<\/p>\n\n\n\n<p>The next screen lets you choose a hard disk file format for the disk you\u2019re about to create. Unless you\u2019re planning to eventually export the disk to use within some other virtualization environment, the default VirtualBox Disk Image (VDI) format will work fine.<\/p>\n\n\n\n<p>I\u2019ve also never regretted going with the default \u201cDynamically allocated\u201d option to determine how the virtual drive will consume space on the host. By \u201cdynamic\u201d they mean that space on the host storage disk will be allocated to the VM only as-needed. Should the VM disk usage remain low, less host space will be allocated.<\/p>\n\n\n\n<p>A fixed sized disk, on the other hand, will be given its full maximum amount of space right away, regardless of how much it\u2019s actually using. The only advantage of \u201cFixed size\u201d is application performance, but since I generally only use VirtualBox VMs for testing and experiments, I\u2019m fine avoiding the trade off.<\/p>\n\n\n\n<p>When VirtualBox knows it\u2019s Linux you\u2019re after\u200a\u2014\u200aand because Linux makes such efficient use of storage space\u200a\u2014\u200aVirtualBox will probably offer you only 8 GB of total disk size on the next screen (shown below). Unless you\u2019ve got unusually big plans for the VM (like, say, you\u2019re going to be working with some serious database operations), that will probably be fine. On the other hand, if you had chosen Windows as your operating system, the default choice would have been 25 GB, and for good reason: Windows isn\u2019t shy about demanding lots of resources. That\u2019s a great illustration of one way Linux is so well suited to virtual environments.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/0*iiUlwfEnDheG-m_L.png\" alt=\"\"\/><figcaption>If necessary, your virtual disk can be as large as 2 TB\u200a\u2014\u200aor the maximum free space on the host&nbsp;device<\/figcaption><\/figure>\n\n\n\n<p>You can also edit the name and location VirtualBox will use for your disk on this screen.<\/p>\n\n\n\n<p>When you\u2019re done, click Create and the new VM will appear in the list of VMs on the left side of the VirtualBox manager. Enjoy the taste of success, but you\u2019re not done: that was just the machine. Now you\u2019ll need an operating system to bring it to life.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"bda3\">Downloading an operating system<\/h4>\n\n\n\n<p>Now that you\u2019ve defined your new VM\u2019s virtual hardware profile, here\u2019s what still needs doing:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Download a file (in ISO format) containing the image of the operating system you want to use.<\/li><li>Boot the new VM using a virtual DVD drive containing the ISO you downloaded<\/li><li>Work through the standard OS installation process<\/li><li>Boot the VM and launch the OS you just installed<\/li><\/ul>\n\n\n\n<p>You\u2019ll need to download a&nbsp;.ISO file containing the operating system files and installation program. Finding the right file is usually just a matter of searching the internet for the distribution name and the word \u201cdownload\u201d. In the case of Ubuntu, you could alternatively just go to the&nbsp;<a href=\"https:\/\/ubuntu.com\/\" rel=\"noreferrer noopener\" target=\"_blank\">ubuntu.com<\/a>&nbsp;page and click on the Downloads tab as you see in the figure. Notice the various flavors of Ubuntu that are available. If you\u2019re going to be using this VM for administration tasks, then the small and fast Server version is probably a better choice than Desktop.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/0*SgivFWTEZblJ9F-I.png\" alt=\"\"\/><figcaption>The Downloads drop-down on the home page of Ubuntu.com. Note the range of versions Ubuntu&nbsp;offers<\/figcaption><\/figure>\n\n\n\n<p><strong>Validate the ISO archive you downloaded<\/strong><\/p>\n\n\n\n<p>Large files can sometimes become corrupted during the download process. If even a single byte within your&nbsp;.ISO has been changed, there\u2019s a chance the installation simply won\u2019t work. Because you don\u2019t want to invest time and energy only to discover that there was a problem with the download, it\u2019s always a good idea to immediately calculate the checksum (or hash) for the&nbsp;.ISO you\u2019ve downloaded to confirm that everything is as it was.<\/p>\n\n\n\n<p>To do that, you\u2019ll need to get the appropriate SHA or MD5 checksum\u200a\u2014\u200awhich is a long string looking something like this:<\/p>\n\n\n\n<p><code>4375b73e3a1aa305a36320ffd7484682922262b3<\/code><\/p>\n\n\n\n<p>In the case of Ubuntu, getting that will mean going to the web page at&nbsp;<a href=\"http:\/\/releases.ubuntu.com\/\" rel=\"noreferrer noopener\" target=\"_blank\">releases.ubuntu.com<\/a>, clicking the directory matching the version you downloaded, and then clicking one of the links to a checksum (like, for instance, SHA1SUMS).<\/p>\n\n\n\n<p>You should compare the appropriate string from that page with the results of a command run from the same directory as your downloaded&nbsp;.ISO that might look like this:<\/p>\n\n\n\n<p><code>$ shasum ubuntu-16.04.2-server-amd64.iso<\/code><\/p>\n\n\n\n<p>If they match, you\u2019re in business. If they don\u2019t\u200a\u2014\u200aand you\u2019ve double checked to make sure you\u2019re looking at the right version\u200a\u2014\u200athen you might have to download the&nbsp;.ISO a second time.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"43f4\">Installing an operating system<\/h4>\n\n\n\n<p>Once your&nbsp;.ISO file is in place, head back to VirtualBox. With the VM you just created highlighted in the left panel, click the green Start button at the top of the app. You\u2019ll be prompted to select a&nbsp;.ISO file from your file system to use as a virtual DVD drive. Naturally, you\u2019ll choose the one you just downloaded. The new VM will read this DVD and launch an OS installation.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Most of the time the installation process will go fine. However, describing solutions to each of the many small things that could go wrong would require a whole whack of articles. So if you do have trouble you can consult the documentation and guides that are available for your operating system or share your question with the online community.<\/p><\/blockquote>\n\n\n\n<p>When everything is nicely installed, there might still be a few more things to take care of before you can successfully boot into your VM. With your VM\u2019s entry highlighted, click the yellow Settings icon. Here\u2019s where you can play with your VM\u2019s environment and hardware settings.<\/p>\n\n\n\n<p>Clicking on Network, for example, allows you to define network connectivity. If you want your VM to have full internet access through the host machine\u2019s network interface then, as shown below, you can select \u201cBridged Adapter\u201d from the Attached drop-down, and then the name of your host\u2019s adapter.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/0*YORXu0i7ssVjkanw.png\" alt=\"\"\/><figcaption>The network tab of the Settings screen. You can determine what type of network interface\u200a\u2014\u200aor interfaces\u200a\u2014\u200ato use for your&nbsp;VM<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Using a bridged adapter might not always be your first choice, and it might sometimes present a security risk. In fact, choosing \u201cNAT Network\u201d is a more common way to provide a VM with internet access. However a bridged network is the easiest way to gain full network connectivity so, for testing at least, it\u2019s a useful approach.<\/p><\/blockquote>\n\n\n\n<p>These next sections are a bit bonus-y, but who doesn\u2019t like free stuff? I\u2019m going to tell you about two related tricks: how to organize your VirtualBox VMs to make spinning up new ones as quick as possible, and how to use the command line to share VMs across a network.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"ccc2\">Cloning VMs for quick&nbsp;starts<\/h4>\n\n\n\n<p>One of the most obvious advantages of working with VMs is the ability to quickly access a fresh, clean OS environment. But if accessing that environment requires going through the full install process, than I don\u2019t see a whole lot of \u201cquickly.\u201d<\/p>\n\n\n\n<p>Until, that is, you throw cloning into the mix. Why not keep your original VM in its clean post-install state, and simply create an identical clone whenever you want to do some real work?<\/p>\n\n\n\n<p>It\u2019s easy. Take another look at the VirtualBox App. Select the (stopped) VM you want to use as a master copy, click the Machine menu link, and then Clone. You\u2019ll confirm the name you\u2019d like to give your clone and then, after clicking Next, whether you want to create a Full clone (meaning entirely new file copies will be created for the new VM) or Linked clone (meaning the new VM will share all the&nbsp;<em>base<\/em>&nbsp;files with its master, while maintaining your new work separately).<\/p>\n\n\n\n<p>Selecting the Linked option will go much faster and take up much less room on your hard disk. The only down side is that you\u2019ll be unable to move this particular clone to a different computer later. It\u2019s your choice.<\/p>\n\n\n\n<p>Now click Clone, and a new VM will show up in the VM panel. Start it the way you normally would and then log in using the same credentials you set on the master.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"67bb\">Managing VMs from the command&nbsp;line<\/h4>\n\n\n\n<p>VirtualBox comes with its own command line shell that\u2019s invoked using&nbsp;<code>vboxmanage<\/code>. Why bother with the command line? Because, among other benefits, it will allow you to work on remote servers &#8211; which can greatly increase the scope of possible projects. To see how&nbsp;<code>vboxmanage<\/code>&nbsp;works, use&nbsp;<code>list vms<\/code>&nbsp;to list all the VMs currently available on your system. Here&#8217;s how that looks on my machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vboxmanage list vms\u201cUbuntu-16.04-template\u201d \n{c00d3b2b-6c77\u20134919\u201385e2\u20136f6f28c63d56}\u201ccentos-7-template\u201d {e2613f6d-1d0d-489c-8d9f-21a36b2ed6e7}\u201cKali-Linux-template\u201d {b7a3aea2\u20130cfb-4763\u20139ca9\u2013096f587b2b20}\u201cwebsite-project\u201d {2387a5ab-a65e-4a1d-8e2c-25ee81bc7203}\u201cUbuntu-16-lxd\u201d {62bb89f8\u20137b45\u20134df6-a8ea-3d4265dfcc2f}<\/code><\/pre>\n\n\n\n<p><code>vboxmanage clonevm<\/code>&nbsp;will pull off the same kind of clone action I described above using the GUI. Here, I&#8217;m making a clone of the Kali-Linux-template VM, naming the copy &#8220;newkali&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vboxmanage clonevm Kali-Linux-template --name newkali<\/code><\/pre>\n\n\n\n<p>That will work nicely as long as I only need to use the new VM here on my local computer. But suppose I wanted other members of my team to have an exact copy of that VM\u200a\u2014\u200aperhaps so they could test something I\u2019ve been working on. For that, I\u2019ll need to convert the VM to some standardized file format. Here\u2019s how I might export a local VM to a file using the Open Virtualization Format (.OVA):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vboxmanage export website-project -o website.ova\n0%\u202610%\u202620%\u202630%\u202640%\u202650%\u202660%\u202670%\u202680%\u202690%\u2026100%Successfully exported 1 machine(s).<\/code><\/pre>\n\n\n\n<p>Next, you\u2019ll need to copy the&nbsp;.OVA file to your colleague\u2019s computer. Bear in mind that the file won\u2019t, by any standard, be considered small and dainty. If you haven\u2019t got network bandwidth to spare for a multiple GB transfer, then consider moving it via a USB device.<\/p>\n\n\n\n<p>Once the transfer is complete, all that\u2019s left is, from the remote computer, to import the VM into that machine\u2019s VirtualBox. The command is simple:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vboxmanage import docker.ova<\/code><\/pre>\n\n\n\n<p>Confirm that the import operation worked using&nbsp;<code>list vms<\/code>&nbsp;and try launching the VM from the desktop.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vboxmanage list vms\u201cdocker-project\u201d \n{30ec7f7d-912b-40a9\u20138cc1-f9283f4edc61}<\/code><\/pre>\n\n\n\n<p>If you don\u2019t need any fancy remote access, you can also share a VM from the GUI. With the machine you want to share highlighted, click on the File menu and then on Export Appliance.<\/p>\n\n\n\n<p>Coming next: the wondrous and mysterious world of LXC.<\/p>\n\n\n\n<p>VirtualBox is great for running operations requiring kernel access, for when you need GUI desktop sessions, or for testing niche market edge-case operating systems. But if you\u2019re on a Linux machine and you just need fast access to a clean Linux environment and you\u2019re not looking for any special release version, then you\u2019d be hard pressed to beat Linux Containers.<\/p>\n\n\n\n<p>Just how fast are LXC containers? You\u2019ll see for yourself soon enough. But, because they skillfully share many system resources with both the host and other containers, they work like full-bore standalone servers while using only minimal storage space and memory.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>NOTE: We\u2019re going to discuss the classic LXC, but you should be aware that there\u2019s a similar environment from the same developers called LXD. LXD is essentially a newer implementation of the LXC interface. It still uses LXC under the hood, but provides a different set of commands that extend functionality to remote network administration.<\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6973\">Getting started with&nbsp;LXC<\/h3>\n\n\n\n<p>Install LXC on your Ubuntu workstation? Piece of cake:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install lxc<\/code><\/pre>\n\n\n\n<p>That\u2019s it. We\u2019re ready to get down to business. The basic LXC skill set is actually quite simple. I\u2019m going to show you the three or four commands you\u2019ll need to make it all work, and then an insider tip that, once you understand how LXC organizes itself, will just blow you away.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"364b\">Launch your first container<\/h4>\n\n\n\n<p>Why not dive right in and create your first container? The value given to&nbsp;<code>-n<\/code>sets the name I want to use for the container, and&nbsp;<code>-t<\/code>&nbsp;tells LXC to build the container from the Ubuntu template.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-create -n mycont -t ubuntu<\/code><\/pre>\n\n\n\n<p>If you decided to create, say, a CentOS container, then you should make a note of the final few lines of the output, as it contains information about the password you should use to log in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-create -n centos_lxc -t centos \n&#91;...]The temporary root password is stored in:        '\/var\/lib\/lxc\/centos_lxc\/tmp_root_pass'<\/code><\/pre>\n\n\n\n<p>You will log in using the user name \u201croot\u201d and the password contained in that file. If, on the other hand, your container used the Ubuntu template, then you\u2019ll use \u201cubuntu\u201d for both your user name and password. Naturally, if you plan to use this container for anything serious, you\u2019ll want to change that password right away.<\/p>\n\n\n\n<p>Use&nbsp;<code>lxc-ls --fancy<\/code>&nbsp;to check the status of your container:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-ls --fancy\nNAME    STATE   AUTOSTART GROUPS IPV4    IPV6 \nmycont  STOPPED 0         -      -       -<\/code><\/pre>\n\n\n\n<p>Well, it exists, but apparently it needs starting. As before, the&nbsp;<code>-n<\/code>&nbsp;specifies by name the container you want to start.&nbsp;<code>-d<\/code>&nbsp;stands for &#8220;detach&#8221; &#8211; meaning you&nbsp;<em>don&#8217;t<\/em>&nbsp;want to be automatically dropped into an interactive session as the container starts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-start -d -n mycont<\/code><\/pre>\n\n\n\n<p>Listing your containers should now display something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-ls --fancy\nNAME    STATE   AUTOSTART GROUPS IPV4        IPV6\nmycont  RUNNING 0         -      10.0.3.142  -<\/code><\/pre>\n\n\n\n<p>This time, the container is running and has been given an IP address. You could use this address to log in using a secure shell session.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh ubuntu@10.0.3.142<\/code><\/pre>\n\n\n\n<p>Alternatively, you can launch a root shell session within a running container using&nbsp;<code>lxc-attach<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo lxc-attach -n mycont\nroot@mycont:\/#<\/code><\/pre>\n\n\n\n<p>When you\u2019re done playing with your new container, you can either run\u00a0<code>exit<\/code> to log out leaving the container running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@mycont:\/# exit\nexit<\/code><\/pre>\n\n\n\n<p>\u2026or shut the container down using&nbsp;<code>shutdown -h now<\/code>.<\/p>\n\n\n\n<p>But before you do that, let\u2019s find out just how blazing fast LXC containers are. The&nbsp;<code>-h<\/code>flag I added to&nbsp;<code>shutdown<\/code>&nbsp;just before stands for &#8220;halt&#8221;. If I would use&nbsp;<code>r<\/code>instead, rather than shutting down for good, the container would reboot. So let&#8217;s run reboot and then try to log in again right away to see how long it takes for the container to get back up on its feet.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@mycont:\/# shutdown -r now\nsudo lxc-attach -n mycont<\/code><\/pre>\n\n\n\n<p>How did that go? I\u2019ll bet that, by the time you managed to retype the&nbsp;<code>lxc-attach<\/code>command, mycont was awake and ready for action. But did you know that hitting the up arrow key in Bash will populate the command line with the previous command. Using that would make it even faster to request a login. In my case, there was no noticeable delay. The container shut down and fully rebooted in&nbsp;<em>less than 2 seconds<\/em>!<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Linux containers are also really easy on system resources. Unlike my experience with VirtualBox VMs\u200a\u2014\u200awhere running three concurrently already starts to seriously impact my 8GB host workstation performance\u200a\u2014\u200aI can launch all kinds of LXC containers without suffering any slowdown.<\/p><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"a9aa\">Fixing a cold LXC container<\/h4>\n\n\n\n<p>Now what about that insider tip I promised you? Well, back in a terminal on the host machine (as opposed to the container), you\u2019ll need to open an administrator shell using&nbsp;<code>sudo su<\/code>. From here on in &#8211; until you type&nbsp;<code>exit<\/code>&nbsp;&#8211; you will be&nbsp;<code>sudo<\/code>&nbsp;full-time.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo su\n&#91;sudo] password for username:#<\/code><\/pre>\n\n\n\n<p>Now change directory to&nbsp;<code>\/var\/lib\/lxc\/<\/code>&nbsp;and list the contents. You should see a directory with the name of your container. If you&#8217;ve got other containers on the system, they&#8217;ll have their own directories as well.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd \/var\/lib\/lxc\n# ls mycont<\/code><\/pre>\n\n\n\n<p>Move to your container directory and list its contents. There will be a file called \u201cconfig\u201d and a directory called \u201crootfs\u201d. The \u201cfs\u201d stands for \u201cfile system\u201d.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd mycont\n# lsconfig rootfs<\/code><\/pre>\n\n\n\n<p>It\u2019s the rootfs directory that I really want you to see right now:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cd rootfs\n# lsbin   \ndev  home  lib64  mnt  proc  run   srv  tmp  varboot  etc  lib   media  opt  root  sbin  sys  usr<\/code><\/pre>\n\n\n\n<p>All those subdirectories that fill rootfs\u2026do they look familiar to you? Of course! They\u2019re all part of the Linux Filesystem Hierarchy Standard. This is essentially the container\u2019s root (\/) directory\u2026but within the&nbsp;<em>host\u2019s<\/em>&nbsp;file system. As long as you have admin permissions on the host, you\u2019ll be able to browse through those directories and edit any files you want\u200a\u2014\u200aeven when the container isn\u2019t running.<\/p>\n\n\n\n<p>There are all kinds of things you\u2019ll be able to do with this access, but here\u2019s one that can quite possibly save your (professional) life one day. Suppose you do something dumb on a container and lock yourself out, there\u2019s now nothing stopping you from navigating through the file system, fixing the configuration file that you messed up, and getting back to work. Go ahead: tell me that\u2019s not cool.<\/p>\n\n\n\n<p>Need to mount a single process on a stopped container? Just&nbsp;<a href=\"https:\/\/hackernoon.com\/chroot-the-magical-healing-powers-of-the-original-linux-virtualization-tool-9aa4c3928711\" rel=\"noreferrer noopener\" target=\"_blank\">use chroot the way I describe in this article<\/a>.<\/p>\n\n\n\n<p>But it gets better. It\u2019s true that the&nbsp;<a href=\"https:\/\/hackernoon.com\/too-many-choices-how-to-pick-the-right-tool-to-manage-your-docker-clusters-b5b3061b84b7\" rel=\"noreferrer noopener\" target=\"_blank\">Docker ecosystem<\/a>&nbsp;has gained many layers of features and sophistication since the technology moved out from under LXC\u2019s shadow some years ago. Under the hood, however, it\u2019s still built on top of a basic structural paradigm that will be instantly recognizable to anyone familiar with LXC.<\/p>\n\n\n\n<p>Which means that, should you be inclined to test drive the fastest-growing virtualization technology of the decade, you\u2019ve already got skin in the game.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"c652\">Writing code on a remote&nbsp;server<\/h3>\n\n\n\n<p>Now that you\u2019ve got those virtual environment thingies all figured out, what can you do with \u2018em? Well, it\u2019s obvious that such setups are perfect for playing with system tools and architectures.<\/p>\n\n\n\n<p>Suppose you\u2019re not into system stuff, but you would like a safe place to build applications. What do I mean by \u201csafe?\u201d I\u2019m talking about an environment where you can freely install libraries and dependency packages without having to worry about destabilizing your personal work computer.<\/p>\n\n\n\n<p>But there are limits to how far that can take you. There\u2019s a lot going on beneath the surface of IDEs like Eclipse or Visual Studio, and people become very attached to their convenience. But expecting to be able to easily run all those layers of complexity over a remote connection\u200a\u2014\u200aand especially on a headless remote server\u200a\u2014\u200ais perhaps a bit ambitious.<\/p>\n\n\n\n<p>But still, wouldn\u2019t it be nice to work on the IDE on your laptop and have the code saved, compiled, and run remotely\u2026say, on a hosted VM or cloud instance? That way you could build your applications on the servers where they\u2019ll actually be run without having to risk the stability of your own workstation.<\/p>\n\n\n\n<p>It can be done. Generally, the trick is to get your IDE to ride on top of a Secure Shell (SSH) session. For details, search the internet for something like \u201ceclipse edit java code on remote server\u201d.<\/p>\n\n\n\n<p><em>This article is based on a chapter from my free online book,&nbsp;<\/em><a href=\"https:\/\/learntech.bootstrap-it.com\/\" rel=\"noreferrer noopener\" target=\"_blank\"><em>Solving for Technology: how to quickly learn valuable new skills in a madly changing technology world<\/em><\/a><em>. There\u2019s lots more where that came from at my Bootstrap IT site, including links to my book,&nbsp;<\/em><a href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9\" rel=\"noreferrer noopener\" target=\"_blank\"><em>Linux in Action<\/em><\/a><em>, and a hybrid course called&nbsp;<\/em><a href=\"https:\/\/www.manning.com\/livevideo\/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1\" rel=\"noreferrer noopener\" target=\"_blank\"><em>Linux in Motion<\/em><\/a><em>&nbsp;that\u2019s made up of more than two hours of video and around 40% of the text of Linux in Action.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article, which also appears among my Medium articles, is based on a chapter from my free online book, Solving for Technology: how to quickly learn valuable new skills in a madly changing technology world. There\u2019s lots more where that&hellip; <a href=\"https:\/\/bootstrap-it.com\/blog\/?p=342\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-342","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create a virtual IT workspace - Bootstrap IT<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bootstrap-it.com\/blog\/?p=342\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a virtual IT workspace - Bootstrap IT\" \/>\n<meta property=\"og:description\" content=\"This article, which also appears among my Medium articles, is based on a chapter from my free online book, Solving for Technology: how to quickly learn valuable new skills in a madly changing technology world. There\u2019s lots more where that&hellip; Continue Reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bootstrap-it.com\/blog\/?p=342\" \/>\n<meta property=\"og:site_name\" content=\"Bootstrap IT\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-12T21:06:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-10T23:55:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bootstrap-it.com\/blog\/wp-content\/uploads\/linux-virtual.png\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"384\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbclin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@davidbclinton\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbclin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"22 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=342\",\"url\":\"https:\/\/bootstrap-it.com\/blog\/?p=342\",\"name\":\"How to create a virtual IT workspace - Bootstrap IT\",\"isPartOf\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#website\"},\"datePublished\":\"2019-04-12T21:06:15+00:00\",\"dateModified\":\"2020-12-10T23:55:43+00:00\",\"author\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec\"},\"breadcrumb\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=342#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bootstrap-it.com\/blog\/?p=342\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=342#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bootstrap-it.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a virtual IT workspace\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#website\",\"url\":\"https:\/\/bootstrap-it.com\/blog\/\",\"name\":\"Bootstrap IT\",\"description\":\"Learn technology using technology\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bootstrap-it.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec\",\"name\":\"dbclin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g\",\"caption\":\"dbclin\"},\"sameAs\":[\"http:\/\/bootstrap-it.com\/\",\"dbclinton\",\"https:\/\/twitter.com\/davidbclinton\"],\"url\":\"https:\/\/bootstrap-it.com\/blog\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a virtual IT workspace - Bootstrap IT","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bootstrap-it.com\/blog\/?p=342","og_locale":"en_US","og_type":"article","og_title":"How to create a virtual IT workspace - Bootstrap IT","og_description":"This article, which also appears among my Medium articles, is based on a chapter from my free online book, Solving for Technology: how to quickly learn valuable new skills in a madly changing technology world. There\u2019s lots more where that&hellip; Continue Reading &rarr;","og_url":"https:\/\/bootstrap-it.com\/blog\/?p=342","og_site_name":"Bootstrap IT","article_published_time":"2019-04-12T21:06:15+00:00","article_modified_time":"2020-12-10T23:55:43+00:00","og_image":[{"width":640,"height":384,"url":"https:\/\/bootstrap-it.com\/blog\/wp-content\/uploads\/linux-virtual.png","type":"image\/png"}],"author":"dbclin","twitter_card":"summary_large_image","twitter_creator":"@davidbclinton","twitter_misc":{"Written by":"dbclin","Est. reading time":"22 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bootstrap-it.com\/blog\/?p=342","url":"https:\/\/bootstrap-it.com\/blog\/?p=342","name":"How to create a virtual IT workspace - Bootstrap IT","isPartOf":{"@id":"https:\/\/bootstrap-it.com\/blog\/#website"},"datePublished":"2019-04-12T21:06:15+00:00","dateModified":"2020-12-10T23:55:43+00:00","author":{"@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec"},"breadcrumb":{"@id":"https:\/\/bootstrap-it.com\/blog\/?p=342#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bootstrap-it.com\/blog\/?p=342"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/bootstrap-it.com\/blog\/?p=342#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bootstrap-it.com\/blog"},{"@type":"ListItem","position":2,"name":"How to create a virtual IT workspace"}]},{"@type":"WebSite","@id":"https:\/\/bootstrap-it.com\/blog\/#website","url":"https:\/\/bootstrap-it.com\/blog\/","name":"Bootstrap IT","description":"Learn technology using technology","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bootstrap-it.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec","name":"dbclin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g","caption":"dbclin"},"sameAs":["http:\/\/bootstrap-it.com\/","dbclinton","https:\/\/twitter.com\/davidbclinton"],"url":"https:\/\/bootstrap-it.com\/blog\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=342"}],"version-history":[{"count":4,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/342\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/342\/revisions\/419"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/343"}],"wp:attachment":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}