# Slackersbible/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Slackersbible

# About

The goal of the Slackware Handbook project is to create a document that closely resembles the FreeBSD Handbook in framework and content, but all about Slackware Linux. Envisioned by Narayan Newton and brought to life by Mad Penguin, the Slackware Handbook is unlike any other technical documentation in the world in that it is a completely 'live' medium. This is one book that will never age, never become obsolete, never collect dust... all because it is in perpetual development by dedicated technology professionals from around the globe.
Anyone will be allowed to contribute, but everything submitted to the book is moderated by a peer review system. If something is inaccurate or misleading, it will be caught and fixed. If something is out of date, it will be updated. In keeping with the true nature of Open Source, it will be completely open for anyone to read, download, and share. The Slackware Handbook will prove to be one of the most accurate technical documents on the planet.

# License
## Acknowledgment is given for using some contents from other works

This Handbook is based on the work of the FreeBSD Documentation Project Slackware Handbook is a project coordinated and hosted by Mad Penguin in an effort to keep Slackware documentation as up-to-date as possible.
Copyright © 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 The FreeBSD Documentation Project Copyright © 2005 Mad Penguin Communications
FreeBSD is a registered trademark of the FreeBSD Foundation.
Many people have worked on it. Therefore, here are their acknowledgments:
Several companies have supported the development of this document by paying authors to work on it full-time, paying for publication, etc. In particular, BSDi (subsequently acquired by Wind River Systems) paid members of the FreeBSD Documentation Project to work on improving this book full time leading up to the publication of the first printed edition in March 2000 ISBN 1-57176-241-8. Wind River Systems then paid several additional authors to make a number of improvements to the print-output infrastructure and to add additional chapters to the text. This work culminated in the publication of the second printed edition in November 2001 ISBN 1-57176-303-1. In 2003-2004, FreeBSD Mall, Inc, paid several contributors to improve the Handbook in preparation for the third printed edition.
The book you are holding represents the efforts of many hundreds of people around the world. Whether they sent in fixes for typos, reverted vandalism, or submitted complete chapters, all the contributions have been useful.

# Preface
## Intended Audience

The first section of the Handbook will guide the new user through the installation of Slackware Linux and gently introduces the concepts and conventions that underpin the OS. Working through this section requires little more than the desire to learn and the fortitude to attempt an installation.
The second, far larger, section of the Handbook is a comprehensive reference to all manner of topics of interest to Slackware Linux system administrators. Some of these chapters may recommend that you do some prior reading, and this is noted in the synopsis at the beginning of each chapter.

# Introduction

Slackware is the oldest Linux distribution still in active development. Dating back to 1993, it is still being maintained by its creator Patrick Volkerding with help from developers from all around the world.
It is a very sturdy yet simple distribution, whose main goals are simplicity and stability. Slackware also strives to be the most "UNIX-like" Linux distribution.
If you want a distribution that will force you to understand Linux and its Unix heritage, Slackware is for you. If, instead, you want the complexities of Linux hidden from you, look for a different distribution.
Don't however let this intimidate you, Slackware is no more difficult to learn or become proficient in than any other distribution. The main difference will be in the way you perform tasks, Slackware is far more dependent on the command line interface (cli) than it is on graphical tools. If you compare it to driving a car, you can think of Slackware as a manual/stick and distributions like Mandrake and Redhat as automatics.
To Quote the Slackware Web page:
What is Slackware Linux?
"The Official Release of Slackware Linux by Patrick Volkerding is an advanced Linux operating system, designed with the twin goals of ease of use and stability as top priorities. Including the latest popular software while retaining a sense of tradition, providing simplicity and ease of use alongside flexibility and power, Slackware brings the best of all worlds to the table.
"Originally developed by Linus Torvalds in 1991, the UNIX(tm)-like Linux operating system now benefits from the contributions of millions of users and developers around the world. Slackware Linux provides new and experienced users alike with a fully-featured system, equipped to serve in any capacity from desktop workstation to machine-room server. Web, ftp, and email servers are ready to go out of the box, as are a wide selection of popular desktop environments. A full range of development tools, editors, and current libraries is included for users who wish to develop or compile additional software."

# UNIX Basics
## Synopsis

