How I Learned Linux

[Update: A bunch of you are here because Eric S. Raymond is awesome and nice. Thanks, ESR!]

And, by extension, how you can.

I’ll start this off with a disclaimer. I am not a Linux expert by any means–in fact, I’m not even fluent, and don’t use it as my main operating system. However, if I sit down in front of a Linux computer to do some work, I’m perfectly comfortable with using it. I can use the command line comfortably, I know what repositories are for and not to download just whatever interesting-looking tarball off the Internet (unless I’m doing so to tinker with it), I can do a tiny bit of shell scripting, and I can even compile or interpret my own programs (written in less annoying languages) via the command line.

Most people are not there. It took me a long time to get there; I remember being interested in Linux long before I figured out even how to learn how to use it.

The boost that let me get into the Linux world was discovering virtual machines, which are great for letting you play with different distros, screw things up, delete everything if you want/need to, start over–all sort of nonsense. It’s worth noting that Linux systems won’t be as reliable on a VM because of funky stuff with virtual hardware and guest additions and that kind of thing. The tutorial I wrote earlier can help with that. (If you’re used to Windows, you won’t notice anything strange about their reliability.)

You don’t need to take a formal class on Linux. In fact, if you really want to learn Linux, taking a class will feel painfully slow for you and will probably try to teach you silly stuff like how to get X Windows [*] to run on a network, which will be boring and frustrating. You can learn much of what you would in a Linux class by tinkering–although, if you’re focused on computer networking rather than programming, you might like taking a class.

On whether it’s right to write intro posts like this

Hackerdom seems to contain a large contingent which considers that anyone who can’t find the information in the rest of this post for themselves isn’t worth helping, because they won’t have the right spirit or work ethic. I disagree. It’s entirely possible to not even know what to type into Google in order to start solving your problem, and this doesn’t necessarily imply anything about the person who is confused. Whether they’ll admit it or not, many hackers will have been similarly helped by being around other hackers who at least know what program their juniors are looking for but don’t know exists. This is what Linux User Groups are for–but, again, most people don’t know those exist, either.

I can understand not wanting to spoon-feed people all the way, and someone with the true hacker spirit wouldn’t want to be spoon-fed anyway because it’s too much fun to do your own research, since you run into lots of other interesting knowledge along the way. But I don’t consider it a detriment to the Linux world to give people a boost in, so here we go: how to get comfortable with Linux.

No, I’m not going to describe what everything does. This post would become ridiculously long and that IS something you can Google for yourself. I will, however, provide you with good links and descriptions where they’re necessary. 

1. Set up your first virtual machine (VM).

i. Download VirtualBox (opens in new tab)

ii. Download a torrent client–a reader suggested deluge or transmission; I haven’t used them myself. I use uTorrent, but as I don’t know much about P2P systems, I pretty much picked the first one I found. As our commenter pointed out, uTorrent has certain questionable downsides. Perhaps when I have time, I’ll do some research about the different torrent clients and do a post about it.

Also, learn how to set it up. If stuff downloads, but only uploads at a painful snail’s pace, you probably have it set up wrong (although you might just have a less popular distro).

iii. Torrent at least one Linux .iso file. If given the option, choose 32-bit.

Distros (distributions) you might want to play with include Xubuntu (which is pretty easy to use and has a decent interface), Debian with GNOME (which is my favorite), Fedora (which is a little different! but maybe you’ll like it), and Mint (which, depending on which one you get, may be based off of either Ubuntu or Debian–it’s kind of a nice middle ground between them and very popular). I suggest making VMs of any distro you’re interested in, and playing with them, rather than relying on other people’s opinions about which you should use. Those posts can be fun to read, but not very helpful in the long run.

Distros you should save for a point when you know what you’re doing better and want to explore other things Linux can do include, but are not limited to, Puppy Linux and Kali Linux. Puppy is meant for running on tiny systems and can be run on computers which don’t even have a hard drive (it can run on just RAM), and Kali is meant for digital security testing. Please don’t do anything stupid with Kali.

iv. Set up your VM.

