Chapter 1. Getting Started with Linux

Linux system administration means different things to different people. Administration, for this book, means the daily actions that a Linux system administrator must take to manage and support users, maintain system health, implement best practices for security, install software, and perform housekeeping tasks. This chapter covers Linux installation, initial setup, and system exploration using simple shell commands.

You’ll spend a significant portion of your time at the command line, also known as the command line interface (CLI). Linux system administrators rarely install or use graphic user interfaces (GUIs) on their supported server systems. This chapter introduces you to the CLI and some simple commands to navigate the filesystem, to locate important files, and to familiarize yourself with the Linux CLI.

Installing Linux

One of the first things every Linux system administrator (sysadmin) learns is how to install Linux. There’s no single correct way to install Linux but there are a few guidelines and suggestions that will make your life easier in the future as your user’s needs change.

While this section won’t go into step-by-step detailed instructions on how to install Linux, the basic steps are outlined here. For the majority of junior-level sysadmins, system installation generally takes place via automated means such as Kickstart or other enterprise-level delivery system.

Preparing your system for Linux

If this is your first time to install Linux, I suggest that you install it into a virtual machine (VM) so that you don’t have to dedicate an entire piece of hardware for a learning system and so that you don’t potentially render your system inoperable by attempting to install Linux in parallel to your current system creating a multi-boot computer. (Setting up multi-booting is a more advanced concept and out of the scope of this book.)

