Slackware Linux Essentials: Tutorial 11

Chapter 11 Process Control
Table of Contents
11.1 Backgrounding
11.2 Foregrounding
11.3 ps
11.4 kill
11.5 top

Every program that is running is called a process. These processes range from things like the X Window System to system programs (daemons) that are started when the computer boots. Every process runs as a particular user. Processes that are started at boot time usually run as root or nobody. Processes that you start will run as you. Processes started as other users will run as those users.

You have control over all the processes that you start. Additionally, root has control over all processes on the system, including those started by other users. Processes can be controlled and monitored through several programs, as well as some shell commands.

11.1 Backgrounding
Programs started from the command line start up in the foreground. This allows you to see all the output of the program and interact with it. However, there are several occasions when you'd like the program to run without taking up your terminal. This is called running the program in the background, and there are a few ways to do it.

The first way to background a process is by adding an ampersand to the command line when you start the program. For example, assume you wanted to use the command line mp3 player amp to play a directory full of mp3s, but you needed to do something else on the same terminal. The following command line would start up amp in the background:

% amp *.mp3 &


The program will run as normal, and you are returned to a prompt.

The other way to background a process is to do so while it is running. First, start up a program. While it is running, hit Control+z. This suspends the process. A suspended process is basically paused. It momentarily stops running, but can be started up again at any time. Once you have suspended a process, you are returned to a prompt. You can background the process by typing:

% bg


Now the suspended process is running in the background.

http://www.slackbook.org/html/process-control.html

Slackware Linux Essentials: Tutorial 10

Chapter 10 Handling Files and Directories
Table of Contents
10.1 Navigation : ls, cd, and pwd
10.2 Pagers: more, less, and most
10.3 Simple Output: cat and echo
10.4 Creation: touch and mkdir
10.5 Copy and Move
10.6 Deletion: rm and rmdir
10.7 Aliasing files with ln
Linux aims to the most Unix-like it can be. Traditionally, Unix operating systems have been command-line oriented. We do have a graphical user interface in Slackware, but the command-line is still the main level of control for the system. Therefore, it is important to understand some of the basic file management commands.

The following sections explain the common file management commands and provide examples of how they are used. There are many other commands, but these will help you get started. Also, the commands are only briefly discussed here. You will find more detail in the accompanying man pages for each command.

10.1 Navigation : ls, cd, and pwd
10.1.1 ls
This command lists files in a directory. Windows and DOS users will notice its similarity to the dir command. By itself, ls(1) will list the files in the current directory. To see what's in your root directory, you could issue these commands:

% cd /
% ls
bin cdr dev home lost+found proc sbin tmp var
boot cdrom etc lib mnt root suncd usr vmlinuz


The problem a lot of people have with that output is that you cannot easily tell what is a directory and what is a file. Some users prefer that ls add a type identifier to each listing, like this:

% ls -FC
bin/ cdr/ dev/ home/ lost+found/ proc/ sbin/ tmp/ var/
boot/ cdrom/ etc/ lib/ mnt/ root/ suncd/ usr/ vmlinuz


Directories get a slash at the end of the name, executable files get an asterisk at the end of the name, and so on.

ls can also be used to get other statistics on files. For example, to see the creation dates, owners, and permissions, you would look at a long listing:

% ls -l
drwxr-xr-x 2 root bin 4096 May 7 09:11 bin/
drwxr-xr-x 2 root root 4096 Feb 24 03:55 boot/
drwxr-xr-x 2 root root 4096 Feb 18 01:10 cdr/
drwxr-xr-x 14 root root 6144 Oct 23 18:37 cdrom/
drwxr-xr-x 4 root root 28672 Mar 5 18:01 dev/
drwxr-xr-x 10 root root 4096 Mar 8 03:32 etc/
drwxr-xr-x 8 root root 4096 Mar 8 03:31 home/
drwxr-xr-x 3 root root 4096 Jan 23 21:29 lib/
drwxr-xr-x 2 root root 16384 Nov 1 08:53 lost+found/
drwxr-xr-x 2 root root 4096 Oct 6 12:47 mnt/
dr-xr-xr-x 62 root root 0 Mar 4 15:32 proc/
drwxr-x--x 12 root root 4096 Feb 26 02:06 root/
drwxr-xr-x 2 root bin 4096 Feb 17 02:02 sbin/
drwxr-xr-x 5 root root 2048 Oct 25 10:51 suncd/
drwxrwxrwt 4 root root 487424 Mar 7 20:42 tmp/
drwxr-xr-x 21 root root 4096 Aug 24 03:04 usr/
drwxr-xr-x 18 root root 4096 Mar 8 03:32 var/


Suppose you want to get a listing of the hidden files in the current directory. This command will do just that:

% ls -a
. bin cdrom home mnt sbin usr
.. boot dev lib proc suncd var
.pwrchute_tmp cdr etc lost+found root tmp vmlinuz


Files beginning with a period (called dot files) are hidden when you run ls. You will only see them if you pass the -a option.

There are many more options that can be found in the online manual page. Don't forget that you can combine options that you pass to ls.

