Friday, October 22, 2010

From Noob to Ninja - Your Guide to Mastering Linux

From Noob to Ninja – Your Guide to Mastering Linux

linuxninja-tuxEvery Linux user has been new at some point, and unless you’ve got a history of UNIX administration, the transition was likely a bit daunting. Many people began learning Linux before sites like Google and StackExchange made it easy to find answers, and ended up having to figure everything out in their own. While inconvenient, this approach can force you to challenge yourself and learn things about the system that you might otherwise never find out.

Usually here at MakeTechEasier, we focus on specific topics for our tutorials. This time we’re taking a different approach, and providing a high-level overview of series of steps designed to hone the skills of a Linux beginner, and turn them into the kind of geek who compiles a new kernel for fun.

Step 1 – Install an “Easy” Linux in Real Partitions

There’s a good chance that if you’re reading this, you’ve likely already installed a Linux such as Ubuntu or Fedora. These “desktop” Linux systems are specifically designed to be as simple as possible to install. It’s important to do an actual partition-based install (as opposed to a “virtual” partition as done by Wubi) because this will ensure you understand the way the partitions are named and the importance of a swap partition.

linuxninja-lucidinstall

Step 2 – Learn the Filesystem

This is particularly important if you’re transitioning from Windows. Linux does not store programs the same way Windows does. On Windows, a program’s files are normally stored in (drumroll please) Program Files, and that usually includes just about everything the program needs. Linux, however, takes an approach that may seem a bit more complicated but has some advantages.

linuxninja-fs

A Linux package will normally place its executable files in a location like /usr/bin, its configuration files in /etc, and perhaps its log files in /var. Why the split? In short, because that allows a user or administrator to work with groups of related files. For example, if you wanted to reinstall your OS but a lot of your apps have custom configurations, you can just back up your /etc directory and all your configs are saved. You could put /var in its own partition so that log files have a hard limit on the space they can take up.

For detailed info on the Linux filesystem hierarchy, check out this great guide from the folks at The Linux Documentation Project.

Step 3 – Explore /proc

We’ve mentioned before how useful it can be to understand /proc, the special filesystem created by Linux to hold dynamic system information. Understanding proc is essential toward understanding Linux, because it gives you live feedback on the state of your hardware and software.

Step 4 – Compile a Kernel

This is where a lot of people step back, feeling as if they’re not ready. The honest truth is that compiling a custom kernel is not as complicated as it may sound. Most of the time, the process consists of a few shell commands and a few minutes of reading over checkboxes. Often, customizing a kernel build is literally as simple as browsing a long list of options and picking the ones that sound good. Many options come with a recommended setting to help guide choices you might not be familiar with.

linuxninja-xconfig

Ubuntu provides an excellent guide on this topic here.

Step 5 – Install Gentoo

There are a few source-based distributions out there, and Gentoo is probably the best known among them. Where your average Linux like Ubuntu and Fedora will fetch packages, Gentoo fetches only the source code, and compile that code into the actual program. There are a few advantages (and disadvantages) to this approach, namely speed and flexibility.

Gentoo users set certain flags for the system that specify, among other things, the CPU type of the machine. When a user requests a package, say for example Firefox, Gentoo’s package manager will search the Firefox source code pack and download the code. It will check the user’s flags to get information, and then build the package that’s specifically optimized for that CPU.

linuxninja-gentoo

The Gentoo install process is not easy. It’s done through the command line and almost everything is done manually, so Gentoo provides excellent install documentation to help get you through.

Step 6 – Learn a Scripting Language

While C is usually the language of choice for Linux system internals, many of the applications are tied together using higher level programming and scripting languages like Python and bash. Learning one or both of these can be IMMENSELY useful for managing and automating your system.

For example, just yesterday I spoke with a friend who was tasked with gathering the specs from hundreds of hard drives on a company network. Many people would let out a little sigh, grab a clipboard, and start opening machines. This friend, being a Linux geek, instead whipped up a 3-line bash script which scanned the hard drive data for the whole network and printed the results in seconds.

If you’re looking for a place to start learning, MTE has a Basic Introduction to Python 3.

Step 7 – Install Linux From Scratch

You may have noticed in the section above when I mentioned that a Gentoo install involves doing nearly everything manually. Take out the word “nearly”, and you’re beginning to envision a LFS install. LFS is not a distribution exactly. In fact, it’s not a distribution at all. It’s a series of instructions, a way to build every… single… piece… of your Linux install directly from source code tarballs. There is no package manager, no installer, no helpful utilities. You just follow the steps to put each and every piece in place to make a bootable system.

The first time I did LFS, it took me a solid week to get it bootable. With some practice and a fast machine, you may be able to trim that down to a few hours. LFS is not for those lacking in serenity and patience, but if you’re willing to put in the time and effort, it’s one of the most rewarding experiences you can have on a PC.

Posted via email from ://allthings-bare

No comments:

Post a Comment