The following chapter will cover the basic commands and functionality of the Slackware Linux operating system. Much of this material is relevant for any UNIX® like operating system. Feel free to skim over this chapter if you are familiar with the material. If you are new to Slackware, then you will definitely want to read through this chapter carefully.
After reading this chapter, you will know:
* How to use the "virtual consoles" of Slackware.
* How UNIX file permissions work.
* The default Slackware file system layout.
* The Slackware disk organization.
* How to mount and unmount file systems.
* What processes, daemons, and signals are.
* What a shell is, and how to change your default login environment.
* How to use basic text editors.
* What devices and device nodes are.
* What binary format is used under Slackware.
* How to read manual pages for more information.

## Virtual Consoles and Terminals

Slackware can be used in various ways. One of them is typing commands to a text terminal. A lot of the flexibility and power of a UNIX® operating system is readily available at your hands when using Slackware this way. This section describes what terminals and consoles are, and how you can use them.

### The Console

By default, Slackware is configured to boot into the command line interface, unless you've changed this, the system will present you with a login prompt after it boots, right after the startup scripts finish running. You will see something similar to:
The messages might be a bit different on your system, but you will see something similar. The last two lines are what we are interested in right now. The second last line reads:
This line contains some bits of information about the system you have just booted. You are looking at a Slackware console. The name of this machine (every UNIX machine has a name) is hawk, and you are now looking at its system console--the tty1 terminal. Finally, the last line is always:
This is the part where you are supposed to type in your username to log into Slackware. The next section describes how you can do this.

### Logging into Slackware

Slackware is a multiuser, multiprocessing system. This is the formal description that is usually given to a system that can be used by many different people, who simultaneously run a lot of programs on a single machine. Every multiuser system needs some way to distinguish one user from the rest. In Slackware (and all the UNIX like operating systems), this is accomplished by requiring that every user must log into the system before being able to run programs. Every user has a unique name (the username) and a personal, secret key (the password). Slackware will ask for these two before allowing a user to run any programs. Right after Slackware boots and finishes running its startup scripts, it will present you with a prompt and ask for a valid username:
For the sake of this example, let us assume that your username is john. Type john at this prompt and press Enter. You should then be presented with a prompt to enter a password:
Type in john's password now, and press Enter. The password is not echoed! You need not worry about this right now. Suffice it to say that it is done for security reasons. If you have typed your password correctly, you should by now be logged into Slackware and ready to try out all the available commands. You should see the MOTD or message of the day followed by a command prompt (a #, $, or % character). This indicates you have successfully logged into Slackware. 3.2.3 Multiple Consoles
Running UNIX commands in one console is fine, but Slackware can run many programs at once. Having one console where commands can be typed would be a bit of a waste when an operating system like Slackware can run dozens of programs at the same time. This is where virtual consoles can be very helpful. Slackware can be configured to present you with many different virtual consoles. You can switch from one of them to any other virtual console by pressing a couple of keys on your keyboard. Each console has its own different output channel, and Slackware takes care of properly redirecting keyboard input and monitor output as you switch from one virtual console to the next.
Special key combinations have been reserved by Slackware for switching consoles. You can use Ctrl+Alt-F1, Alt-F2, through Alt-F8 to switch to a different virtual console in Slackware. TTY1 (Ctrl+Alt+F1) is the default virtual console that you see at login. TTY1 through TTY6 are available at all times in text mode. TTY7 and higher become graphical virtual consoles when the graphical system is started.
As you are switching from one console to the next, Slackware takes care of saving and restoring the screen output. The result is an ``illusion of having multiple ``virtual screens and keyboards that you can use to type commands for Slackware to run. The programs that you launch on one virtual console do not stop running when that console is not visible. They continue running when you have switched to a different virtual console.

## Permissions