10.1.2 cd
The cd command is used to change working directories. You simply type cd followed by the path name to change to. Here are some examples:

darkstar:~$ cd /bin
darkstar:/bin$ cd usr
bash: cd: usr: No such file or directory
darkstar:/bin$ cd /usr
darkstar:/usr$ ls
bin
darkstar:/usr$ cd bin
darkstar:/usr/bin$


Notice that without the preceding slash, it tries to change to a directory in the current directory. Also executing cd with no options will move you to your home directory.

The cd command is not like the other commands. It is a builtin shell command. Shell builtins are discussed in Section 8.3.1. This may not make any sense to you right now. Basically it means there is no man page for this command. Instead, you have to use the shell help. Like this:

% help cd


It will display the options for cd and how to use them.

10.1.3 pwd
The pwd command is used to show your current location. To use the pwd command just type pwd. For example:

% cd /bin
% pwd
/bin
% cd /usr
% cd bin
% pwd
/usr/bin



http://www.slackbook.org/html/file-commands.html

Slackware Linux Essentials: Tutorial 09

Chapter 9 Filesystem Structure
Table of Contents
9.1 Ownership
9.2 Permissions
9.3 Links
9.4 Mounting Devices
9.5 NFS Mounts

We have already discussed the directory structure in Slackware Linux. By this point, you should be able to find files and directories that you need. But there is more to the filesystem than just the directory structure.

Linux is a multiuser operating system. Every aspect of the system is multiuser, even the filesystem. The system stores information like who owns a file and who can read it. There are other unique parts about the filesystems, such as links and NFS mounts. This section explains these, as well as the multiuser aspects of the filesystem.

9.1 Ownership
The filesystem stores ownership information for each file and directory on the system. This includes what user and group own a particular file. The easiest way to see this information is with the ls command:

% ls -l /usr/bin/wc
-rwxr-xr-x 1 root bin 7368 Jul 30 1999 /usr/bin/wc


We are interested in the third and fourth columns. These contain the username and group name that owns this file. We see that the user “root” and the group “bin” own this file.

We can easily change the file owners with the chown(1) (which means “change owner”) and chgrp(1) (which means “change group”) commands. To change the file owner to daemon, we would use chown:

# chown daemon /usr/bin/wc


To change the group owner to “root”, we would use chgrp:

# chgrp root /usr/bin/wc


We can also use chown to specify the user and group owners for a file:

# chown daemon:root /usr/bin/wc


In the above example, the user could have used a period instead of a colon. The result would have been the same; however, the colon is considered better form. Use of the period is deprecated and may be removed from future versions of chown to allow usernames with periods in them. These usernames tend to be very popular with Windows Exchange Servers and are encountered most commonly in email addresses such as: mr.jones@example.com. In slackware, administrators are advised to stay away from such usernames because some scripts still use the period to indicate the user and group of a file or directory. In our example, chmod would interpret mr.jones as user “mr” and group “jones”.

File ownership is a very important part of using a Linux system, even if you are the only user. You sometimes need to fix ownerships on files and device nodes.

http://www.slackbook.org/html/filesystem-structure.html

Slackware Linux Essentials: Tutorial 08

Chapter 8 The Shell
Table of Contents
8.1 Users
8.2 The Command Line
8.3 The Bourne Again Shell (bash)
8.4 Virtual Terminals


In a graphical environment, the interface is provided by a program that creates windows, scrollbars, menus, etc. In a commandline environment, the user interface is provided by a shell, which interprets commands and generally makes things useable. Immediately after logging in (which is covered in this chapter), users are put into a shell and allowed to go about their business. This chapter serves as an introduction to the shell, and to the most common shell among Linux users-- the Bourne Again Shell (bash). For more detailed information on anything in this chapter, check out the bash(1) man page.

8.1 Users
8.1.1 Logging In
So you've booted, and you're looking at something that looks like this:

Welcome to Linux 2.4.18
Last login: Wed Jan 1 15:59:14 -0500 2005 on tty6.
darkstar login:


Hmm.. nobody said anything about a login. And what's a darkstar? Don't worry; you probably didn't accidentally fire up a hyperspace comm-link to the Empire's artificial moon. (I'm afraid the hyperspace comm-link protocol isn't currently supported by the Linux kernel. Maybe the 2.8 kernel branch will at last provide this oft looked-for support.) No, darkstar is just the name of one of our computers, and its name gets stamped on as the default. If you specified a name for your computer during setup, you should see it instead of darkstar.

As for the login... If this is your first time, you'll want to log in as root. You'll be prompted for a password; if you set one during the setup process, that's what it's looking for. If not, just hit enter. That's it-- you're in!

8.1.2 Root: The Superuser
Okay, who or what is root? And what's it doing with an account on your system?

Well, in the world of Unix and similar operating systems (like Linux), there are users and then there are users. We'll go into this in more detail later, but the important thing to know now is that root is the user above all users; root is all-powerful and all-knowing, and nobody disobeys root. It just isn't allowed. root is what we call a “superuser”, and rightly so. And best of all, root is you.