There are a lot of how-tos on this subject, including my own, which I just updated; I really suggest that you get into the habit now of checking more than one to see how they’re different and how one might be better than the other. My own included a few weird voodoo/cargo-cult programming things that were in there because they’d made something work for arcane reasons when really it was something else that was wrong–which is why it just got updated, and why you should always look at more than one tutorial. Keep the links of good tutorials; you’ll meet other newbies who need them.

2. Learn the command line.

There are numerous excellent tutorials on this. I don’t need or want to rewrite them, but I will link to them.

Zed A. Shaw’s tutorial at the end of Learn Python the Hard Way. Start with this one. Keep the link; you can learn Python at that web site, the tutorials are really good. Don’t be dissuaded by the name, it’s easier than learning from the dispassionate bureaucrats writing Microsoft programming manuals any day.

How-To Geek (Will teach you how to install things, very important–although if you’re using Fedora or a derivative, you can’t use apt-get. Just replace “apt-get” with “yum” in any of the commands mentioned and you should be fine.)

If you’re still confused about apt-get, look here for Ubuntu’s how-to.

LinuxCommand.org — I don’t remember reading this all the way through, but I had it bookmarked, so probably it answered some question or other. Come back to it if you have questions.

3. Don’t break your system (unintentionally).

Sometimes you intentionally pound on stuff to see what breaks it. However, if something breaks and you have no idea what you did, that’s a glaring neon sign that you haven’t learned enough. It helps to know what kind of stuff will break your system and why before you get to that point, though.

Here’s a link I found with good advice. It says Debian, but the points it makes are not Debian-specific.

Don’t Break Debian

4. Know where to go for help.

Your first resource when you don’t know how something works should be this really helpful command that you NEED to know. It’s called “man”. No, there isn’t a “woman” command. “man” is short for “manual.”

Typing “man ls” into the Terminal will show you everything you could ever want to know about the ls command, including different formatting options like -a and -l. The utility of those flags may not seem like much, until you write a shell script that needs to use ls and have the output in a reliable format, so man pages can be your best friend.

Man pages can also be found on the Internet.

Google is your other best friend. Learn how to use it, please; it’ll save everyone’s time, including yours, in the long run.

However, if you’ve spent more than 30 minutes to an hour (depending on the complexity/obscurity of your problem) trying to find answers, it’s probably time to go to a human. Preferably, one who can program.

Your distro will have its own forum. If you’re trying out different distros, make sure you go to the right forum for the distro that has the problem, even if the bug isn’t distro-specific.

There are also more general Linux forums, like this one which even has a newbie section.

5. Learn the secret handshake.

I was going to make a joke about this to finish off the article. Then I realized there actually is kind of a secret handshake, if you want to be a hacker and not just become competent with Linux. Consider this optional but fun; it may help you stick with Linux instead of giving up, so visit these links if you get bored.

The Jargon File

How to Become a Hacker

How to Learn Hacking

This collection of links should set you in good stead to becoming competent with Linux. If, given this boost, you can’t get any further or find anything interesting to do with what you’ve learned… well, that’s the point where we’d be spoon-feeding you. But I think it’d be hard to get through all this without sort of learning the attitude and skills you’d need to keep going, if you wanted. If you weren’t cut out for this sort of hobby, you probably wouldn’t have had the persistence or interest to make it through–you would have given up halfway through this post.

Good luck, and happy hacking!

*X Windows is an older remote access program, and a window system. It used to be a reasonably good program, I’ve heard, but it’s not a good option now. It would allow you to virtualize one computer’s GUI on another computer. But there are inherent security risks in programs that transfer GUIs over a network–at least, so far. If there were a startup that wanted to improve that, I bet there’s a huge market for a secure remote access system.

Our teacher didn’t like it–she’s a firm believer in using SSH and the command line for this sort of thing, and I agree until someone comes up with a better solution–and I don’t think the textbook writer liked it either because he put it at the very end of the chapter, after all the other options.

 

SSH is faster anyway.

Advertisements

I found another useful trick in VirtualBox