Slackware is based on several key UNIX concepts. The first and most pronounced is that Slackware is a multi-user operating system. The system can handle several users all working simultaneously on completely unrelated tasks. The system is responsible for properly sharing and managing requests for hardware devices, peripherals, memory, and CPU time fairly to each user.
Because the system is capable of supporting multiple users, everything the system manages has a set of permissions governing who can read, write, and execute the resource. These permissions are stored as three octets broken into three pieces, one for the owner of the file, one for the group that the file belongs to, and one for everyone else. This numerical representation works like this:
You can use the -l command line argument to ls(1) to view a long directory listing that includes a column with information about a file's permissions for the owner, group, and everyone else. For example, a ls -l in an arbitrary directory may show:
Here is how the first column of ls -l is broken up:
The first (leftmost) character tells if this file is a regular file, a directory, a special character device, a socket, or any other special pseudo-file device. In this case, the - indicates a regular file. The next three characters, rw- in this example, give the permissions for the owner of the file. The next three characters, r--, give the permissions for the group that the file belongs to. The final three characters, r--, give the permissions for the rest of the world. A dash means that the permission is turned off. In the case of this file, the permissions are set so the owner can read and write to the file, the group can read the file, and the rest of the world can only read the file. According to the table above, the permissions for this file would be 644, where each digit represents the three parts of the file's permission.
This is all well and good, but how does the system control permissions on devices? Slackware actually treats most hardware devices as a file that programs can open, read, and write data to just like any other file. These special device files are stored on the /dev directory.
Directories are also treated as files. They have read, write, and execute permissions. The executable bit for a directory has a slightly different meaning than that of files. When a directory is marked executable, it means it can be traversed into, that is, it is possible to "cd" (change directory) into it. This also means that within the directory it is possible to access files whose names are known (subject, of course, to the permissions on the files themselves).
In particular, in order to perform a directory listing, read permission must be set on the directory, whilst to delete a file that one knows the name of, it is necessary to have write and execute permissions to the directory containing the file.
There are more permission bits, but they are primarily used in special circumstances such as setuid binaries and sticky directories. If you want more information on file permissions and how to set them, be sure to look at the chmod manual page. 3.3.1 Symbolic Permissions
Contributed by Tom Rhodes.
Symbolic permissions, sometimes referred to as symbolic expressions, use characters in place of octal values to assign permissions to files or directories. Symbolic expressions use the syntax of (who) (action) (permissions), where the following values are available:
These values are used with the chmod command just like before, but with letters. For an example, you could use the following command to block other users from accessing FILE:
% chmod go= FILE
A comma separated list can be provided when more than one set of changes to a file must be made. For example the following command will remove the groups and world write permission on FILE, then it adds the execute permissions for everyone:
% chmod go-w,a+x FILE

## Processes

Slackware is a multi-tasking operating system. This means that it seems as though more than one program is running at once. Each program running at any one time is called a process. Every command you run will start at least one new process, and there are a number of system processes that run all the time, keeping the system functional.
Each process is uniquely identified by a number called a process ID, or PID, and, like files, each process also has one owner and group. The owner and group information is used to determine what files and devices the process can open, using the file permissions discussed earlier. Most processes also have a parent process. The parent process is the process that started them. For example, if you are typing commands to the shell then the shell is a process, and any commands you run are also processes. Each process you run in this way will have your shell as its parent process. The exception to this is a special process called init(8). init is always the first process, so its PID is always 1. init is started automatically by the kernel when Slackware starts.
Foreground and Background
When you run a command, usually that command is in the foreground (you see it) and it's using the computer until it is finished. This might seem obvious until you realize that there are things that can be done about this. For example, if you start a command and then decide that you would like to terminate it, you can usually use Ctrl+C to terminate it. Also, if you'd like to start other commands rather than wait for the program to quit, you may use Ctrl+Z to stop it, so that it will no longer run and be "in your way".
A stopped application can be brought to the foreground once again using the "fg" command, where it will resume running. This is useful if you want to let the command continue, or if you'd like to use Ctrl+C to terminate it.
Another thing that can be done is to use an ampersand (&) after a command to cause it to run in the background. When you do this, you might see the following:
root@darkstar:~# updatedb & [1] 12353
This means that the program has been started, and has been given the PID (program identification number) of 12353, which is useful should you want to terminate it with "kill 12353".
Two commands are particularly useful to see the processes on the system, ps(1) and top(1). The ps command is used to show a static list of the currently running processes, and can show their PID, how much memory they are using, the command line they were started with, and so on. The top command displays all the running processes, and updates the display every few seconds, so that you can interactively see what your computer is doing.
By default, ps only shows you the commands that are running and are owned by you. For example:
As you can see in this example, the output from ps(1) is organized into a number of columns. PID is the process ID discussed earlier. PIDs are assigned starting from 1, go up to 99999, and wrap around back to the beginning when you run out. The TT column shows the tty the program is running on, and can safely be ignored for the moment. STAT shows the program's state, and again, can be safely ignored. TIME is the amount of time the program has been running on the CPU--this is usually not the elapsed time since you started the program, as most programs spend a lot of time waiting for things to happen before they need to spend time on the CPU. Finally, COMMAND is the command line that was used to run the program.
ps(1) supports a number of different options to change the information that is displayed. One of the most useful sets is auxww. a displays information about all the running processes, not just your own. u displays the username of the process' owner, as well as memory usage. x displays information about daemon processes, and ww causes ps(1) to display the full command line, rather than truncating it once it gets too long to fit on the screen. The output from top(1) is similar. A sample session looks like this:
The output is split into two sections. The header (the first five lines) shows the PID of the last process to run, the system load averages (which are a measure of how busy the system is), the system uptime (time since the last reboot) and the current time. The other figures in the header relate to how many processes are running (47 in this case), how much memory and swap space has been taken up, and how much time the system is spending in different CPU states.
Below that are a series of columns containing similar information to the output from ps(1). As before you can see the PID, the username, the amount of CPU time taken, and the command that was run. top(1) also defaults to showing you the amount of memory space taken by the process. This is split into two columns, one for total size, and one for resident size--total size is how much memory the application has needed, and the resident size is how much it is actually using at the moment.
top(1) automatically updates this display every two seconds; this can be changed with the s option.