Cool, huh?

If you're not sure: yes, that's very cool. The catch is, though, that root is inherently allowed to break anything it so desires. You might want to skip ahead to Section 12.1.1 and see about adding a user; then login as that user and work from there. The traditional wisdom is that it's best to only become the superuser when absolutely necessary, so as to minimize the possibility of accidentally breaking something.

By the way, if you decide you want to be root while you're logged in as someone else, no problem. Just use the su(1) command. You'll be asked for root's password and then it will make you root until you exit or logout. You can also become any other user using su, provided you know that user's password: su logan, for instance, would make you me.

root is allowed to su to any user, without requiring their password.


http://www.slackbook.org/html/shell.html

Slackware Linux Essentials: Tutorial 07

Chapter 7 Booting
Table of Contents
7.1 LILO
7.2 LOADLIN
7.3 Dual Booting

The process of booting your Linux system can sometimes be easy and sometimes be difficult. Many users install Slackware on their computer and that's it. They just turn it on and it's ready to use. Othertimes, simply booting the machine can be a chore. For most users, LILO works best. Slackware includes LILO and Loadlin for booting Slackware Linux. LILO will work from a hard drive partition, a hard drive's master boot record, or a floppy disk, making it a very versatile tool. Loadlin works from a DOS command line, killing DOS and invoking Linux.

Another popular utility for booting Linux is GRUB. GRUB is not included or officially supported by Slackware. Slackware holds to the “tried and true” standard for what gets included inside the distribution. While GRUB works well and includes some features that LILO does not, LILO handles all the essential tasks of a boot loader reliably with a proven track record. Being younger, GRUB hasn't quite lived up to that legacy yet. As it is not included with Slackware, we do not discuss it here. If you wish to use GRUB (perhaps it came with another Linux OS and you want to use it to dual-boot) consult GRUB's documentation.

This section covers using LILO and Loadlin, the two booters included with Slackware. It also explains some typical dual booting scenarios and how you could go about setting it up.

7.1 LILO
The Linux Loader, or LILO, is the most popular booter in use on Linux systems. It is quite configurable and can easily be used to boot other operating systems.

Slackware Linux comes with a menu-driven configuration utility called liloconfig. This program is first run during the setup process, but you can invoke it later by typing liloconfig at the prompt.

LILO reads its settings from the /etc/lilo.conf(5) file. It is not read each time you boot up, but instead is read each time you install LILO. LILO must be reinstalled to the boot sector each time you make a configuration change. Many LILO errors come from making changes to the lilo.conf file, but failing to re-run lilo to install these changes. liloconfig will help you build the configuration file so that you can install LILO for your system. If you prefer to edit /etc/lilo.conf by hand, then reinstalling LILO just involves typing /sbin/lilo (as root) at the prompt.

When you first invoke liloconfig, it will look like this:

Figure 7-1. liloconfig



If this is your first time setting up LILO, you should pick simple. Otherwise, you might find expert to be faster if you are familiar with LILO and Linux. Selecting simple will begin the LILO configuration.

If kernel frame buffer support is compiled into your kernel, liloconfig will ask which video resolution you would like to use. This is the resolution that is also used by the XFree86 frame buffer server. If you do not want the console to run in a special video mode, selecting normal will keep the standard 80x25 text mode in use.

The next part of the LILO configuration is selecting where you want it installed. This is probably the most important step. The list below explains the installation places:

Root
This option installs LILO to the beginning of your Linux root partition. This is the safest option if you have other operating systems on your computer. It ensures that any other booters are not overwritten. The disadvantage is that LILO will only load from here if your Linux drive is the first drive on your system. This is why many people chose to create a very small /boot partition as the first drive on their system. This allows the kernel and LILO to be installed at the beginning of the drive where LILO can find them. Previous versions of LILO contained an infamous flaw known as the “1024 cylinder limit”. LILO was unable to boot kernels on partitions past the 1024th cylinder. Recent editions of LILO have eliminated this problem.

Floppy
This method is even safer than the previous one. It creates a boot floppy that you can use to boot your Linux system. This keeps the booter off the hard disk entirely, so you only boot this floppy when you want to use Slackware. The flaws with this method are obvious. Floppies are notoriously fickle, prone to failures. Secondly, the boot loader is no longer self-contained within the computer. If you loose your floppy disk, you'll have to make another to boot your system.

MBR
You will want to use this method if Slackware is the only operating system on your computer, or if you will be using LILO to choose between multiple operating systems on your computer. This is the most preferred method for installing LILO and will work with almost any computer system.

This option will overwrite any other booter you have in the MBR.


After selecting the installation location, liloconfig will write the configuration file and install LILO. That's it. If you select the expert mode you will receive a special menu. This menu allows you to tweak the /etc/lilo.conf file, add other operating systems to your boot menu, and set LILO to pass special kernel parameters at boot time. The expert menu looks like this:

Figure 7-2. liloconfig Expert Menu



Whatever your system configuration is, setting up a working boot loader is easy. liloconfig makes setting it up a cinch.

http://www.slackbook.org/html/booting.html