You know how I love VMs because if it all goes pear-shaped, you can bomb the thing and make it over?

I found out how to make it even easier to revert changes by using snapshots. HowToGeek already covers this subject well, so I’m just going to link to them; this post is here as reference material for those of you who are following my site to learn about virtualization. As noted before, not all aspects of VMs and the software that builds them are obvious. I’m still exploring this technology, too; I’ve only been at it for a couple months maybe, so I haven’t discovered all the features yet, but I’ll update here when I find anything new.

Here’s HowToGeek’s article: http://www.howtogeek.com/150258/how-to-save-time-by-using-snapshots-in-virtualbox/

Play with Linux without changing your main OS: How to set up a VM

In this post, I’ll give you what will hopefully be a shortcut around all the nonsense I went through trying to make a Linux (specifically: Lubuntu) VM to play with. Not everything you do to make these things run well is terribly obvious, so I’m covering it for you.

I’m not going to assume you know everything, so I’m going to cover a lot of really basic info in this article. If you’re well-grounded in the basics, the tl;drs are in red.

VOCABULARY

OS: Operating System. Windows is one; Mac OS X is one; Linux is one.

RAM: aka “memory,” this isn’t the same thing as storage. RAM is like your computer’s short-term memory. Upgrading RAM often speeds up computers because it’s a common system bottleneck; that is, the system can only go as fast as its slowest component, and that’s often RAM. That’s not to say that every system will speed up if you upgrade RAM, because there are other components which could slow down a system (e.g., a fragmented hard drive, a really inefficient piece of programming). In addition, not every system needs a lot of RAM to run what it needs to run.

VM: A virtual machine is just a program that thinks it’s a real computer. It runs an operating system and has its own files. Anything you save to a VM stays there even if you shut the VM off (unlike a live USB). There are tons of uses for VMs. For instance, apart from the Linux VMs I made for fun and to mess around with, I also have a VM running Windows 7; this lets me run Windows-specific programs for school without actually having to use it as my main OS.

For more about what a VM is and why you’d want one, HowToGeek has an awfully nice look at the subject. Link opens in new tab.

64-bit; 32-bit; x86: You use 32-bit OSes on systems with = 4GB of RAM. Operating systems marked x86 are 32-bit.

Host OS: your “normal” OS, as opposed to the one that’s on the VM.

Guest OS: the OS that’s on the VM.

——————————————————————

YOU WILL NEED:

– A computer that’s pretty decent on the hardware front. If you don’t have at least 4GB of RAM and two cores, you’ll probably want to look into permanent live USBs instead. Because running a VM means that your hardware is working double-time to keep up two different OSes, plus any programs you’re running on them, things can get pretty demanding in that direction. Live USBs are less demanding because your computer doesn’t have to run your “normal” operating system alongside the new one.

– To install VirtualBox. (opens in new tab) That’s the official site; as always, it’s preferable to get your download straight from the developers’ own site so it doesn’t come with C|Net-bundled crapware or anything like that.

A Linux .iso in your favorite flavor. I used Lubuntu, which is just Ubuntu (pronounced “oo-BOON-tu”; it’s an African word) with a less fancy interface that’s easier on the VM’s limited hardware. You may want to do a little research into the different distributions and interfaces–Lubuntu’s not a bad starter, but there’s also Debian, Mint, and a whole host of others.

You’ll want the 32-bit (x86) version of your chosen distro. Linux can do a lot with a minimal amount of RAM, so don’t worry about it for now, even if you have a powerful computer that can give the VM >4GB of RAM. If, later, you decide your Linux VM really needs the extra power, you’ll know enough by then to whip up a 64-bit VM easily.

It helps the Linux developers if you use a torrent program (e.g., uTorrent) to download the .iso file that contains your chosen distro, rather than downloading straight from their site (which costs a lot of bandwidth, as the files are of course quite large). If you can’t, there are still ordinary downloads available.

If you’re at sea with all these options, just go ahead and grab the 32-bit version of Lubuntu from here. (opens in new tab)

——————————————————————

INSTALLING LINUX ON YOUR VM