## Text Editors

Much of UNIX administration involved editing configuration files, most of which are simply text files. Here we will address several of the most common UNIX text editors and their basic operations.

### vi

There is arguably no text editor more ubiquitous in the UNIX world than vi. This fact alone serves as a reason that all serious UNIX (and Slackware) users should learn at least its basic features. The name comes from the command "visual" used to switch the ex line editor into visual mode. This fact serves to illustrate two interesting things about vi. First, that vi is a modal editor, which means that its editing functions change depending on the state, or mode, that the program is in. The second interesting thing to note is that the name is, like much of UNIX programs, and extension of another. vi has all the user customization and extensibility UNIX users demand, which makes it an extremely powerful program.

#### Modal Editing

By contrast to some text editors that simply echo keystrokes to the screen and rely on function key combinations for extended features, modal editors--and by extension, vi--use the editor mode to define what actions are perform on the text file. This is best explained by example.
What you see is a modern version of vi called Vim. Vim inherits nearly all of the features of the original, proprietary version of vi, and adds a multitude of its own features which are distributed under a GPL-compatible free software license. The screen above is what Vim looks like when it first loads. In this state, it is in Normal mode. Normal mode is also referred to as Command mode, because from this mode you can execute various commands, or actions, on the text, such as changing, deleting, copying, etcetera. To enter text in standard fashion, you must first switch vi to Insert mode.
From this initial mode we can enter text by switching to Insert mode in one of several ways. The easiest is just to press the "i" key (for insert). Now you can enter text as you wish. All standard alphanumeric characters, including punctuation, are echoed to the display as typed:

##### Figure 5.1.1-1

You can see from this example that Vim displays the text as typed, "vi is my favorite text editor.", as well as the fact that it is now in Insert mode. To switch back to Command mode, simply press the escape key (Esc). vi will return to Command mode (and Vim will change its display to reflect this by removing "-- INSERT --" from the bottom of the screen.

##### Important: Commands Are Case Sensitive

    Be careful. vi commands (such as "i" here) are case sensitive, so a capital "I" is not the same command as a lower case "i". By the same token it is highly recommended not to use CAPSLOCK on your keyboard while editing in vi. Despite being largely superfluous to most typists anyway, using CAPSLOCK can lead to unexpected results when you switch back to Command mode.

#### Basic Commands

"So what good is Command mode?" you ask. Good question. Let's take a look at some basic commands that illustrate the power of modal editing.

##### Moving the Cursor

Command mode may seem to add complication to the text editing process, but it is actually designed to increase productivity. One of the first fruits you will glean from Command mode is increased speed editing text. Command mode makes text editing faster than standard text editing even if you only know a handful of commands. Take the previous example (see Figure 5.1.1-1). If you were to press "Esc" at the end of the line, vi would enter Command mode and the cursor would be placed atop the last character typed. From this state, you can use the "h", "j", "k", and "l" keys to move the cursor left, down, up, and right, respectively, throughout the file one character at a time.

##### Yanking, Putting and Deleting Text

vi uses registers to store text temporarily. Using the yank and put commands, you can copy or remove text from a portion of the file into the register and put it somewhere else.

##### File Operations

So now that you can do a few commands, you probably want to open a file do some editing.

### Emacs

Emacs is another popular UNIX text editor and, like vi, is extremely powerful. Emacs was originally conceived by Richard Stallman, the founder of the GNU project, as a set of editor macros for another text editor. This eventually became what is known today as Emacs (derived from Editor MACroS).

## Further reading

* Learning the vi Editor