A good place to start with virtualization, if you don’t already have it installed, is to download and install the latest version of VirtualBox ( VirtualBox is an application that allows your current computer to act as a virtual machine host system where you may install virtual guests, such as Linux into what amounts to a separate functioning computer system. Virtualbox runs on many different host operating systems (OSs) and supports a variety of guest operating systems including Linux. The host OS and guest OS can be different from one another. Your computer (host OS) can be a Windows, Mac, or Linux-based system but have guest Linux systems installed on it as VirtualBox VMs.

Downloading and installing Linux

Next, you’ll need to select a Linux distribution (distro) to install so that you can practice issuing commands, changing configurations, rebooting, installing software, creating users, and so on. I suggest that you should select a Linux distro based on the one that your current employer uses. If your company doesn’t use Linux yet or you’re not employed in a system administrator role, then select from one of the popular distributions described below:


Debian is a top-level distribution from which many other distributions are derived. Debian is community-supported, open source, and free.


OpenSUSE is a community-supported, top-level distribution that has many faithful followers worldwide. Its commercial version SUSE Linux Enterprise has widespread adoption.

Red Hat Enterprise Linux

Red Hat is a commercially-supported Linux that enjoys worldwide enterprise adoption and is now owned by IBM.


Ubuntu is a very popular, Debian-derived community and commercially-supported distribution. Ubuntu also offers ready-made VirtualBox (and other) virtual machines to help you get a quick start.

The downloaded ISO file is a bootable Linux image. You don’t have to do anything to it if you use it to create a virtual machine. A virtual machine will boot from the ISO image and begin the installation process. After you’ve configured your virtual machine in VirtualBox, select Settings from the Oracle VM VirtualBox Manager, as shown in Figure 1-1.

Figure 1-1. The Oracle VirtualBox Manager application and a configured virtual machine.

Then, select Storage, as shown in Figure 1-2.

Figure 1-2. Virtual machine settings with Storage settings selected.

Select the empty optical disk drive under the IDE Controller in the Storage Devices pane and then select the optical disk icon in the Attributes pane to browse for your ISO image file. See Figure 1-3.

Figure 1-3. Select the ISO image from the list.

Once you’ve selected your ISO image, click OK to proceed. Now, when you start your VM, it will boot from this ISO image to begin installation onto your VM’s virtual disk.

When your system boots, you can accept the default settings. If you have some experience installing Linux, then you can change the default settings to suit your needs. Create yourself a user account when prompted to do so. If your distribution prompts you to give the root account a password, do so. You must remember this password because without it you’ll have to reinstall your Linux VM or try to recover it. Installing Linux can take several minutes and a reboot is required at the end of the installation process.

Getting to know your new Linux system

After installation, the first you need to do is to login using the username and password that you created during installation. Upon login, you’re placed into your home directory inside a shell or operating environment. Your home directory is a subdirectory of the /home directory. The Linux filesystem is a hierarchical filesystem, similar to Microsoft Windows. At the very top level, there is the root directory, which is represented by the / symbol. Windows uses a drive letter, such a C: for the root directory. On Windows, you can have many drive letters that all have their own root levels, such as C:, D:, E:, and so on. In Linux, there is only one root directory, /. All other directories are subdirectories of the root directory. Figure 1-4 is an illustration of the Linux root directory and its subdirectories.

Figure 1-4. The Linux Hierarchical Filesystem showing the root directory (/) and all of its subdirectories.

Note that there are only directories under the / (root) filesystem and no individual files. All files are kept in directories. You’ll explore many of these subdirectories throughout the rest of the book. The following table gives you a brief overview of the files and information contained in each directory.

Directory Description
/ The root filesystem only contains other directories but no individual files.
/bin The binaries directory contains executable files. Points to /usr/bin.
/dev The device directory contains device files to address peripherals.
/etc Contains system configuration files for users and services.
/home User’s home directories.
/lib System libraries files. Points to /usr/lib.
/media Directory for mounting media such as USB drives or DVD disks.
/mnt The mount directory for mounting remote filesystems.
/opt Directory in which third-party software is installed.
/proc A virtual filesystem that tracks system processes.
/root The root user’s home directory.
/run Variable and volatile run-time data.
/sbin System binary (executable) files.
/srv Might contain data from system services.
/sys Contains kernel information.
/tmp Temporary file directory for session information and temporary file storage.
/usr Programs and libraries for users and user-related programs.
/var Variable files such as logs, spools, and queues.

System files are protected from user modification. Only the root (administrative) user can modify system configuration files and settings. Users generally only have write access to their own home directories, the /tmp directory, and shared directories specifically created and modified by the administrator.

In the next section, you learn how to interact with your new Linux system at the command line.

Learning the command line interface

The command line interface or CLI is how most system administrators interact with their Linux systems because server systems don’t typically have a graphic interface. In Microsoft Windows terminology, a CLI only system, such as a Linux server, would be equivalent to a Windows Server Core system where you only have access to command line utilities.

As the name suggests, you interact with the Linux system using commands that you enter with a keyboard or standard input (stdin). The source from standard input can also be file redirection, programs, and other sources, but in the context for this book, stdin refers to keyboard input unless otherwise noted. Many commands are informational and display data about the system or system activities to the screen or standard output (stdout). Sometimes you’ll receive an error from the system that’s also known as standard error or stderr. You’ll see the shorthand and the long versions of these references used interchangeably throughout this text and in other Linux-related documentation that you’ll find elsewhere.

You must learn a few commands to successfully interact with the filesystem. And by learn, I mean know them without looking them up online. There’s only a handful of commands like this and there are few options that you should also commit to memory so that your interaction with the system becomes natural and efficient. And don’t worry about harming the system with any command that I cover. I’ll warn you when a command should be used with care or caution.

There are a few things you need to know before jumping into issuing commands. The first is that Linux doesn’t use file extensions. This means that the file, filename.exe has no more meaning to Linux than does the file, Financial_Report.txt or Resume.doc. They are all files and might or might or not be executable or text files. In Linux, you can name a file anything you want to.

The second thing to know about Linux is that filenames are case-sensitive. In other words, the two files, filename.txt and filename.TXT are two different files. I will prove this later in the chapter. For now, take my word for it. The third thing to know is that a file’s permission determines whether you can execute the file, edit the file, or even look at the file’s contents. Fourth, all Linux locations are stated from the / (root) directory. For example, if you mention the password file in Linux, it’s always shown as /etc/passwd. This is known as the absolute path and is the standard convention for speaking of or referring to files on the system.

Fifth, Linux assumes you know what you want to do and that you’ve spelled everything correctly when you issue a command, so be careful because some actions are irreversible.

Finally, Linux, like Unix, or more generally *nix systems are not “chatty” like the Windows® operating systems are. Linux systems, for example, don’t prompt you with an “Are you sure?” message when you remove (delete) files. The Linux system assumes that you want to execute the command that you issued and that you correctly spelled all parts of the command. Spelling counts at the Linux command line.

Commands for filesystem navigation

Navigating the Linux filesystem means exploring the various system directories, learning to return to your home directory, and listing directory contents in different ways. If you’re a Windows user and you’ve worked at the command prompt (CMD window) on that platform, then the Linux command line will be familiar to you.

The following short list of commands will acquaint you with the Linux filesystem, files, and the contents of your home directory.


The pwd or print working directory command displays where you are on the filesystem. If you issue the pwd command now, followed by the ENTER key, the command responds with /home/<your login name>. Always assume that you press the ENTER key after each command so that you can receive a response.

$ pwd

The $ is your shell prompt that shows you’re logged into the system as a user. You’ll use this command more later in the chapter.


The cd, change directory, or current directory command places you into a new directory, returns you to your home directory, moves you to a higher level, or to a subdirectory. The cd command is analogous to the Windows cd command.

$ cd /etc
$ pwd

Simply entering cd returns you to your home directory regardless of where you are on the filesystem. From the example above.

$ pwd
$ cd
$ pwd

When you cd to a directory, use its absolute path.

$ cd /usr/bin

You can cd to a subdirectory without the absolute path if you’re currently in the parent directory.

$ cd
$ pwd
$ cd /usr
$ cd bin
$ pwd

The cd command is one that you’ll use every day that you connect to a Linux system.


The ls or list command displays a list of files and directories of the location you specify. If you don’t specify a location, ls displays the list of files and directories in your current directory.

$ cd
$ pwd
$ /home/student1
$ ls

You have no visible files on the system yet because you haven’t created any and none exist by default. However, you can list files from other directories by specifying the absolute path to the directory list you wish to see.

$ ls /usr/bin
a2x               getcifsacl                   p11-kit                   snmpping            getconf                      pack200                   snmpps
ac                getent                       package-cleanup           snmpset

There are too many files to list here in the /usr/bin directory, so I’ve truncated it to these few.

There are actually files in your home directory but they’re hidden because of the way they’re named. Files that begin with a period (.) are hidden from a regular ls command. To see these files, you must use a command option to allow you to see all files.

$ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .gnupg  .zshrc

Your listing might vary slightly from this one but understand that all directories and files whose names begin with a (.) are hidden from standard file lists. You can cd into hidden directories or list files within them.

$ ls .gnupg
private-keys-v1.d  pubring.kbx

The ls command is one you’ll certainly use every time you login to your Linux system and is certainly one that you want to commit to memory. I will use the ls command throughout this book and introduce you to many more options for it along the way. Now that you’ve learned the basics of filesystem navigation, it’s time to cover rebooting and shutting down your system.

Starting, rebooting, and shutting down a Linux system

The most basic tasks facing any Linux sysadmin is that of starting, restarting, and shutting down a system. If you have experience with computers, you know that powering off a system without issuing a shutdown command is bad. It’s bad because doing so can, for example, corrupt open files, it can leave open files open, it disrupts running services, and it can cause problems with database transaction logs--possibly resulting in data loss.

Proper knowledge of how to start, restart, and shutdown a system is of great value to sysadmins.

Starting a system

For physical systems, you press the power button and release to start a system. This begins the power-on self tests (POST) and boot process. Watching the console during boot is important because the system notifies you and logs any issues on the way up. Your goal is to watch the screen for any errors or anomalies along the way. The worst message of all is a “kernel panic” which will be covered later in the book. Hopefully all is well with your system and the process ends with a login prompt.

The startup process is quite short but can identify systemic problems such as memory, disk, filesystem, and network issues. I’ll cover troubleshooting in a later chapter, but be aware now that you should watch the boot process carefully noting any problems for later investigation.

Restarting a system

Restarting or rebooting a system is a standard sysadmin practice. Although you might read or hear the contrary, there’s nothing wrong with rebooting your system. In fact, it’s recommended that you do so on a regular basis for all of the reasons stated under the previous section. Restarting a system clears memory, refreshes connections, and ensures that the system is healthy. A good reboot can cure certain nagging problems, such as an application that drains your system’s memory, but only temporarily.

Any issues that are resolved with a reboot should be investigated more thoroughly after the system is up and stable. Restarting a system gives you an opportunity to do some troubleshooting before application problems, logging problems, or network problems place the system back into a state when it requires another reboot.

Shutting down a system

Shutting down means issuing a command that gently and appropriately closes all programs and eventually powers off the system. This gentle shutdown also has the effect of warning users that the system is going down, so that everyone can save their work and logoff.

System shutdown should be reserved for hardware maintenance, relocation, or decommissioning. Some enterprise policies require that systems go through a full shutdown once a year to identify any hardware issues that might not manifest themselves except through a complete system failure. Technicians and sysadmins usually take this opportunity to perform hardware maintenance or hardware checks at the same time.


This first chapter gets you up and running with a live Linux system, covers some Linux basics, explores a few essential commands, and instructs you on the how and why of system startup, rebooting, and shutdown. In Chapter 2, you learn more about using the command line interface using commands to create, remove, and modify files. You also learn about Linux permissions, how to set them, how to interpret them, and how to set a global default permission for users.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.