1. That .iso you downloaded? Stick it somewhere you won’t lose it. I suggest putting it in your home folder. If you like, you can rename it too, but that’s usually unnecessary. You’ll want to keep the distro name and the version number (which will be something like 14.04) in the name. Don’t use spaces, but underscores and hyphens (_ or -, respectively) are okay.

2. Open up VirtualBox. Click through whatever tutorial junk it throws at you–you can read it if you want, but since this guide will take you through the steps anyway, it’s not necessary. Then go ahead and click the blue round/spiky-shaped button that says New, in order to create a new VM.

3. You need to choose a name for your VM. It doesn’t matter terribly what you name it. I name mine after awesome programmers–so far I have Adalace, Matsumoto, and Eric (points if you know who I’m referring to). Under Type, choose Linux. Under Version, you’ll need to tell it what flavor you picked out. If you’ve been following along with the Lubuntu .iso I recommended earlier, choose 32-bit Ubuntu. Remember, Lubuntu is just Ubuntu with a different user interface–the programming behind it is essentially the same. But it DOES matter that you choose the right bit version. It won’t work if you get that wrong–although if you find you accidentally checked the wrong bit version, you can change this in Settings later.

Other important note: Some Linux systems need you to mark the VM as 64-bit, or they won’t install–even if your .iso is 32-bit. Debian “Wheezy” is this way, and so are some others I’ve tried.

4. Now it wants to know how much RAM you’re going to feed the VM. This RAM gets allocated to the VM when you start it up, but it doesn’t “keep” the RAM when the VM shuts down. If you have a computer with 4GB of RAM and you decide to give your VM 1.5GB, then while the VM is running, your host computer will be running on 2.5GB of RAM and the VM will have 1.5. Then when you shut the VM off, your host will run on all 4GB again. I suggest feeding it at least 1.5GB, although you can give it more if you have more to spare. Remember: your host OS needs at least 2GB of RAM for itself.

Ah, but the slider doesn’t measure RAM in GB, does it? It’s using MB as a unit. 1024 MB = 1 GB, if you’re not familiar. It’s automatically set to 512MB, or half a gig, when you get to the screen. Probably your VM could run on that okay, as Lubuntu is pretty lightweight (this is where the different interface matters), but it’d be pretty slow. So just throw in ~1500MB RAM. Precision doesn’t terribly matter here, you don’t need to get it to 1532 MB exactly (though you can just type it in if you want).

5. Leave the radio button setting on “Create a virtual hard drive now.” Click Create.

6. Leave the radio button setting on VDI (if you knew you needed to use any of the other settings, you’d already be doing something more advanced than what this guide describes, and you wouldn’t be reading this). Click Continue.

7. Most of you will want to go with the dynamically allocated option here. VirtualBox explains the difference between them pretty well in the selection window, so I won’t rehash it. Choose, and click Continue.

8. Here’s where you set how much storage space the VM will have. If you picked dynamically allocated, you’re just setting a cap for how much room on your hard disk the VM can take up, and you can change this value later. You’ll want to think about it a bit more if you chose to make your VM a fixed size. Give yourself at least 8 GB, more if you want, and click Create again.

9. If you chose fixed size, you’ll have to wait for your computer to trundle on with its various creation processes, etc etc. If you chose dynamically allocated, you’ll almost immediately have a drive you can open up. First, though, we want to change a few settings on it. Click your VM once, and then click the Settings button.

10. Important step. There are different tabs available to you; first, go to System. You’re going to change the boot order. Basically no computers have a floppy drive any more, so uncheck that and click the down arrow three times to move it to the bottom of the list.

Leave the CD drive and the hard drive checked. Even if you don’t think you’ll use CDs on your VM, it’s important to leave it checked because (as far as I can tell) the VM thinks it’s booting from a CD in order to install the OS. Under Display, go ahead and let it use 3D acceleration. You may also want to give it more video memory; again, VirtualBox’s default settings are kind of bare-bones, so give it about 36MB instead of the default 12. If you feel the need to adjust this later, you can. The rest of the settings can be left alone until you have your own reasons to change them. Save your changes, close the Settings menu.

