You scoured through old computer parts to put together a server, and you trudged through the process of installing Linux. Now you’re looking at an interface reminiscent of a B-rated hacking movie from the mid 1980’s. This part of the private server guide teaches you the basics of using Linux and interacting with the command-line.
When you boot your machine for the first time, a few things will happen: a menu will appear for a couple of seconds, followed by several flashes of the screen and dozens of lines of scrolling text. Don’t blink, or you might miss it. While this may seem off-putting, it’s all a normal part of the boot process.
The Boot Menu
The menu that appears is your boot menu. When you boot your computer, one of the earliest tasks is loading the Linux (remember that Linux is a kernel, while Ubuntu is a distribution of Linux). A distribution can have several copies of Linux installed at any given time. The boot menu lets you to switch between different kernels at boot time in the event one kernel works better than another. In most cases, you won’t have to worry about this. When Ubuntu updates the kernel, it automatically updates the boot menu to point to the latest one. You can visit this link for additional information on what the boot loader is and how it can be configured.
Wall of Text
That scary scrolling wall of text that appears after you select a kernel isn’t actually all that scary. As the kernel begins loading different parts of the system, diagnostic information is printed to the screen. In the event of a critical failure (i.e., you can no longer interact with the computer), the information is already available for you to see. Fortunately, unless you experience a critical failure while booting, most of this information will be irrelevant. Ubuntu’s website has more information on the boot process.
The Command Line
After the boot process is finished, you’re dropped into what’s known as a tty. The tty (short for teletype, but terminal is commonly used instead) provides a command-line interface to the computer. As the name implies, the command-line allows you to send commands the computer using your keyboard. The command-line may seem archaic, but with a little familiarity it can become a very powerful interface for managing your server.
You may notice a number next to tty. Ubuntu provides 7 independent terminals which you can swap between at any time. Each terminal can be accessed through the key combination CTRL + ALT + <terminal number>. This way, if you have a process running on one terminal, you can easily switch to another terminal to continue working. As an aside, on desktop Linux distributions, terminal 7 is typically reserved for the graphical user interface. What this implies is that, unlike Windows and OS X where the graphical user interface is the only interface, Linux runs its graphical interface on top of the underlying command line. You can in fact switch back and forth from the graphical interface to the command line, and even reset the graphical session from the command line.
If you haven’t already, log in to your server using the username and password you supplied during installation. You’ll see a welcome message along with some basic statistics about your server such as drive usage, memory usage, and system load. At the end of the welcome message, you’ll see the following line of text:
<user>@<hostname>: ~$ _
This is the command prompt, so called because the computer is prompting you for input. For the most part, server software is designed to run automatically in the background, without any user intervention. However, when you need to actively manage your computer, the command prompt provides the means to interact with the software running on your system. The prompt displays the current logged in user, the hostname, and the working directory (more on that later).
Commands are broken down into two components: the program that you want to run, and any parameters you want to supply to the command. Parameters are a way for you to specify exactly what you want the command to do. For instance, let’s look at a basic command for printing text to the screen:
echo “Hello World!”
This command invokes the echo program. We pass “Hello World!” as a parameter to tell the echo program that we want it to display “Hello World!”. When we hit enter, we see this reflected in the command line.
Once the program finishes, the command prompt moves up the screen and a new one appears, ready to accept a new command.
One of the most difficult aspects of using the command line is learning which command to use in a given situation. This link covers some of the more basic commands, but if you find yourself in more unfamiliar territory, Google will almost always help you find a command that will perform the action you need.
One of the quickest ways to learn about a command’s parameters is through its manual (or man) page. Man pages are available for almost every program and provide an in-depth explanation of the program’s usage and parameters. For instance, to learn more about echo, simply type:
You can navigate using the arrow keys, the Page Up key, and the Page Down key. To exit, type “:” followed by “q”.
User Permissions and Privileges
One of Linux’s strengths is its separation of privileges. You can add and remove users from your system at any time, and fine-tune their access to various parts of the system. However, there’s one user that always has full access regardless of whether you add 1 or 1000 users. That user is root, and once you understand what root is capable of you’ll understand why Ubuntu makes it impossible to log in as root by default.
The Root of All Evil
The root user is the supreme user behind each Linux installation, having complete access to all areas of the system. A user who is logged in as root can install or uninstall software, change the speed of the CPU, delete everything on the hard drive, access another user’s files, power off the system, or install and run malware. Needless to say, root requires a very intimate knowledge of Linux before it can be used safely.
Although root has its dangers, it’s often the only way to perform crucial tasks such as installing software, restarting services, and editing program files. As a workaround, Ubuntu uses the sudo command to temporarily provide root privileges to common users. sudo (short for “substitute user do”) allows you to run a command as another user without having to modify privileges. sudo is frequently used to temporarily gain root access as a regular user. By default, the user you created during setup can use sudo using the following command structure:
sudo <command> <command parameters>
On first use, sudo will warn you about the responsibility of running a command as root before asking you for your password. If you’re sure about what you’re doing, enter your password. If you change your mind, press Ctrl+C to cancel the command.
The File System
Similar to Windows and OS X, the Linux file system is based on a hierarchy. The base of the file system is known as root (not to be confused with the root user), presented as “/”. All other drives, directories, and files appear under / as files and folders. You can list the files and folders available under a given directory by using the ls command and supplying / as the parameter:
The most relevant subdirectory of / is /home. This is where all of your users’ files are stored. Your home directory, the specific folder where your files are stored, is available as /home/<username> (alternatively, you can reference it using “~”. This is why the command prompt shows “~$”). You can change directories by using the cd program and supplying the new directory as a parameter. For practice, use cd to change your active directory to your home directory, then using ls to list the files:
The output will likely be blank, since you probably haven’t added any files to your home directory. For more information on the file system structure, see this link.
You now know how to run commands, traverse the file system, and gain administrative privileges (if only temporarily). The next step in our guide is setting up your computer for remote administration and networking.
Previous: Installing the Operating System