11. Now start up your VM with a double click or by using the green Start button. It’ll pop up with a window asking for a “virtual optical disk file.” That just means the .iso you downloaded earlier and oh-so-carefully put where you won’t lose it. Now you need to find it. Click the folder icon, navigate to it, and pull up your .iso.

12. Hit Enter to select English from the languages menu that pops up (if you’re reading this, you probably speak English), or pick your favorite language (one you understand, please) and hit Enter.

* It’s worth noting that if you click the mouse inside your VM window, it’ll pop up with a warning letting you know the VM will “capture” your mouse cursor, and telling you what key to press in order to un-capture it. It’s not a big deal, just take note of which key it says. For me, on Mac, it’s the command key. It may be the Ctrl or Windows key on Windows; I’m not sure. Pressing whatever key it is for you just tells the VM to let the host system use the cursor, instead of keeping it to itself like a greedy little bugger. Later on, your system may not need to bother you about this, and it may handle the cursor automatically. Usually it takes a minute for this feature to start up, though, so you may see the message from time to time. It’s nothing to worry about.

13. Navigate with the arrow keys and opt to install Lubuntu on your VM. Hit Enter again. It will most likely complain about your BIOS. This is because it doesn’t have a real BIOS, and its complaint does not actually matter. It’ll run anyway, just let it do its thing for a minute. You’re going to fool it into thinking it has a BIOS later.

14. Hopefully you’ll be rewarded with a lovely blue-and-purple background while the installer loads (or whatever color your chosen flavor has). Be patient; it’ll pop up. Pick English (or whatever language) again and hit Continue, unless you actually want to read the linked release notes.

15. It’ll tell you about some basic system requirements and ask that your computer should be plugged in and connected to the Internet. Your system requirements were covered when we allocated those resources to the VM when we made it, so don’t worry about that. Let it install the updates and software it wants to install; that way you don’t have to do it later. It won’t install junk. (Ha!) Click Continue.

16. It will think for a few minutes, trying to figure out if you’ve got any OSes on the disk already. Of course you don’t, as it’s a freshly minted VM. So let it wipe the nonexistent files off the drive and install Lubuntu. This won’t hurt your host (read: normal) operating system, or touch any of its files except for the VM’s personal file. Click Install Now.

17. It’ll ask for your timezone. Click your area on the map, or enter a major city in your timezone (e.g., Chicago, New York, Moscow) and hit Continue.

18. It’ll ask for your keyboard layout. If you’re using an ordinary keyboard such as might be found on a Windows laptop, keep the default settings. If you’re using a Mac, pick Macintosh. If you’re using a Dvorak keyboard, you know bloody well what setting you need. If you’re Russian, you’re gonna have to figure this one out on your own. It does have an option to detect your keyboard layout for you, but that doesn’t always work. Pick your keyboard layout and hit Continue.

19. Type in your name, re-enter your VM’s name, pick yourself a username and password, and pick whether you want to be prompted for said password. Basic stuff. Do the obvious and move on. Remember your password, even if you chose not to have the machine prompt you.

20. It’ll start really installing now. Let it run. You can leave it alone for a bit now.

21. When it declares that it’s finished installing and asks you to reboot the VM, just click the conveniently-located Restart Now button.

22. If it asks you to press Enter when it starts up, press Enter. It’ll complain about the BIOS again, and then it’ll start up for real.

23. It’s in a tiny window, though, even if you pick Fullscreen under the View options. That’s because we haven’t installed the guest additions packages yet. They’re basically a bunch of drivers and stuff that adjust Lubuntu (or whatever you’re using) to the “hardware” of the virtual machine (like the “BIOS”). If it’s not automatically handling switching your mouse and keyboard back and forth between the VM and your host machine, it may start once you install guest additions. So we’ll install those, we’ll reboot, and then hopefully it’ll show up in actual fullscreen when you fullscreen it.

The command to go in and out of fullscreen in VBox is the host key + F. For me, that means Command + F. If you don’t know what your host key is yet, Google it; it depends on your host operating system.

Lubuntu has a pretty bare interface. The taskbar is at the bottom, and probably there’s a software updater prompting you to update stuff. Guest additions first, though; we’ll update with the command line soon. So tell it to come back later. There are two ways to install guest additions. I will cover installing via the terminal; if you want to look into doing it via the GUI*, that’s your prerogative.

(*Graphical User Interface, pronounced “gooey.” A sillier name could not have been created, even by the likes of INTERCAL.)

—–INSTALLING GUEST ADDITIONS—–

This part is kind of distro-specific. In other words, if you’re using something other than Ubuntu or its alt-interface cousins Lubuntu, Xubuntu, or Kubuntu, you’re going to need to access the instructions specific to your Linux flavor here, at VirtualBox’s page on the matter.

Hit ctrl+alt+t to open the terminal. You can also access the terminal by clicking on the lower left-hand corner icon, mousing up to Accessories, and picking LXTerminal from the drop-down list. Keyboard shortcut’s faster, though.

Here are the commands you most likely need to enter. Note that they’re case-sensitive and need to be typed in exactly.

sudo apt-get update

sudo apt-get upgrade

[a little info on this pair can be found here]

sudo apt-get install dkms build-essential

[then reboot, open the terminal again, and run…]

sudo apt-get install virtualbox-guest-additions-iso virtualbox-guest-dkms

That should cover all your bases, and install anything that needs to be installed. Reboot again, try fullscreen mode and see if it works. It should.

—–TERMINAL INSTRUCTIONS FOR THOSE WHO ARE NEW TO THINGS—–

If you’re VASTLY new, you may want to have a look at this command-line tutorial made by Zed A. Shaw.

Some general information. People get intimidated by the terminal, so knowing more about it helps.

Any command you run with the sudo (“super-user do”) prefix will prompt you for your password. This is because you CAN do damaging things to your system while using this prefix (in this case, it’s not a system with anything important on it). If someone on the Internet tells you to run a command prefixed with sudo and you don’t know what it does, find out what it does first. There are people who will use these commands to help you, but there are also some people who’d like to play a nasty prank on you. So find out what the thing does from Google, or just run the command under a designated guinea-pig virtual machine, so it can’t damage any files.

You don’t need to worry *too* much about what you do to your VM (unless you put important files on it later), but if you switch to Linux as your main OS, you need to be more careful. VMs are sandboxed away from your host system and your files there, so you won’t hurt anything by screwing up a brand-new VM; if all else fails, you can delete the VM and start over. This is why VMs are a great playground for messing around with Linux–or, really, any unfamiliar piece of software.

It’s worth noting that when you type in a password, it won’t show up, even as character dots; this is a security thing. If you mistype while you’re typing the password, you can use Backspace as always. If you accidentally execute a command with a typo in it and you get that “I don’t know what the heck you’re talking about” message from the computer, you can hit the up arrow key once and it’ll pop back up, and you can correct your typo.

In addition, if you wait too long or reboot between commands, your sudo privileges will time out and you’ll have to prefix your next command with sudo again.

For both of these commands, the system will analyze how much space the suggested operation will take up on your hard disk, and it’ll ask you if you want to continue. Hit y and press enter so it can move on.

Another Linux thing: if it says [Y/n], then just pressing enter will do the same thing as pressing y and hitting enter, because the capitalized option is the default option. Conversely, if it says [y/N], hitting enter is the same as telling it no.

You can tell when your last command has finished running because the terminal will display a prompt that looks kind of like this: 

username@computername: ~$

Typing “exit” closes the terminal, and pressing ctrl+c makes it stop whatever thing it’s doing.

———————–

That should do it! You now have a working Linux VM.

If you don’t, well, Google is your friend, no? The Linux community is a broad one and someone has probably already asked your question on a forum somewhere. And if you still can’t find help, make an account on one of those forums and ask the question yourself! Be nice to the people there; they are helping you out of the goodness of their heart and are not being paid, so thank them!

Happy hacking!