Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Introduction to linux
Description: this note based on those who takes computer science,because linux is open source window which run on PC and on various server which used on various organization.

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Introduction to Linux

A Hands on Guide
Machtelt Garrels
Garrels
...
27 Edition
Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008 Machtelt Garrels
20080606

Introduction to Linux

Table of Contents
Introduction
...
Why this guide?
...
Who should read this book?

...
New versions and availability
...
Revision History
...
Contributions
...
Feedback
...
Copyright information
...
What do you need?

...
Conventions used in this document
...
Organization of this document
...
What is Linux?
...
1
...
7
1
...
1
...
7
1
...
2
...
8
1
...
3
...
9
1
...
The user interface

...
2
...
Is Linux difficult?
...
2
...
Linux for non-experienced users
...
3
...
10
1
...
1
...
10
1
...
2
...
11
1
...
Properties of Linux
...
4
...
Linux Pros
...
4
...
Linux Cons
...
5
...
14
1
...
1
...
14
1
...
2
...
15
1
...
3
...
15
1
...
Summary
...
7
...
16
Chapter 2
...
18
2
...
Logging in, activating the user interface and logging out
...
1
...
Introduction
...
1
...
Graphical mode
...
1
...
Text mode
...
2
...
21
2
...
1
...
21
2
...
2
...
21
2
...
3
...
22
2
...
Getting help

...
3
...
Be warned
...
3
...
The man pages
...
3
...
More info
...
4
...
28
2
...
Exercises
...
Quickstart
2
...
1
...
29
2
...
2
...
29
2
...
3
...
30
2
...
4
...
30
2
...
5
...
31
Chapter 3
...
32
3
...
General overview of the Linux file system
...
1
...
Files
...
1
...
About partitioning
...
1
...
More file system layout
...
2
...
40
3
...
1
...
40
3
...
2
...
41
3
...
3
...
41
3
...
4
...
44
3
...
5
...
46
3
...
6
...
47
3
...
Manipulating files
...
3
...
Viewing file properties
...
3
...
Creating and deleting files and directories
...
3
...
Finding files

...
3
...
More ways to view file content
...
3
...
Linking files
...
4
...
60
3
...
1
...
60
3
...
2
...
62
3
...
Summary
...
6
...
68
3
...
1
...
68
3
...
2
...
68
3
...
3
...
69
3
...
4
...
69
3
...
5
...
69
Chapter 4
...
71
4
...
Processes inside out
...
1
...
Multi-user and multi-tasking
...
1
...
Process types
...
1
...
Process attributes
...
1
...
Displaying process information

...
1
...
Life and death of a process
...
1
...
SUID and SGID

...
2
...
80
4
...
1
...
80
4
...
2
...
80
4
...
3
...
80
ii

Introduction to Linux

Table of Contents
Chapter 4
...
2
...
Init
...
2
...
Init run levels
...
2
...
Shutdown
...
3
...
84
4
...
1
...
84
4
...
2
...
85
4
...
3
...
86
4
...
4
...
86
4
...
5
...
86
4
...
Scheduling processes
...
4
...
Use that idle time!
...
4
...
The sleep command
...
4
...
The at command
...
4
...
Cron and crontab
...
5
...
94
4
...
Exercises
...
6
...
General
...
6
...
Booting, init etc
...
6
...
Scheduling
...
I/O redirection
...
1
...
97
5
...
1
...
97
5
...
2
...
97
5
...
Advanced redirection features
...
2
...
Use of file descriptors

...
2
...
Examples
...
3
...
101
5
...
1
...
102
5
...
2
...
102
5
...
Summary
...
5
...
103
Chapter 6
...
105
6
...
Text editors
...
1
...
Why should I use an editor?
...
1
...
Which editor should I use?
...
2
...
106
6
...
1
...
106
6
...
2
...
107
6
...
3
...
108
6
...
Linux in the office

...
3
...
History
...
3
...
Suites and programs
...
3
...
Remarks
...
4
...
109
6
...
Exercises
...
Home sweet /home
...
1
...
111
7
...
1
...
111
7
...
2
...
111
7
...
Your text environment
...
2
...
Environment variables

...
2
...
Shell setup files
...
2
...
A typical set of setup files
...
2
...
The Bash prompt
...
2
...
Shell scripts
...
3
...
123
7
...
1
...
123
7
...
2
...
124
7
...
3
...
125
7
...
Region specific settings
...
4
...
Keyboard setup
...
4
...
Fonts
...
4
...
Date and time zone
...
4
...
Language
...
4
...
Country-specific Information
...
5
...
128
7
...
1
...
128
7
...
2
...
128
7
...
3
...
131
7
...
4
...
132

...
5
...
Installing extra packages from the installation CDs

...
6
...
134
7
...
Exercises
...
7
...
Shell environment
...

7
...
2
...
136
Chapter 8
...
137
8
...
Printing files
...
1
...
Command line printing

...
1
...
Formatting
...
2
...
139
8
...
1
...
139
8
...
2
...
140
8
...
3
...
140
8
...
Print problems
...
3
...
Wrong file

...
3
...
My print hasn't come out
...
4
...
142
8
...
Exercises
...
Fundamental Backup Techniques
...
1
...
144
9
...
1
...
144
iv

Introduction to Linux

Table of Contents
Chapter 9
...
2
...
148
9
...
1
...
148
9
...
2
...
150
9
...
3
...
151
9
...
4
...
151
9
...
5
...
151
9
...
Using rsync
...
3
...
Introduction
...
3
...
An example: rsync to a USB storage device
...
4
...
152
9
...
1
...
152
9
...
2
...
153
9
...
3
...
154
9
...
4
...
154
9
...
5
...
155
9
...
Summary
...
6
...
156
Chapter 10
...
157
10
...
Networking Overview

...
1
...
The OSI Model
...
1
...
Some popular networking protocols

...
2
...
160
10
...
1
...
160
10
...
2
...
161
10
...
3
...
161
10
...
4
...
163
10
...
5
...
164
10
...
6
...
164
10
...
Internet/Intranet applications
...
3
...
Server types
...
3
...
Mail
...
3
...
Web
...
3
...
File Transfer Protocol
...

10
...
5
...
172
10
...
6
...
173
10
...
7
...
174
10
...
8
...
174
10
...
9
...
174
10
...
Remote execution of applications
...
4
...
Introduction
...
4
...
Rsh, rlogin and telnet
...

10
...
3
...
177
10
...
4
...
178
10
...
5
...
182
10
...
6
...
182

...
4
...
Cygwin
...
Networking
10
...
Security
...
5
...
Introduction
...
5
...
Services
...
5
...
Update regularly
...
5
...
Firewalls and access policies

...
5
...
Intrusion detection
...
5
...
More tips

...
5
...
Have I been hacked?

...
5
...
Recovering from intrusion

...
6
...
187
10
...
Exercises
...
7
...
General networking
...
7
...
Remote connections
...
7
...
Security

...
Sound and Video
...
1
...
189
11
...
1
...
189
11
...
2
...
189
11
...
Sound and video playing

...
2
...
CD playing and copying
...
2
...
Playing music files
...
2
...
Recording
...
3
...
192
11
...
Internet Telephony
...
4
...
What is it?

...
4
...
What do you need?
...
5
...
194
11
...
Exercises
...
Where to go from here?
...
1
...
196
A
...
1
...
196
A
...
2
...
196
A
...
3
...
196
A
...
4
...
196
A
...
5
...
197
A
...
Useful sites
...
2
...
General information

...
2
...
Architecture Specific References
...
2
...
Distributions
...
2
...
Software

...
DOS versus Linux commands
...
Shell Features

...
1
...
200
C
...
Differing features
...
204
A

...
204
C
...
205
E
...
206
G

...
207
I
...
208
K

...
208
M
...
210
O

...
210
Q

...
211
S
...
212
U

...
214
W
...
214
Y

...
215
Index
...
Why this guide?
Many people still believe that learning Linux is difficult, or that only experts can understand how a Linux
system works
...
Today,
thanks to the advancements in development, Linux has grown in popularity both at home and at work
...


2
...
For more advanced
trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system
and network administration
...
We hope these examples will help you to
get a better understanding of the Linux system and that you feel encouraged to try out things on your own
...


3
...
tldp
...
html; you can also download PDF and PostScript formatted versions here
...
garrels
...

The second edition of this guide is available in print from Fultus
...
Fultus distributes this document through Ingram and Baker & Taylor to many bookstores,
including Amazon
...
co
...
com and Google's Froogle global shopping portal
and Google Book Search
...
Introduction to Linux front cover

Introduction

1

Introduction to Linux

The guide has been translated into Hindi by:
• Alok Kumar
• Dhananjay Sharma
• Kapil
• Puneet Goel
• Ravikant Yuyutsu
Andrea Montagner translated the guide into Italian
...
Revision History
Revision History
Revision 1
...

Revision 1
...

Revision 1
...

Revision 1
...

Revision 1
...

Revision 1
...

Revision 1
...

Revision 1
...
xml
...

Revision 1
...
Added Fultus referrence in New Versions
section, updated Conventions and Organization sections
...


5
...
And especially to the Belgian Linux users for
hearing me out every day and always being generous in their comments
...

And thanks to all the readers who notified me about missing topics and who helped to pick out the last errors,
unclear definitions and typos by going through the trouble of mailing me all their remarks
...

In 2006, Suresh Rajashekara created a Debian package of this documentation
...
It is a big work that should not be underestimated; I admire your courage
...
Feedback
Missing information, missing links, missing characters? Mail it to the maintainer of this document:



Don't forget to check with the latest version first!

7
...

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer
...

* Neither the name of the author, Machtelt Garrels, nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission
...
IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
...


8
...
Most of this guide applies to all
Linux distributions - and UNIX in general
...

The Installation HOWTO contains helpful information on how to obtain Linux software and install it on your
computer
...

CD images can be downloaded from linux-iso
...

An interesting alternative for those who don't dare to take the step of an actual Linux installation on their
machine are the Linux distributions that you can run from a CD, such as the Knoppix distribution
...
Conventions used in this document
The following typographic and usage conventions occur in this text:

Table 1
...

Literal computer input and output captured from the terminal, usually rendered with
a light grey background
...

Name of a variable or pointer to content of a variable, as in $VARNAME
...

Argument to a command, as in "read man ls "
...

Name of a file or directory, for example "Change to the /usr/bin directory
...

Graphical button to click, like the OK button
...
"
4

Introduction to Linux
Terminology

Important term or concept: "The Linux kernel is the heart of the system
...

\
In other words, if you see a long command that is cut into multiple lines, \ means
"Don't press Enter yet!"
See Chapter 1
link to related subject within this guide
...

The following images are used:
This is a note
It contains additional information or remarks
...

This is a warning
Be very careful
...


10
...
As such, it provides you with the fundamental knowledge needed by anyone
who wants to start working with a Linux system, while at the same time it tries to consciously avoid
re-inventing the hot water
...

The first chapter is an introduction to the subject on Linux; the next two discuss absolute basic commands
...
Chapter 6 is needed for continuing with
the rest, since it discusses editing files, an ability you need to pass from Linux newbie to Linux user
...

All chapters come with exercises that will test your preparedness for the next chapter
...

• Chapter 2: Getting started, connecting to the system, basic commands, where to find help
...

• Chapter 4: Understanding and managing processes, boot and shutdown procedures, postponing tasks,
repetitive tasks
...

• Chapter 6: Why you should learn to work with an editor, discussion of the most common editors
...

• Chapter 8: Converting files to a printable format, getting them out of the printer, hints for solving
print problems
...

• Chapter 10: Overview of Linux networking tools and user applications, with a short discussion of the
underlying service daemon programs and secure networking
...

• Appendix A: Which books to read and sites to visit when you have finished reading this one
...

• Appendix C: If you ever get stuck, these tables might be an outcome
...


Introduction

6

Chapter 1
...
We
will discuss past and future development and take a closer look at the advantages and
disadvantages of this system
...

This chapter answers questions like:
♦ What is Linux?
♦ Where and how did Linux start?
♦ Isn't Linux that system where everything is done in text mode?
♦ Does Linux have a future or is it just hype?
♦ What are the advantages of using Linux?
♦ What are the disadvantages?
♦ What kinds of Linux are there and how do I choose the one that fits me?
♦ What are the Open Source and GNU movements?

1
...
History
1
...
1
...

Imagine computers as big as houses, even stadiums
...

Software was always customized to serve a specific purpose, and software for one given system didn't run on
another system
...
It was difficult, both for the users and the system administrators
...
The total cost per unit of computing power was enormous
...
In
1969, a team of developers in the Bell Labs laboratories started working on a solution for the software
problem, to address these compatibility issues
...
Simple and elegant
...
Written in the C programming language instead of in assembly code
...
Able to recycle code
...
"
The code recycling features were very important
...
UNIX on the other hand needed only a small
piece of that special code, which is now commonly named the kernel
...
The operating
system and all other functions were built around this kernel and written in a higher programming language, C
...
What is Linux?

7

Introduction to Linux
This language was especially developed for creating the UNIX system
...

The software vendors were quick to adapt, since they could sell ten times more software almost effortlessly
...
UNIX did a great deal to help users become compatible with different
systems
...
More things became possible to
do and more hardware and software vendors added support for UNIX to their products
...
You had to work at a university, for the government or for large financial
corporations in order to get your hands on a UNIX system
...

By that time, there were several versions of UNIX available for the PC architecture, but none of them were
truly free and more important: they were all terribly slow, so most people ran MS DOS or Windows 3
...


1
...
2
...
Linus
Torvalds, a young man studying computer science at the university of Helsinki, thought it would be a good
idea to have some sort of freely available academic version of UNIX, and promptly started to code
...

Below is one of his first posts in comp
...
minix, dating from 1991:
From: torvalds@klaava
...
FI (Linus Benedict Torvalds)
Newsgroups: comp
...
minix
Subject: Gcc-1
...
100050
...
Helsinki
...
Could somebody please point me to a (preferably)
machine-readable format of the latest posix rules? Ftp-sites would be
nice
...

That is why he asked for POSIX standards, POSIX still being the standard for UNIX
...
New drivers became available for all kinds of new hardware,
at a continuously rising speed
...
These coders didn't stop at their PC's; every piece of hardware they could find
was useful for Linux
...
Thanks to these people, Linux is now not only ideal to run on new PC's,
Chapter 1
...

Two years after Linus' post, there were 12000 Linux users
...
All the features of UNIX were added over the
next couple of years, resulting in the mature operating system Linux has become today
...
Today, a lot of the
important players on the hard- and software market each have their team of Linux developers; at your local
dealer's you can even buy pre-installed Linux systems with official support - eventhough there is still a lot of
hard- and software that is not supported, too
...
1
...
Current application of Linux systems
Today Linux has joined the desktop market
...
We don't like to admit that
Microsoft is ruling this market, so plenty of alternatives have been started over the last couple of years to
make Linux an acceptable choice as a workstation, providing an easy user interface and MS compatible office
applications like word processors, spreadsheets, presentations and the like
...
Especially Internet providers and Internet service providers have grown fond of Linux as
firewall, proxy- and web server, and you will find a Linux box within reach of every UNIX system
administrator who appreciates a comfortable management station
...
In post offices, they are the nerve centers that route
mail and in large search engine, clusters are used to perform internet searches
...

It is also worth to note that modern Linux not only runs on workstations, mid- and high-end servers, but also
on "gadgets" like PDA's, mobiles, a shipload of embedded applications and even on experimental
wristwatches
...


1
...
The user interface
1
...
1
...
Experienced UNIX users will say no,
because Linux is an ideal operating system for power-users and programmers, because it has been and is being
developed by such people
...
These packages come with every standard Linux distribution
...
All the documentation and
manuals are there, and examples are often included to help you get started in no time
...

In the early days of Linux, being an expert was kind of required to start using the system
...
It was common practice to tell a
beginning user to "RTFM" (read the manuals)
...
What is Linux?

9

Introduction to Linux
find the documentation, and even if someone did, explanations were in such technical terms that the new user
became easily discouraged from learning the system
...


1
...
2
...
They integrated a great deal of graphical user interfaces (GUIs), developed by
the community, in order to ease management of programs and services
...

Nowadays you can log in graphically and start all required applications without even having to type a single
character, while you still have the ability to access the core of the system if needed
...
New users are not
forced to do difficult things, while experienced users are not forced to work in the same way they did when
they first started learning Linux
...
Developers of desktop applications are
making incredible efforts to make the most beautiful desktops you've ever seen, or to make your Linux
machine look just like your former MS Windows or an Apple workstation
...
Linux has these, and tries to present all available services in a logical form that ordinary people can
understand
...
gnome
...
org/screenshots/
• http://www
...
org
• http://www
...
org

1
...
Does Linux have a future?
1
...
1
...
People can adapt it, fix it, debug it, and they can do it at a speed that dwarfs the
performance of software developers at conventional companies
...

The Open Source initiative started to make this clear to the commercial world, and very slowly, commercial
vendors are starting to see the point
...
Now Linux has grown past the stage where it
was almost exclusively an academic system, useful only to a handful of people with a technical background
...
What is Linux?

10

Introduction to Linux
Now Linux provides more than the operating system: there is an entire infrastructure supporting the chain of
effort of creating an operating system, of making and testing programs for it, of bringing everything to the
users, of supplying maintenance, updates and support and customizations, etcetera
...


1
...
2
...
This project is called SAMBA, and its
achievement is the reverse engineering of the Server Message Block (SMB)/Common Internet File System
(CIFS) protocol used for file- and print-serving on PC-related machines, natively supported by MS Windows
NT and OS/2, and Linux
...

Maybe even more successful than the SAMBA project is the Apache HTTP server project
...
Originally known as "A PAtCHy server", based on
existing code and a series of "patch files", the name for the matured code deserves to be connoted with the
native American tribe of the Apache, well-known for their superior skills in warfare strategy and inexhaustible
endurance
...
Apache is run on sites that get millions of visitors per day, and while no official support is
provided by the developers, the Apache user community provides answers to all your questions
...

In the category of office applications, a choice of MS Office suite clones is available, ranging from partial to
full implementations of the applications available on MS Windows workstations
...
With the desktop comes the praise of the common users, and not only
their praise, but also their specific requirements, which are growing more intricate and demanding by the day
...
Paid
employees and volunteers alike are working diligently so that Linux can maintain a position in the market
...
The Open Source community makes sure answers keep coming, and
watches the quality of the answers with a suspicious eye, resulting in ever more stability and accessibility
...
Throughout this course we will present you with the most common packages, which are almost all
freely available
...
You can see for yourself that no effort has been spared to make users who are
switching from Windows feel at home:

Figure 1-1
...
What is Linux?

11

Introduction to Linux

1
...
Properties of Linux
1
...
1
...
If you want to spend absolutely nothing, you don't even have to pay the
price of a CD
...
No
registration fees, no costs per user, free updates, and freely available source code in case you want to
change the behavior of your system
...
The license says that anybody who
may want to do so, has the right to change Linux and eventually to redistribute a changed version, on
the one condition that the code is still available after redistribution
...

• Linux is portable to any hardware platform:
A vendor who wants to sell a new type of computer and who doesn't know what kind of OS his new
machine will run (say the CPU in your car or washing machine), can take a Linux kernel and make it
Chapter 1
...

• Linux was made to keep on running:
As with UNIX, a Linux system expects to run without rebooting all the time
...
This property
allows for Linux to be applicable also in environments where people don't have the time or the
possibility to control their systems night and day
...
But Linux is not only fit for use as a fort against enemy attacks from the
Internet: it will adapt equally to other situations, utilizing the same high standards for security
...

• Linux is scalable:
From a Palmtop with 2 MB of memory to a petabyte storage cluster with hundreds of nodes: add or
remove the appropriate packages and Linux fits all
...
If you
want to do little things, such as making an operating system for an embedded processor or just
recycling your old 486, Linux will do that as well
...
It sometimes happens that there are only a couple of hours
between discovery and fixing of a bug
...
4
...
Linux Cons
• There are far too many different distributions:
"Quot capites, tot rationes", as the Romans already said: the more people, the more opinions
...
But it also means that everyone will find what he or she needs
...

When asked, generally every Linux user will say that the best distribution is the specific version he is
using
...
On top of the basics, special third party software is added
making, for example, TurboLinux more suitable for the small and medium enterprise, RedHat for
servers and SuSE for workstations
...
The best
strategy is to test a couple of distributions; unfortunately not everybody has the time for this
...
A quick search on Google, using the
keywords "choosing your distribution" brings up tens of links to good advise
...

• Linux is not very user friendly and confusing for beginners:
It must be said that Linux, at least the core system, is less userfriendly to use than MS Windows and
certainly more difficult than MacOS, but
...
More information is being released
Chapter 1
...

• Is an Open Source product trustworthy?
How can something that is free also be reliable? Linux users have the choice whether to use Linux or
not, which gives them an enormous advantage compared to users of proprietary software, who don't
have that kind of freedom
...
If Linux
were not trustworthy, it would have been long gone, never knowing the popularity it has now, with
millions of users
...
It is a project that is never finished, that is true, but in
an ever changing environment, Linux is also a project that continues to strive for perfection
...
5
...
5
...
Linux and GNU
Although there are a large number of Linux implementations, you will find a lot of similarities in the different
distributions, if only because every Linux machine is a box with building blocks that you may put together
following your own needs and views
...

Just when you think you have a nice running system, Linux will stimulate your imagination and creativeness,
and the more you realize what power the system can give you, the more you will try to redefine its limits
...
The Linux system is
based on GNU tools (Gnu's Not UNIX), which provide a set of standard ways to handle and use the system
...
Most distributions offer pre-compiled
packages of most common tools, such as RPM packages on RedHat and Debian packages (also called deb or
dpkg) on Debian, so you needn't be a programmer to install a package on your system
...
This setup
also allows you to install software even if it does not exist in a pre-packaged form suitable for your system
...

• GNU Photo: software for interaction with digital cameras
• Octave: a programming language, primarily intended to perform numerical computations and image
processing
...

Chapter 1
...
Throughout this guide we will only discuss freely available software,
which comes (in most cases) with a GNU license
...
The most common
implementations include RPM and dpkg
...
Dpkg is the Debian package management system,
which uses an interface called apt-get, that can manage RPM packages as well
...
Other third party software vendors may have
their own installation procedures, sometimes resembling the InstallShield and such, as known on MS
Windows and other platforms
...


1
...
2
...
2
...
1) is not part of the GNU project but uses the
same license as GNU software
...
Because any usable system must contain both
the kernel and at least a minimal set of utilities, some people argue that such a system should be called a
GNU/Linux system
...
If we are not talking about a GNU/Linux system, the specific
distribution, version or program name will be mentioned
...
5
...
Which distribution should I install?
Prior to installation, the most important factor is your hardware
...
LinuxPPC for example has been made to
run on Apple and other PowerPCs and does not run on an ordinary x86 based PC
...
Another tricky case is
Sun hardware, which could be an old SPARC CPU or a newer UltraSparc, both requiring different versions of
Linux
...
Sometimes distributions for
special CPUs are not as reliable, since they are tested by fewer people
...
These distributions are well-tested and maintained on a regular basis,
focusing on reliant server implementation and easy installation and update procedures
...
Linux also runs decently on laptops and middle-range servers
...

While the standard desktop might be Gnome on one system, another might offer KDE by default
...
Other window and desktop managers
are available for more advanced users
...
What is Linux?

15

Introduction to Linux
The standard installation process allows users to choose between different basic setups, such as a workstation,
where all packages needed for everyday use and development are installed, or a server installation, where
different network services can be selected
...

The goal of this guide is to apply to all Linux distributions
...
The following are very good choices for novices:
• Fedora Core
• Debian
• SuSE Linux
• Mandriva (former MandrakeSoft)
• Knoppix: an operating system that runs from your CD-ROM, you don't need to install anything
...
org
...


1
...
Summary
In this chapter, we learned that:
• Linux is an implementation of UNIX
...

• "De gustibus et coloribus non disputandum est": there's a Linux for everyone
...


1
...
Exercises
A practical exercise for starters: install Linux on your PC
...

Read the docs!
Most errors stem from not reading the information provided during the install
...

Things you must know BEFORE starting a Linux installation:
• Will this distribution run on my hardware?
Check with http://www
...
org/HOWTO/Hardware-HOWTO/index
...

• What kind of keyboard do I have (number of keys, layout)? What kind of mouse (serial/parallel,
number of buttons)? How many MB of RAM?
• Will I install a basic workstation or a server, or will I need to select specific packages myself?
• Will I install from my hard disk, from a CD-ROM, or using the network? Should I adapt the BIOS for
any of this? Does the installation method require a boot disk?
• Will Linux be the only system on this computer, or will it be a dual boot installation? Should I make a
large partition in order to install virtual systems later on, or is this a virtual installation itself?

Chapter 1
...

• Is this computer a gateway/router/firewall? (If you have to think about this question, it probably isn't
...
There is system-specific documentation available if you want to know everything about it
...

• Will this machine start up in text mode or in graphical mode?
• Think of a good password for the administrator of this machine (root)
...

• Do I need a rescue disk? (recommended)
• Which languages do I want?
The full checklist can be found at http://www
...
org/HOWTO/Installation-HOWTO/index
...

In the following chapters we will find out if the installation has been successful
...
What is Linux?

17

Chapter 2
...

We will discuss:
♦ Connecting to the system
♦ Disconnecting from the system
♦ Text and graphic mode
♦ Changing your password
♦ Navigating through the file system
♦ Determining file type
♦ Looking at text files
♦ Finding help

2
...
Logging in, activating the user interface and logging
out
2
...
1
...
You always
need to authenticate to the system
...


2
...
2
...
You know you will connect to the system using
graphical mode when you are first asked for your user name, and then, in a new window, to type your
password
...

Careful with that root account!
It is generally considered a bad idea to connect (graphically) using the root user name, the system
adminstrator's account, since the use of graphics includes running a lot of extra programs, in root's case
with a lot of extra permissions
...
But there are enough risks to keep this in mind as a general advice, for all use of the root
account: only log in as root when extra privileges are required
...


Chapter 2
...
This program can be found in the Applications->Utilities,
System Tools or Internet menu, depending on what window manager you are using
...

While browsing the menus, you will notice that a lot of things can be done without entering commands via the
keyboard
...
But this
guide is for future network and system administrators, who will need to meddle with the heart of the system
...
This tool is the shell, and when
in graphical mode, we activate our shell by opening a terminal window
...
Almost everything that follows is done using this
simple but powerful text tool
...
This terminal shows a standard prompt, which displays the user's login name, and the current working
directory, represented by the twiddle (~):

Figure 2-1
...

Later we will discuss prompts and their behavior in detail
...

To disconnect from the system in graphical mode, you need to close all terminal windows and other
applications
...
Closing everything is not really
necessary, and the system can do this for you, but session management might put all currently open
applications back on your screen when you connect again, which takes longer and is not always the desired
effect
...

When you see the login screen again, asking to enter user name and password, logout was successful
...
Quickstart

19

Introduction to Linux
We mentioned both the Gnome and KDE desktops already a couple of times
...
Whatever desktop you
chose to work with is fine - as long as you know how to open a terminal window
...


2
...
3
...
A
text mode login screen typically shows some information about the machine you are working on, the name of
the machine and a prompt waiting for you to log in:
RedHat Linux Release 8
...
Then you should type
your password, followed by another Enter
...
But this is normal on Linux and is done for security
reasons
...
Additionally, it is popular on UNIX systems to display a fortune cookie,
which contains some general wise or unwise (this is up to you) thoughts
...

Don't log in as root
Also in text mode: log in as root only to do setup and configuration that absolutely requires administrator
privileges, such as adding users, installing software packages, and performing network and other system
configuration
...
Alternatively, some systems, like Ubuntu, force you to use sudo, so that you do not
need direct access to the administrative account
...
You are successfully disconnected
from the system when you see the login screen again
...

However, powering off an old system without going through the halting process might cause
severe damage! If you want to be sure, always use the Shut down option when you log out from
the graphical interface, or, when on the login screen (where you have to give your user name and
password) look around for a shutdown button
...


Chapter 2
...
2
...
2
...
The commands
These are the quickies, which we need to get started; we will discuss them later in more detail
...
Quickstart commands
Command
ls
cd directory
passwd
file filename
cat textfile
pwd
exit or logout
man command
info command
apropos string

Meaning
Displays a list of files in the current working directory, like the dir command in
DOS
change directories
change the password for the current user
display file type of file with name filename
throws content of textfile on the screen
display present working directory
leave this session
read man pages on command
read Info pages on command
search the whatis database for strings

2
...
2
...

Commands can be issued by themselves, such as ls
...
The same option character may have a different meaning
for another command
...
Some
commands have no options
...
An example is ls /etc, where the directory /etc is the argument to the ls command
...
Some commands require arguments,
sometimes arguments are optional
...
3
...
We will discuss directory structure in-depth later
...
and
...
We will try to find out about those
during the exercises, and more in the next chapter
...
Quickstart

21

Introduction to Linux
Try to avoid logging in with or using the system administrator's account, root
...
, can be executed using a normal
user account with no special permissions at all
...
2
...

Almost all commands in this book can be executed without system administrator privileges
...
Once you're done, leave the application or session that
gives you root privileges immediately
...
Especially in the beginning, it is important to read
system documentation, manuals for basic commands, HOWTOs and so on
...
This book will try to
guide you to the most appropriate documentation on every subject discussed, in order to stimulate the habit of
reading the man pages
...
2
...
Using Bash features
Several special key combinations allow you to do things easier and faster with the GNU shell, Bash, which is
the default on almost any Linux system, see Section 3
...
3
...
Below is a list of the most commonly used
features; you are strongly suggested to make a habit out of using them, so as to get the most out of your Linux
experience from the very beginning
...
Key combinations in Bash
Key or key combination
Ctrl+A
Ctrl+C
Ctrl+D
Ctrl+E
Ctrl+H
Ctrl+L
Ctrl+R
Ctrl+Z
ArrowLeft and
ArrowRight
ArrowUp and
ArrowDown
Shift+PageUp and
Shift+PageDown
Tab
Tab Tab

Chapter 2
...

End a running program and return the prompt, see Chapter 4
...

Move cursor to the end of the command line
...

Clear this terminal
...
3
...
4
...

Move the cursor one place to the left or right on the command line, so that you can
insert characters at other places than just at the beginning and the end
...
Go to the line that you want to repeat, edit details if necessary,
and press Enter to save time
...

Command or filename completion; when multiple choices are possible, the system
will either signal with an audio or visual bell, or, if too many choices are possible,
ask you if you want to see them all
...


22

Introduction to Linux
The last two items in the above table may need some extra explanations
...
You just type on the command line cd dir, then you press Tab and the shell completes the name for
you, if no other files are starting with the same three characters
...
If more than one file starts with the same
characters, the shell will signal this to you, upon which you can hit Tab twice with short interval, and the shell
presents the choices you have:
your_prompt> cd st
starthere
stuff

stuffit

In the above example, if you type "a" after the first two characters and hit Tab again, no other possibilities are
left, and the shell completes the directory name, without you having to type the string "rthere":
your_prompt> cd starthere

Of course, you'll still have to hit Enter to accept this choice
...
If you type Tab Tab again, you'll see the choices; if you type
one or more characters that make the choice unambiguous to the system, and Tab again, or Enter when
you've reach the end of the file name that you want to choose, the shell completes the file name and changes
you into that directory - if indeed it is a directory name
...

The same goes for command name completion
...
2
...
3
...
3
...
Be warned
GNU/Linux is all about becoming more self-reliant
...
A common way of getting help is finding someone who knows, and however patient and
peace-loving the Linux-using community will be, almost everybody will expect you to have tried one or more
of the methods in this section before asking them, and the ways in which this viewpoint is expressed may be
rather harsh if you prove not to have followed this basic rule
...
3
...
The man pages
A lot of beginning users fear the man (manual) pages, because they are an overwhelming source of
documentation
...

Reading man pages is usually done in a terminal window when in graphical mode, or just in text mode if you
prefer it
...
Quickstart

23

Introduction to Linux
yourname@yourcomp ~> man man

The documentation for man will be displayed on your screen after you press Enter:
man(1)

man(1)

NAME
man - format and display the on-line manual pages
manpath - determine user's search path for man pages
SYNOPSIS
man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file]
[-M pathlist] [-P pager] [-S section_list] [section] name
...
If you specify
section, man only looks in that section of the manual
...
However, if name contains a
slash (/) then man interprets it as a file specification, so that you
can do man
...
5 or even man /cd/foo/bar
...
gz
...


a

description

of where man looks for the manual

OPTIONS
-C config_file
lines 1-27

Browse to the next page using the space bar
...
When you
reach the end, man will usually quit and you get the prompt back
...

Pagers
The available key combinations for manipulating the man pages depend on the pager used in your
distribution
...
See Section 3
...
4
...

Each man page usually contains a couple of standard sections, as we can see from the man man example:
• The first line contains the name of the command you are reading about, and the id of the section in
which this man page is located
...
Commands are likely to have
multiple man pages, for example the man page from the user section, the man page from the system
admin section, and the man page from the programmer section
...
You can look for any given search string in this index using the apropos command
...
You can think of an option as a way of executing the command
...
Some commands have no options or no arguments
...

• A longer description of the command is given
...
Options can usually be combined
...

• Environment describes the shell variables that influence the behavior of this command (not all
commands have this)
...
Quickstart

24

Introduction to Linux
• Sometimes sections specific to this command are provided
...
In between parentheses is the
number of the man page section in which to find this command
...

• Usually there is also information about known bugs (anomalies) and where to report new bugs you
may find
...

Some commands have multiple man pages
...
By default, the man page with the lowest number is shown
...


2
...
3
...
3
...
1
...
These
usually contain more recent information and are somewhat easier to use
...

Get started by typing info info in a terminal window:
File: info
...
The GNU Project distributes most
of its on-line manuals in the Info format, so you need a program called
"Info reader" to read the manuals
...

If you are new to Info and want to learn how to use it, type the
command `h' now
...

To learn advanced Info commands, type `n' twice
...

* Menu:
* Getting Started::
Getting started using an Info reader
...

* Creating an Info File::
How to make your own Info file
...
info
...
2
...


Chapter 2
...
Use the P and N keys to go to the previous
or next subject
...
Use Q to quit
...

2
...
3
...
The whatis and apropos commands
A short index of explanations for commands is available using the whatis command, like in the examples
below:
[your_prompt] whatis ls
ls
(1)

- list directory contents

This displays short information about a command, and the first section in the collection of man pages that
contains an appropriate page
...
Say that
you don't know how to start a browser, then you could enter the following command:
another prompt> apropos browser
Galeon [galeon](1) - gecko-based GNOME web browser
lynx
(1) - a general purpose distributed information browser
for the World Wide Web
ncftp
(1) - Browser program for the File Transfer Protocol
opera
(1) - a graphical web browser
pilot
(1) - simple file system browser in the style of the
Pine Composer
pinfo
(1) - curses based lynx-style info browser
pinfo [pman]
(1) - curses based lynx-style info browser
viewres
(1x) - graphical class browser for Xt

After pressing Enter you will see that a lot of browser related stuff is on your machine: not only web
browsers, but also file and FTP browsers, and browsers for documentation
...
Generally, a command with a man page in section one, so one marked with "(1)", is suitable for
trying out as a user
...

2
...
3
...
The --help option
Most GNU commands support the --help, which gives a short explanation about how to use the command
and a list of available options
...

Concatenate FILE(s), or standard input, to standard output
...
Quickstart

equivalent to -vET
number nonblank output lines
equivalent to -vE
display $ at end of each line
number all output lines
never more than one single blank line
equivalent to -vT
display TAB characters as ^I
(ignored)
use ^ and M- notation,

26

Introduction to Linux
--help
--version

except for LFD and TAB
display this help and exit
output version information and exit

With no FILE, or when FILE is -, read standard input
...
org>
...
3
...
4
...
Konqueror, the default KDE file manager, provides
painless and colourful access to the man and Info pages
...
Similarly, "man:ls" will present
you with the man page for the ls command
...
Entering "info:/dir" in the address
location toolbar displays all the Info pages, arranged in utility categories
...
Start up from the menu or by typing the command konqueror in a terminal
window, followed by Enter; see the screenshot below
...
Konqueror as help browser

Chapter 2
...
You can start it selecting Applications->Help from the
Gnome menu, by clicking the lifeguard icon on your desktop or by entering the command gnome-help in a
terminal window
...

The nautilus file manager provides a searchable index of the man and Info pages, they are easily browsable
and interlinked
...

The big advantage of GUIs for system documentation is that all information is completely interlinked, so you
can click through in the "SEE ALSO" sections and wherever links to other man pages appear, and thus browse
and acquire knowledge without interruption for hours at the time
...
3
...
5
...
cd, exit,
logout and pwd are such exceptions
...
For information about these, refer to the man or info page of your shell
...
See Section 3
...
3
...

If you have been changing your original system configuration, it might also be possible that man pages are
still there, but not visible because your shell environment has changed
...
How to do this is explained in Section 7
...
1
...

Some programs or packages only have a set of instructions or references in the directory /usr/share/doc
...
3
...

In the worst case, you may have removed the documentation from your system by accident (hopefully by
accident, because it is a very bad idea to do this on purpose)
...
3
...
If so, you may have to re-install
the package that contains the command to which the documentation applied, see Section 7
...


2
...
Summary
Linux traditionally operates in text mode or in graphical mode
...
This does
not mean that you don't have to know about text mode: we will work in the text environment throughout this
course, using a terminal window
...
Inevitably, you will have to read
a lot of documentation to achieve that goal; that is why, as you will notice, we refer to extra documentation for
almost every command, tool and problem listed in this book
...
Make reading documentation a habit as soon as possible
...

We already learned some commands:

Table 2-3
...
Quickstart

28

Introduction to Linux
apropos
cat
cd
exit
file
info
logout
ls
man
passwd
pwd

Search information about a command or subject
...

Change into another directory
...

Get information about the content of a file
...

Leave a shell session
...

Read manual pages of a command
...

Display the current working directory
...
5
...
These exercises are
made to get you to read some error messages
...

Don't forget to use the Bash features on the command line: try to do the exercises typing as few characters as
possible!

2
...
1
...

I am working in text/graphical mode
...

• Log out
...
5
...
Passwords
Log in again with your user name and password
...
aa! and hit the Enter key
...

-> What happens?
• Try again, this time don't enter a password but just hit the Enter key
...
Quickstart

29

Introduction to Linux
New password
Unless you change your password back again to what it was before this exercise, it will be "P6p3
...

Change your password after this exercise!
Note that some systems might not allow to recycle passwords, i
...
restore the original one within a
certain amount of time or a certain amount of password changes, or both
...
5
...
Directories
These are some exercises to help you get the feel
...

Mind the space between "cd" and "
...

-> What happens?
• List the directory contents with the ls command
...

• Enter the cd command
...

-> What happens?
• Display the content of this directory
...

Do you know another possibility to get where you are now?

2
...
4
...
Type ls; if the output is longer than your screen, make the
window longer, or try Shift+PageUp and Shift+PageDown
...
Try the file command on it
...
Quickstart

30

Introduction to Linux
-> The file type of my inittab is
...

-> What is the default mode of your computer?
• Return to your home directory using the cd command
...

-> Does this help to find the meaning of "
...
" using the cat command?
• Display help for the cat program, using the --help option
...


2
...
5
...

• Try man or info on cd
...


Chapter 2
...
About files and the file system
After the initial exploration in Chapter 2, we are ready to discuss the files and directories on a
Linux system in more detail
...
We will try to shine some light on
the organization of files in the file system
...

After completion of the exercises in this chapter, you will be able to:
♦ Describe the layout of a Linux file system
♦ Display and set paths
♦ Describe the most important files, including kernel and shell
♦ Find lost and hidden files
♦ Create, move and delete files and directories
♦ Display contents of files
♦ Understand and use different link types
♦ Find out about file properties and change file permissions

3
...
General overview of the Linux file system
3
...
1
...
1
...
1
...
"
This statement is true because there are special files that are more than just files (named pipes and sockets, for
instance), but to keep things simple, saying that everything is a file is an acceptable generalization
...
Programs, services, texts, images, and so forth, are all files
...

In order to manage all those files in an orderly fashion, man likes to think of them in an ordered tree-like
structure on the hard disk, as we know from MS-DOS (Disk Operating System) for instance
...
For now
we will use this image of the tree, but we will find out later why this is not a fully accurate image
...
1
...
2
...


Chapter 3
...

• Directories: files that are lists of other files
...
Most special files are in /dev, we will
discuss them later
...
We will
talk about links in detail
...

• Named pipes: act more or less like sockets and form a way for processes to communicate with each
other, without using network socket semantics
...
doc
41472 Feb 21 17:56 Linux
...
File types in a long list
Symbol Meaning
Regular file
d
Directory
l
Link
c
Special file
s
Socket
p
Named pipe
b
Block device
In order not to always have to perform a long listing for seeing the file type, a lot of systems by default don't
issue just ls, but ls -F, which suffixes file names with one of the characters "/=*|@" to indicate the file type
...
3
...
1
...

As a user, you only need to deal directly with plain files, executable files, directories and links
...

Now, before we look at the important files and directories, we need to know more about partitions
...
1
...
About partitioning

Chapter 3
...
1
...
1
...
It may seem strange that Linux uses more than one partition on the same disk, even
when using the standard installation procedure, so some explanation is called for
...
By
dividing the hard disk in partitions, data can be grouped and separated
...

This principle dates from the days when Linux didn't have journaled file systems and power failures might
have lead to disaster
...
This is currently the most
important reason for partitioning
...
If the disk contains only one big partition, the entire system will stop functioning
if the disk is full
...

Mind that having a journaled file system only provides data security in case of power failure and sudden
disconnection of storage devices
...
In those cases, you should use a RAID (Redundant Array of Inexpensive Disks) solution
...
1
...
2
...

Most systems contain a root partition, one or more data partitions and one or more swap partitions
...

Most Linux systems use fdisk at installation time to set the partition type
...
On some occasions, however, you may not be so
lucky
...
The standard Linux partitions have number 82 for swap and 83 for data, which can be journaled
(ext3) or normal (ext2, on older systems)
...

Apart from these two, Linux supports a variety of other file system types, such as the relatively new Reiser
file system, JFS, NFS, FATxx and many other file systems natively available on other (proprietary) operating
systems
...
A standard installation requires about 250 MB for the
root partition
...
Swap is the system that ensures, like on normal UNIX systems, that you can keep on
Chapter 3
...
On Linux, you will virtually never see irritating messages like Out of memory,
please close some applications first and try again, because of this extra memory
...

Using memory on a hard disk is naturally slower than using the real memory chips of a computer, but having
this little extra is a great comfort
...

Linux generally counts on having twice the amount of physical memory in the form of swap space on the hard
disk
...
An example on a system with
512 MB of RAM:
• 1st possibility: one swap partition of 1 GB
• 2nd possibility: two swap partitions of 512 MB
• 3rd possibility: with two hard disks: 1 partition of 512 MB on each disk
...

Read the software documentation for specific guidelines
...
Others, such as some handheld systems, might not have any swap at all by lack of a hard
disk
...

The kernel is on a separate partition as well in many distributions, because it is the most important file of your
system
...

The rest of the hard disk(s) is generally divided in data partitions, although it may be that all of the
non-system critical data resides on one partition, for example when you perform a standard workstation
installation
...
Changing sizes or properties of existing partitions is
possible but not advisable
...
On larger systems, he or
she may even spread one partition over several hard disks, using the appropriate software
...
During the installation process you can define your own partition layout using
either your distribution specific tool, which is usually a straight forward graphical interface, or fdisk, a
text-based tool for creating partitions and setting their properties
...
The selected software for
installation reflects this and the stress is on common user packages, such as nice desktop themes, development
tools, client programs for E-mail, multimedia software, web and other services
...

Chapter 3
...
Programs that offer services are kept in a
different place than the data handled by this service
...

• a partition with user programs and applications
• one or more partitions for the user specific files (home directories)
• one or more swap partitions (virtual memory)
Servers usually have more memory and thus more swap space
...
For better
performance, swap is often divided into different swap partitions
...
1
...
3
...
The mount point defines the place of a particular
data set in the file system
...
On this partition,
which is indicated with the slash (/), directories are created
...
An example: given a partition that holds the following directories:
videos/

cd-images/

pictures/

We want to attach this partition in the filesystem in a directory called /opt/media
...
Preferably, it
should be an empty directory
...
Then, using the mount
command, the administrator can attach the partition to the system
...

During system startup, all the partitions are thus mounted, as described in the file /etc/fstab
...
If well configured, the device will be mounted as soon as the system
notices that it is connected, or it can be user-mountable, i
...
you don't need to be system administrator to
attach and detach the device to and from the system
...
3
...
In Linux, df is the GNU version, and supports the -h or
human readable option which greatly improves readability
...
Their behavior is usually the same, though GNU
versions of common tools often have more and better features
...
These can include partitions
from other networked systems, like in the example below where the home directories are mounted from a file
server on the network, a situation often encountered in corporate environments
...
0G

Used Avail Use% Mounted on
183M 288M 39% /
8
...
7G 85% /opt
5
...
2G 81% /usr

Chapter 3
...
7G
8
...
7G
3
...
7G

77% /var
44% /
...
1
...
More file system layout
3
...
3
...
Visual
For convenience, the Linux file system is usually thought of in a tree structure
...


Figure 3-1
...
About files and the file system

37

Introduction to Linux
This is a layout from a RedHat system
...
The names are
not even required; they are only a convention
...
This directory,
containing all underlying directories and files, is also called the root directory or "the root" of the file system
...
When starting with a
new system, it is always a good idea to take a look in the root directory
...
Subdirectories of the root directory
Directory Content
/bin
Common programs, shared by the system, the system administrator and the users
...
In some recent distributions also grub data
...

Contains references to all the CPU peripheral hardware, which are represented as files with
/dev
special properties
...

/initrd
(on some distributions) Information for booting
...

Every partition has a lost+found in its upper directory
...

/misc
For miscellaneous purposes
...
g
...

/net
Standard mount point for entire remote file systems
/opt
Typically contains extra and third party software
...
More information about the
/proc
meaning of the files in proc is obtained by entering the command man proc in a terminal
window
...
txt discusses the virtual file system in detail
...
Mind the difference between /, the root directory and
/root
/root, the home directory of the root user
...

Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any
/tmp
work!
/usr
Programs, libraries, documentation etc
...

/var
Storage for all variable files and temporary files created by users, such as log files, the mail
queue, the print spooler area, space for temporary storage of files downloaded from the Internet,
Chapter 3
...

How can you find out which partition a directory is on? Using the df command with a dot (
...

Filesystem
/dev/hda7

Size
980M

Used Avail Use% Mounted on
163M 767M 18% /

As a general rule, every directory under the root directory is on the root partition, unless it has a separate entry
in the full listing from df (or df -h with no other options)
...

3
...
3
...
The file system in reality
For most users and for most common system administration tasks, it is enough to accept that files and
directories are ordered in a tree-like structure
...

Every partition has its own file system
...
In a file system, a file is represented by an
inode, a kind of serial number containing information about the actual data that makes up the file: to whom
this file belongs, and where is it located on the hard disk
...

Each inode describes a data structure on the hard disk, storing the properties of a file, including the physical
location of the file data
...
This number will be the maximum amount of files, of all types (including directories, special files,
links etc
...
We typically count on having 1 inode per 2 to 8
kilobytes of storage
...
In that inode is the following information:
• Owner and group owner of the file
...
)
• Permissions on the file Section 3
...
1
• Date and time of creation, last read and change
...

• Number of links to this file (see later in this chapter)
...

The only information not included in an inode, is the file name and directory
...
By comparing file names and inode numbers, the system can make up a tree-structure that the
user understands
...
The inodes have their own
separate space on the disk
...
About files and the file system

39

Introduction to Linux

3
...
Orientation in the file system
3
...
1
...
For example, we know that the ls command is in the /bin directory (check with which -a ls),
yet we don't have to enter the command /bin/ls for the computer to list the content of the current directory
...
This variable lists those directories in the system where
executable files can be found, and thus saves the user a lot of typing and memorizing locations of commands
...
The echo command is used to display the content ("$") of the variable PATH:
rogier:> echo $PATH
/opt/local/bin:/usr/X11R6/bin:/usr/bin:/usr/sbin/:/bin

In this example, the directories /opt/local/bin, /usr/X11R6/bin, /usr/bin, /usr/sbin and
/bin are subsequently searched for the required program
...
This can lead to strange situations
...
The difference is in the configuration of the PATH variable:
[jenny@blob jenny]$ sendsms
bash: sendsms: command not found
[jenny@blob jenny]$ echo $PATH
/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/home/jenny/bin
[jenny@blob jenny]$ su - tony
Password:
tony:~>which sendsms
sendsms is /usr/local/bin/sendsms
tony:~>echo $PATH
/home/tony/bin
...

A backslash indicates the continuation of a line on the next, without an Enter separating one line from the
other
...
Since the program in his home directory is found first when searching the
Chapter 3
...
To resolve this problem there are several ways (there are always several ways to solve a
problem in UNIX/Linux): one answer could be to rename the user's wc program, or the user can give the full
path to the exact command he wants, which can be found by using the -a option to the which command
...
Opening new sessions, even while the current one is still running, will not
result in a new path in the new session
...
2 how we can make these kinds of
changes to the environment permanent, adding these lines to the shell configuration files
...
2
...
Absolute and relative paths
A path, which is the way you need to follow in the tree structure to reach a given file, can be described as
starting from the trunk of the tree (the / or root directory)
...

In the other case, the path doesn't start with a slash and confusion is possible between ~/bin/wc (in the
user's home directory) and bin/wc in /usr, from the previous example
...

In relative paths we also use the
...
indications for the current and the parent directory
...
/configure, which runs the configure program located in the current directory (that came
with the new code), as opposed to running another configure program elsewhere on the system
...
/images/garden
...
2
...
The most important files and directories
3
...
3
...
The kernel
The kernel is the heart of the system
...
The kernel also makes sure that processes and daemons (server processes) are started and stopped
at the exact right times
...
It would
lead us too far to discuss the kernel in detail
...
About files and the file system

41

Introduction to Linux
file on the system
...
2
...
2
...
2
...
2
...
What is a shell?

When I was looking for an appropriate explanation on the concept of a shell, it gave me more trouble than I
expected
...
A shell is much more than that
...
Most users do know that
other language, the point-and-click language of the desktop
...
It is very difficult
for a programmer to include all options and possible uses of a command in the GUI-format
...

The shell, on the other hand, is an advanced way of communicating with the system, because it allows for
two-way conversation and taking initiative
...
The shell allows the user to handle a system in a very flexible way
...

3
...
3
...
2
...

This is the basic shell, a small program with few features
...

• bash or Bourne Again SHell: the standard GNU shell, intuitive and flexible
...
On Linux, bash is the standard shell for common users
...
This means that the Bourne Again SHell is compatible
with the Bourne shell: commands that work in sh, also work in bash
...
All examples and exercises in this book use bash
...
Sometimes
asked for by programmers
...

• ksh or the Korn shell: sometimes appreciated by people with a UNIX background
...

The file /etc/shells gives an overview of known shells on a Linux system:
mia:~> cat /etc/shells
/bin/bash
/bin/sh
/bin/tcsh
/bin/csh

Fake Bourne shell
Chapter 3
...

Your default shell is set in the /etc/passwd file, like this line for user mia:
mia:L2NOfqdlPrHwE:504:504:Mia Maya:/home/mia:/bin/bash

To switch from one shell to another, just enter the name of the new shell in the active terminal
...
A new prompt is usually shown, because each
shell has its typical appearance:
mia:~> tcsh
[mia@post21 ~]$
3
...
3
...
3
...
2
...
3
...
In most cases it is a
subdirectory of /home, though this may vary
...
In
another case the system administrator may have opted for a less comprehensible layout and your home
directory may be on /disk6/HU/07/jgillard
...
The correct path to your
home directory is stored in the HOME environment variable, in case some program needs it
...
You can put as many files in as many directories as you
want, although the total amount of data and files is naturally limited because of the hardware and size of the
partitions, and sometimes because the system administrator has applied a quota system
...
Nowadays, limits are almost exclusively
applied in large environments
...
Exceeding
the limits may be tolerated during a grace period with fewer or no restrictions at all
...

No Quota?
If your system can not find the quota, then no limitation of file system usage is being applied
...
This same
path is stored in the HOME variable, so you don't have to do anything to activate it
...
About files and the file system

43

Introduction to Linux
switch from /var/music/albums/arno/2001 to images in your home directory using one elegant
command:
rom:/var/music/albums/arno/2001> cd ~/images
rom:~/images> pwd
/home/rom/images

Later in this chapter we will talk about the commands for managing files and directories in order to keep your
home directory tidy
...
2
...
The most important configuration files
As we mentioned before, most configuration files are stored in the /etc directory
...
The syntax is
straight forward:
cat file1 file2
...
This is certainly not a
complete list
...
When reading the
configuration files, you will find that they are usually quite well commented and self-explanatory
...


Table 3-3
...
*
directories
default
filesystems
fstab
ftp*
group

Information/service
Mail aliases file for use with the Sendmail and Postfix mail server
...
In this file local user names are
matched with real names as they occur in E-mail addresses, or with
other local addresses
...

The system-wide configuration file for the Bourne Again SHell
...
Other shells may have their
own system-wide config files, like cshrc
...

Default options for certain commands, such as useradd
...

Lists partitions and their mount points
...

Configuration file for user groups
...
Edit manually only if you
really know what you are doing
...
About files and the file system

44

Introduction to Linux
A list of machines that can be contacted using the network, but without
the need for a domain name service
...

inittab
Information for booting: mode, number of text consoles etc
...

ld
...
conf
Locations of library files
...
conf, silo
...
conf etc
...

Rotation of the logs, a system preventing the collection of huge
logrotate
...

mail
Directory containing instructions for the behavior of the mail server
...
conf
Configuration of modules that enable special features (drivers)
...

mtab
Currently mounted file systems
...

Order in which to contact the name resolvers when a process demands
nsswitch
...

pam
...

Lists local users
...
Edit manually only when you really know what
you are doing
...
Don't edit
printcap
this manually unless you really know what you are doing
...

rc*
Directories defining active services for each run level
...
conf
Order in which to contact DNS servers (Domain Name Servers only)
...
cf
Main config file for the Sendmail server
...

sndconfig or sound
Configuration of the sound card and sound events
...

Directory containing the system configuration files: mouse, keyboard,
sysconfig
network, desktop, system clock, power management etc
...
RedHat uses XFree, which is
reflected in the name of the main configuration file, XFree86Config
...

Configuration files for Internet services that are run from the system's
xinetd
...
conf
(extended) Internet services daemon (servers that don't run an
independent daemon)
...

hosts

Chapter 3
...
2
...
The most common devices
Devices, generally every peripheral attachment of a PC that is not the CPU itself, is presented to the system as
an entry in the /dev directory
...

Users that are new to Linux or UNIX in general are often overwhelmed by the amount of new names and
concepts they have to learn
...


Table 3-4
...
About files and the file system

Device
CD drive
Special entry for the currently used console
...
44 MB floppies
...

Infrared devices
Management of ISDN connections
Joystick(s)
Printers
Memory
midi player
Idealized model of a mixer (combines or adds signals)
Modem
All kinds of mouses
Bottomless garbage can
Entries for parallel port support
Pseudo terminals
For Radio Amateurs (HAMs)
...

USB card and scanner
For use with a graphics card supporting video
...
2
...
The most common variable files
In the /var directory we find a set of directories for storing specific non-constant data (as opposed to the ls
program or the system configuration files, which change relatively infrequently or never at all)
...
are kept in a subdirectory of /var
...
A lot of these files also need more
permissions than usual, like /var/tmp, which needs to be writable for everyone
...
This
is one reason why the /var directory, including all its subdirectories, is usually on a separate partition
...

/var/tmp and /tmp
Files in /tmp can be deleted without notice, by regular system tasks or because of a system reboot
...
Nevertheless, since this is not
the case by default, we advise to use the /var/tmp directory for saving temporary files
...
If you manage your own system, you can be reasonably
sure that this is a safe place if you did not consciously change settings on /var/tmp (as root, a normal
user can not do this)
...
This pretty much limits your access to safe file systems
...
The configuration
file of the so-called syslogdaemon determines which and how long logged information will be kept
...

In /var we typically find server data, which is kept here to separate it from critical data such as the server
program itself and its configuration files
...
The FTP-tree of an FTP server (data that
can be downloaded by a remote client) is also best kept in one of /var's subdirectories
...

On most workstation installations, /var/spool will at least contain an at and a cron directory,
containing scheduled tasks
...

On server systems we will generally find /var/spool/mail, containing incoming mails for local users,
sorted in one file per user, the user's "inbox"
...
These parts of the system can be very busy on mail servers with a lot of users
...

The /var/lib/rpm directory is specific to RPM-based (RedHat Package Manager) distributions; it is
where RPM package information is stored
...

Chapter 3
...
3
...
3
...
Viewing file properties
3
...
1
...
More about ls
Besides the name of the file, ls can give a lot of other information, such as the file type, as we already
discussed
...
With the -a option to ls, files that are normally hidden from view can be displayed
as well
...
A couple of typical examples include the
configuration files in your home directory
...

Next to that, every directory contains a file named just dot (
...
), which are used in
combination with their inode number to determine the directory's position in the file system's tree structure
...
Options can be combined, as is the case with most UNIX commands and their options
...
ls -latr displays the same files, only now in reversed order of the last change, so
that the file changed most recently occurs at the bottom of the list
...
/

...
/ Albums/ Singles/

gene/

index
...
html

krissie:~/mp3> ls -l Radio/
total 8
drwxr-xr-x
2 krissie krissie
drwxr-xr-x
2 krissie krissie

4096 Oct 30
4096 Sep 24

1999 Carolina/
1999 Slashdot/

krissie:~/mp3> ls -ld Radio/
drwxr-xr-x
4 krissie krissie

4096 Oct 30

1999 Radio/

krissie:~/mp3> ls -ltr
total 20
drwxr-xr-x
4 krissie
-rw-r--r-1 krissie
drwxrwxr-x
30 krissie
drwxr-xr-x
2 krissie
drwxrwxr-x
13 krissie

4096
453
4096
4096
4096

krissie
krissie
krissie
krissie
krissie

Oct 30 1999 Radio/
Jan 7 2001 index
...
This feature allows to see the file type without
using any options to ls
...
The standard scheme is in
/etc/DIR_COLORS:

Table 3-5
...
About files and the file system

48

Introduction to Linux
red
compressed archives
white
text files
pink
images
cyan
links
yellow
devices
green
executables
flashing red broken links
More information is in the man page
...
For mono-color use (like printing a directory listing) and for general
readability, this scheme is still in use:

Table 3-6
...

3
...
1
...
More tools
To find out more about the kind of data we are dealing with, we use the file command
...
Some examples:
mike:~> file Documents/
Documents/: directory
mike:~> file high-tech-stats
...
pdf: PDF document, version 1
...
rm
Nari-288
...
sdw
bijlage10
...
xcf
logo
...
txt
cv
...
png
image
...
About files and the file system

49

Introduction to Linux
mike:~> file me+tux
...
jpg: JPEG image data, JFIF standard 1
...
zip
...
zip
...
zip', last modified: Thu Nov 1 23:45:39 2001, os: Unix
mike:~> file vi
...
gif: GIF image data, version 89a, 88 x 31
mike:~> file slide1
slide1: HTML document text
mike:~> file template
...
xls: Microsoft Office Document
mike:~> file abook
...
ps: PostScript document text conforming at level 2
...
See info
file for a detailed description
...
In
other words, file can be tricked
...
These tools will
not work when used on the wrong type of files
...
If this happens to you, just close the terminal session and start a new one
...


3
...
2
...
3
...
1
...


...
Today almost every system is networked, so naturally files get copied from
one machine to another
...
To illustrate the problem, here's the full
content of a new user's directory, created on a standard RedHat system:
[newuser@blob user]$ ls -al
total 32
drwx-----3 user
user
drwxr-xr-x
6 root
root
-rw-r--r-1 user
user
-rw-r--r-1 user
user
-rw-r--r-1 user
user
drwxr-xr-x
3 user
user
-rw-r--r-1 user
user
-rw------1 user
user

4096
4096
24 Jan
191 Jan
124 Jan
4096 Jan
3511 Jan
61 Jan

Jan 16 13:32
...

16 13:32
...
bash_profile
16 13:32
...
kde
16 13:32
...
xauthDqztLr

On first sight, the content of a "used" home directory doesn't look that bad either:
Chapter 3
...
org638/
staroffice6
...
0

But when all the directories and files starting with a dot are included, there are 185 items in this directory
...
Usually these files are created the first time you start an application
...

Furthermore, new files are created seemingly continuously because users want to save files, keep different
versions of their work, use Internet applications, and download files and attachments to their local machine
...
It is clear that one definitely needs a scheme to keep an overview on things
...
We only discuss text tools available to the
shell, since the graphical tools are very intuitive and have the same look and feel as the well known
point-and-click MS Windows-style file managers, including graphical help functions and other features you
expect from this kind of applications
...
Most file managers can be started from the menu of your desktop manager, or by clicking your
home directory icon, or from the command line, issuing these commands:
• nautilus: The default file manager in Gnome, the GNU desktop
...
gnome
...

• konqueror: The file manager typically used on a KDE desktop
...
kde
...

• mc: Midnight Commander, the Unix file manager after the fashion of Norton Commander
...
org/directory/ or a mirror, such as http://www
...
org
...
Now let's find out about the internals and see how these graphical
tools use common UNIX commands
...
3
...
2
...
3
...
2
...
Creating directories

A way of keeping things in place is to give certain files specific default locations by creating directories and
subdirectories (or folders and sub-folders if you wish)
...
About files and the file system

51

Introduction to Linux
richard:~/archive> ls
1999/ 2000/ 2001/
richard:~/archive> mkdir 2001/reports/Restaurants-Michelin/
mkdir: cannot create directory `2001/reports/Restaurants-Michelin/':
No such file or directory
richard:~/archive> mkdir -p 2001/reports/Restaurants-Michelin/
richard:~/archive> ls 2001/reports/
Restaurants-Michelin/

If the new file needs other permissions than the default file creation permissions, the new access rights can be
set in one move, still using the mkdir command, see the Info pages for more
...

The name of a directory has to comply with the same rules as those applied on regular file names
...
There are virtually no limits on the length
of a file name, but it is usually kept shorter than 80 characters, so it can fit on one line of a terminal
...
When in doubt, check with Appendix C
...
3
...
2
...
Moving files

Now that we have properly structured our home directory, it is time to clean up unclassified files using the mv
command:
richard:~/archive> mv
...
doc reports/Restaurants-Michelin/

This command is also applicable when renaming files:
richard:~> ls To_Do
-rw-rw-r-1 richard richard

2534 Jan 15 12:39 To_Do

richard:~> mv To_Do done
richard:~> ls -l done
-rw-rw-r-1 richard richard

2534 Jan 15 12:39 done

It is clear that only the name of the file changes
...

Detailed information about the syntax and features of the mv command can be found in the man or Info pages
...
The answer
to your problem is likely to be in the system documentation
...
After a while, you will get to know the most common
options to the common commands, but you will still need the documentation as a primary source of
information
...

3
...
2
...
3
...
A useful option is recursive copy (copy all
underlying files and subdirectories), using the -R option to cp
...
About files and the file system

52

Introduction to Linux
As an example the case of user newguy, who wants the same Gnome desktop settings user oldguy has
...
/oldguy/
...


This gives some errors involving file permissions, but all the errors have to do with private files that newguy
doesn't need anyway
...

3
...
2
...
4
...
(Use ls -a to check whether
a directory is empty or not)
...

How empty can a directory be?
It is normal that the directories
...
(dot-dot) can't be removed, since they are also necessary in
an empty directory to determine the directories ranking in the file system hierarchy
...
So once removed, a file is really gone, and there is generally no way to get it back
unless you have backups, or you are really fast and have a real good system administrator
...
In that case the system won't immediately act upon request
...
tar'? y
rm: remove directory `archive/backup'? y
rm: remove directory `archive'? y

We will discuss how to make this option the default in Chapter 7, which discusses customizing your shell
environment
...
3
...
Finding files
3
...
3
...
Using shell features
In the example on moving files we already saw how the shell can manipulate multiple files at once
...
The shell can substitute ranges of numbers and upper or lower case characters alike
...

All sorts of substitutions can be used simultaneously; the shell is very logical about it
...

In other shells, the asterisk is commonly used to minimize the efforts of typing: people would enter cd dir*
instead of cd directory
...
It means that you can type the first few characters of a command (anywhere) or a file
(in the current directory) and if no confusion is possible, the shell will find out what you mean
...
About files and the file system

53

Introduction to Linux
in a directory containing many files, you can check if there are any files beginning with the letter A just by
typing ls A and pressing the Tab key twice, rather than pressing Enter
...

3
...
3
...
Which
A very simple way of looking up files is using the which command, to look in the directories listed in the
user's search path for the required file
...
The which command is useful when
troubleshooting "Command not Found" problems
...
The problem is similar to the
PATH problem in the previous part: Tina's colleague tells her that he can see the required program in
/opt/acroread/bin, but this directory is not in her path:
tina:~> which acroread
/usr/bin/which: no acroread in (/bin:/usr/bin:/usr/bin/X11)

The problem can be solved by giving the full path to the command to run, or by re-exporting the content of the
PATH variable:
tina:~> export PATH=$PATH:/opt/acroread/bin
tina:~> echo $PATH
/bin:/usr/bin:/usr/bin/X11:/opt/acroread/bin

Using the which command also checks to see if a command is an alias for another command:
gerrit:~> which -a ls
ls is aliased to `ls -F --color=auto'
ls is /bin/ls

If this does not work on your system, use the alias command:
tille@www:~/mail$ alias ls
alias ls='ls --color'

3
...
3
...
Find and locate
These are the real tools, used when searching other paths beside those listed in the search path
...
GNU
find, however, deals with the syntax problems
...
The most common use
is for finding file names:
find -name
This can be interpreted as "Look in all files and subdirectories contained in a given path, and print the names
of the files containing the search string in their name" (not in their content)
...
-size +5000k
psychotic_chaos
...
About files and the file system

54

Introduction to Linux
If you dig in the man pages, you will see that find can also perform operations on the found files
...
It is best to first test without the -exec option that the correct files are selected,
after that the command can be rerun to delete the selected files
...
tmp:
peter:~>

find
...
tmp" -exec rm {} \;

peter:~>

Optimize!
This command will call on rm as many times as a file answering the requirements is found
...
This is quite a load on your system
...
This way, the rm command is only called when the command line is full, instead of for every
file
...

Later on (in 1999 according to the man pages, after 20 years of find), locate was developed
...
On the other hand, a search in the locate database uses less resources than find and
therefore shows the results nearly instantly
...
The files in root's home directory are such an
example, these are not normally accessible to the public
...
cshrc, to display all users who have a customized configuration
file for the C shell
...
cshrc will be displayed, and not the one in root's home directory
...
png
/usr/share/icons/hicolor/32x32/apps/acroread
...
png
/usr/share/icons/locolor/32x32/apps/acroread
...

There are three possibilities left
...
/Acrobat4/bin/acroread
tina:~> file /usr/local/Acrobat4/bin/acroread
/usr/local/Acrobat4/bin/acroread: Bourne shell script text executable
tina:~> file /usr/local/Acrobat4/Reader/intellinux/bin/acroread
/usr/local/Acrobat4/Reader/intellinux/bin/acroread: ELF 32-bit LSB
executable, Intel 80386, version 1, dynamically linked (uses

Chapter 3
...

Again, a description of the full features of find and locate can be found in the Info pages
...
3
...
4
...
3
...
4
...
General line filtering

A simple but powerful program, grep is used for filtering input lines and returning certain patterns to the
output
...
In the example below, jerry uses
grep to see how he did the thing with find:
jerry:~> grep -a find
...
-name userinfo
man find
find
...
cfg

Search history
Also useful in these cases is the search function in bash, activated by pressing Ctrl+R at once, such as
in the example where we want to check how we did that last find again:
thomas ~> ^R
(reverse-i-search)`find': find `/home/thomas` -name *
...
The more characters you type, the more restricted the
search gets
...
bash_history in your home directory when you quit that session)
...
If you want to see previous commands containing the same string, type
Ctrl+R again
...

All UNIXes with just a little bit of decency have an online dictionary
...
The dictionary is a list
of known words in a file named words, located in /usr/share/dict
...
word list
Some distributions offer the dict command, which offers more features than simply searching words in a
list
...
About files and the file system

56

Introduction to Linux
And what was the E-mail address of Arno again?
serge:~/mail> grep -i arno *
sent-mail: To: ...
com>
sent-mail: On Mon, 24 Dec 2001, Arno
...
com wrote:

find and locate are often used in combination with grep to define some serious queries
...

3
...
3
...
2
...
The escape character in Bash is
backslash, as in most shells; this takes away the special meaning of the following character
...
, ? and *
...

For instance, say that you want to display the file "*" instead of all the files in a directory, you would have to
use
less \*
The same goes for filenames containing a space:
cat This\ File

3
...
4
...
3
...
1
...

The easiest way of course would be to use graphical tools instead of command line tools
...
org
...
for all kinds of office applications and so on
...

Instead we keep concentrating on shell- or text-mode applications, which form the basics for all other
applications
...
When in doubt, check
first using the file command
...

Font problems
Plain text tools such as the ones we will now be discussing, often have problems with "plain" text files
because of the font encoding used in those files
...

Chapter 3
...
4
...
3
...
2
...
A
little bit of UNIX history explains this:
• First there was cat
...

• Then there was pg, which may still be found on older UNIXes
...

• The more program was a revised version of pg
...

• less is the GNU version of more and has extra features allowing highlighting of search strings,
scrolling back etc
...

You already know about pagers by now, because they are used for viewing the man pages
...
3
...
3
...
To see the last ten commands entered:
tony:~> tail -10
...
The tail command has a handy feature to continuously show the last n lines of a file
that changes all the time
...
More
information is located in the system documentation files
...
3
...
Linking files
3
...
5
...
Link types
Since we know more about files and their representation in the file system, understanding links (or shortcuts)
is a piece of cake
...
There are two ways to achieve this:
• Hard link: Associate two or more file names with the same inode
...


Chapter 3
...

• Soft link or symbolic link (or for short: symlink): a small file that is a pointer to another file
...
Since
inodes are not used in this system, soft links can span across partitions
...
Hard and soft link mechanism

Note that removing the target file for a symbolic link makes the link useless
...
Hardlinks can not span across partitions, since they refer to inodes,
and inode numbers are only unique within a given partition
...
These are files containing meta-data which can only be interpreted by the graphical file manager
...
They may end in a
...
lnk suffix; an example
can be found in ~/
...
gnome-desktop]$ cat La\ Maison\ Dupont
[Desktop Entry]
Encoding=Legacy-Mixed
Name=La Maison Dupont
Type=X-nautilus-home
X-Nautilus-Icon=temp-home
URL=file:///home/dupont

This example is from a KDE desktop:
Chapter 3
...
Should you need
help, your system documentation should be your first resort
...

3
...
5
...
Creating symbolic links
The symbolic link is particularly interesting for beginning users: they are fairly obvious to see and you don't
need to worry about partitions
...
In order to create symlinks, you need to use the -s option:
ln -s targetfile linkname
In the example below, user freddy creates a link in a subdirectory of his home directory to a directory on
another part of the system:
freddy:~/music> ln -s /opt/mp3/Queen/ Queen
freddy:~/music> ls -l
lrwxrwxrwx 1 freddy freddy

17 Jan 22 11:07 Queen -> /opt/mp3/Queen

Symbolic links are always very small files, while hard links have the same size as the original file
...
They are often used to save disk space, to make a copy of a
file in order to satisfy installation requirements of a new program that expects the file to be in another
location, they are used to fix scripts that suddenly have to run in a new environment and can generally save a
lot of work
...


3
...
File security
3
...
1
...
On a Linux system, every file is owned by a
user and a group user
...
For each category of users, read, write and execute permissions can be
granted or denied
...
This
command also displays file permissions for these three user categories; they are indicated by the nine
characters that follow the first character, which is the file type indicator at the beginning of the file properties
Chapter 3
...
As seen in the examples below, the first three characters in this series of nine display access rights for the
actual user that owns the file
...

The permissions are always in the same order: read, write, execute for the user, the group and the others
...
Users with user name marise or users belonging to the group users
can read and write (change/move/delete) the file, but they can't execute it (second and third dash)
...

The second example is an executable file, the difference: everybody can run this program, but you need to be
root to change it
...

For easy use with commands, both access rights or modes and user groups have a code
...


Table 3-7
...

read access is granted to the user category defined in this place
write permission is granted to the user category defined in this place
execute permission is granted to the user category defined in this place

Table 3-8
...
Among other functions, the security scheme takes care of user access to programs, it can
serve files on a need-to-know basis and protect sensitive data such as home directories and system
configuration files
...
If you don't, it can be displayed using the id command, which also
displays the default group you belong to and eventually other groups of which you are a member:
tilly:~> id
uid=504(tilly) gid=504(tilly) groups=504(tilly),100(users),2051(org)

Your user name is also stored in the environment variable USER:
tilly:~> echo $USER
tilly

Chapter 3
...
4
...
The tools
3
...
2
...
The chmod command
A normal consequence of applying strict file permissions, and sometimes a nuisance, is that access rights will
need to be changed for all kinds of reasons
...
The
chmod command can be used with alphanumeric or numeric options, whatever you like best
...
/hello
bash:
...
/hello
Hello, World
asim:~> ls -l hello
-rwxrw-r-1 asim

asim

32 Jan 15 16:29 hello*

The + and - operators are used to grant or deny a given right to a given group
...
The Info and man pages contain useful examples
...
Also, comments like, "It worked yesterday," and "When I run this as
root it works," are most likely caused by the wrong file permissions
...
Thus we get a 3-digit number, which is the symbolic value for the settings chmod has to
make
...
File protection with chmod
Command
chmod 400 file
chmod 500
directory

Meaning
To protect a file against accidental overwriting
...


Chapter 3
...

A publicly readable file that can only be changed by the issuing user
...

Protects a file against any access from other users, while the issuing user still has
chmod 700 file
full access
...

chmod 775 file
Standard file sharing mode for a group
...

If you enter a number with less than three digits as an argument to chmod, omitted characters are replaced
with zeros starting from the left
...
Everything about these and many more are located in the Info pages
...
4
...
2
...

However, on many Linux systems you can only be actively logged in to one group at the time
...
The fourth field of this
file holds users' primary group ID, which is looked up in the /etc/group file
...
From /etc/group we can get the name matching this group ID
...

User private group scheme
In order to allow more flexibility, most Linux systems follow the so-called user private group
scheme, that assigns each user primarily to his or her own group
...
Usually this group has the same name
as the user login name, which can be a bit confusing
...
Because these are
secondary groups to this user, he will need to use the newgrp to log into any of these groups (use gpasswd for
setting the group password first)
...

asim:/var/www/html> newgrp web
asim:/var/www/html> id
uid=501(asim) gid=3400(web) groups=100(users),501(asim),3400(web)

When asim creates new files now, they will be in group ownership of the group web instead of being owned
by the group asim:

Chapter 3
...
4
...
4) or calling your
system administrator to change ownerships for you
...

3
...
2
...
The file mask
When a new file is saved somewhere, it is first subjected to the standard security procedure
...
The standard file permission is determined by the mask for new file creation
...
In the example above, however, we see 4
values displayed, yet there are only 3 permission categories: user, group and other
...
4
...
4 and Section 4
...
6
...

Each UNIX-like system has a system function for creating new files, which is called each time a user uses a
program that creates new files, for instance, when downloading a file from the Internet, when saving a new
text document and so on
...
Full read, write and
execute permission is granted to everybody when creating a new directory
...
This, before the mask is applied, a directory has permissions 777 or rwxrwxrwx, a plain file 666 or
rw-rw-rw-
...
Thus, a directory will have permissions of 775 by default, a file 664, if the mask value is (0)002
...
If it wouldn't
have that, it would not be accessible
...
Thus, if it is set to
002, files and directories that you create while being in the new group will also be accessible to the other
members of that group; you don't have to use chmod
...
About files and the file system

64

Introduction to Linux
The root user usually has stricter default file creation permissions:
[root@estoban root]# umask
022

These defaults are set system-wide in the shell resource configuration files, for instance /etc/bashrc or
/etc/profile
...

3
...
2
...
Changing user and group ownership
When a file is owned by the wrong user or group, the error can be repaired with the chown (change owner)
and chgrp (change group) commands
...
Both commands are very flexible, as you can find out
by using the --help option
...
Of course the system will check if the user issuing one of these commands has
sufficient permissions on the file(s) she wants to change
...
On a Linux system, each user has his own group, so this form
can be used to make files private:
jacky:~> id
uid=1304(jacky) gid=(1304) groups=1304(jacky),2034(pproject)
jacky:~> ls -l my_report
-rw-rw-r-- 1 jacky
project

29387 Jan 15 09:34 my_report

jacky:~> chown jacky: my_report
jacky:~> chmod o-r my_report
jacky:~> ls -l my_report
-rw-rw---- 1 jacky
jacky

29387 Jan 15 09:34 my_report

If jacky would like to share this file, without having to give everybody permission to write it, he can use the
chgrp command:
jacky:~> ls -l report-20020115
...
xls
jacky:~> chgrp project report-20020115
...
xls
jacky:~> ls -l report-20020115
...
xls

This way, users in the group project will be able to work on this file
...


Chapter 3
...
In that case, all
underlying files and subdirectories of a given directory will belong to the given user and/or group
...
If
you are not the administrator of the system, you can not change user nor group ownerships for security
reasons
...

3
...
2
...
Special modes
For the system admin to not be bothered solving permission problems all the time, special access rights can be
given to entire directories, or to separate programs
...
Originally this
was a feature used a lot to save memory: big jobs are loaded into memory only once
...
When applied to an entire directory, however, the sticky bit has
a different meaning
...
This feature is used on directories like
/var/tmp, that have to be accessible for everyone, but where it is not appropriate for users to
change or delete each other's data
...
The historic origin of the "t" is in
UNIX' save Text access feature
...
When this mode is set on an executable file, it will run with the user and group
permissions on the file instead of with those of the user issuing the command, thus giving access to
system resources
...

• SGID (set group ID) on a directory: in this special case every file created in the directory will have
the same group owner as the directory itself (while normal behavior would be that new files are
owned by the users who create them)
...
doc

This is the standard way of sharing files in UNIX
...
This may be confusing
...
About files and the file system

66

Introduction to Linux

3
...
Summary
On UNIX, as on Linux, all entities are in some way or another presented to the system as files with the
appropriate file properties
...

We've made our first steps toward becoming an expert: we discussed the real and the fake structure of the file
system, and we know about the Linux file security model, as well as several other security precautions that are
taken on every system by default
...
We learned several shell commands in
this chapter, which are listed in the table below
...
New commands in chapter 3: Files and the file system
Command
bash
cat file(s)
cd directory
chgrp newgroup file(s)
chmod mode file(s)
chown newowner[:[newgroup]] file(s)
cp sourcefile targetfile
df file
echo string
export
file filename
find path expression
grep PATTERN file
head file
id
info command
less file
ln targetfile linkname
locate searchstring
ls file(s)
man command
mkdir newdir
mv oldfile newfile
newgrp groupname
pwd
Chapter 3
...

Send content of file(s) to standard output
...
cd is a bash built-in command
...

Copy sourcefile to targetfile
...

Display a line of text
Part of bash that announces variables and their values
to the system
...

Find files in the file system hierarchy
Print lines in file containing the search pattern
...

Read documentation about command
...

Make a link with name linkname to targetfile
...

Prints directory content
...

Make a new empty directory
...

Log in to a new group
...

67

Introduction to Linux
quota
Show disk usage and limits
...

rmdir file
Removes directories
...

umask [value]
Show or change new file creation mode
...

which command
Shows the full path to command
...
This documentation is your first-aid kit
and contains the answers to many questions
...
Reading the documentation will
give you the control you need
...
File permissions
Who\What
u(ser)
g(roup)
o(ther)

r(ead)
4
4
4

w(rite)
2
2
2

(e)x(ecute)
1
1
1

3
...
Exercises
Just login with your common user ID
...
6
...
Partitions
• On which partition is your home directory?
• How many partitions are on your system?
• What is the total size of your Linux installation?

3
...
2
...

• Export a senseless path by entering, for instance, export PATH=blah and try listing directory
content
...

• Now go to share in /usr using only one command
...
What is your present working
directory?

Chapter 3
...
6
...
Tour of the system
• Change to the /proc directory
...
d | /etc/init
...

• What services should be running in this level?
• Which services run in graphical mode that don't run in text mode?
• Change to /etc
• How long does the system keep the log file in which user logins are monitored?
• Which release are you running?
• Are there any issues or messages of the day?
• How many users are defined on your system? Don't count them, let the computer do it for you!
• How many groups?
• Where is the time zone information kept?
• Are the HOWTOs installed on your system?
• Change to /usr/share/doc
...

• Which version of bash is installed on this system?

3
...
4
...

• Can you move this directory to the same level as your home directory?
• Copy all XPM files from /usr/share/pixmaps to the new directory
...

• Change to your home directory
...
Make sure that you also copy the files and directories which are in the subdirectories of /etc!
(recursive copy)
• Change into the new directory and make a directory for files starting with an upper case character and
one for files starting with a lower case character
...
Use
as few commands as possible
...

• Delete the directory and its entire content using a single command
...

• Where is the sendmail server program?
• Make a symbolic link in your home directory to /var/tmp
...

• Make another symbolic link in your home directory to this link
...
Remove the first
link and list directory content
...
6
...
File permissions
• Can you change file permissions on /home?
• What is your standard file creation mode?
• Change ownership of /etc to your own user and group
...
About files and the file system

69

Introduction to Linux
• Change file permissions of ~/
...

• Issue the command locate root
...
Can it be used?

Chapter 3
...
Processes
Next to files, processes are the most important things on a UNIX/Linux system
...
We will learn more about:
♦ Multi-user processing and multi-tasking
♦ Process types
♦ Controlling processes with different signals
♦ Process attributes
♦ The life cycle of a process
♦ System startup and shutdown
♦ SUID and SGID
♦ System speed and response
♦ Scheduling processes
♦ The Vixie cron system
♦ How to get the most out of your system

4
...
Processes inside out
4
...
1
...
Not every command starts a single process
...

Furthermore, Linux is based on UNIX, where it has been common policy to have multiple users running
multiple commands, at the same time and on the same system
...
In some cases, processes will have to continue to run even when the user who started them
logs out
...

We will explain the structure of Linux processes in the next sections
...
1
...
Process types
4
...
2
...
Interactive processes
Interactive processes are initialized and controlled through a terminal session
...
These processes can run in the foreground, occupying the terminal that started the program,
and you can't start other applications as long as this process is running in the foreground
...
Until now, we mainly focussed on programs running in the foreground - the
length of time taken to run them was too short to notice - but viewing a file with the less command is a good
example of a command occupying the terminal session
...
The program is still connected to the terminal from where it was started, and the terminal is
only useful for entering commands this program can understand
...
Processes

71

Introduction to Linux
unresponsiveness of the system
...

The shell offers a feature called job control which allows easy handling of multiple processes
...
Using this system, programs can
also be started in the background immediately
...

Putting a job in the background is typically done when execution of a job is expected to take a long time
...
In the example,
using graphical mode, we open an extra terminal window from the existing one:
billy:~> xterm &
[1] 26558
billy:~> jobs
[1]+ Running

xterm &

The full job control features are explained in detail in the bash Info pages, so only the frequently used job
control applications are listed here:

Table 4-1
...

Run this command in the background (release the terminal)
Show commands running in the background
...

Interrupt (terminate and quit) a process running in the foreground
...
By using the %
%n
expression a job can be referred to using its number, for instance fg %2
...

fg
Puts the job back in the foreground
...

Most UNIX systems are likely to be able to run screen, which is useful when you actually want another shell
to execute commands
...
In this new session you may do whatever it is
you want to do
...
You can then detach
this session, while the programs you started in it continue to run, even when you log out of the originating
shell, and pick your screen up again any time you like
...
To addicts, it still has meaning in Linux, even though we've had virtual consoles
for almost ten years
...
Processes

72

Introduction to Linux
4
...
2
...
Automatic processes
Automatic or batch processes are not connected to a terminal
...
Such tasks can be executed
using one of two criteria:
• At a certain date and time: done using the at command, which we will discuss in the second part of
this chapter
...
By default, tasks are put in a queue where they wait to be executed until the system load is
lower than 0
...
In large environments, the system administrator may prefer batch processing when
large amounts of data have to be processed or when tasks demanding a lot of system resources have to
be executed on an already loaded system
...

4
...
2
...
Daemons
Daemons are server processes that run continuously
...
A typical example is the networking daemon,
xinetd, which is started in almost every boot procedure
...


4
...
3
...

• The parent process ID or PPID: the number of the process (PID) that started this process
...

• Terminal or TTY: terminal to which the process is connected
...
The real owner
is the user issuing the command, the effective user is the one determining access to system resources
...
An example to clarify this: the browser mozilla in /usr/bin is owned by user root:
theo:~> ls -l /usr/bin/mozilla
-rwxr-xr-x 1 root
root
4996 Nov 20 18:28 /usr/bin/mozilla*
theo:~> mozilla &
[1] 26595
theo:~> ps -af
UID
PID PPID C STIME TTY
TIME CMD
theo 26601 26599 0 15:04 pts/5 00:00:00 /usr/lib/mozilla/mozilla-bin
theo 26613 26569 0 15:04 pts/5 00:00:00 ps -af

When user theo starts this program, the process itself and all processes started by the initial process,
will be owned by user theo and not by the system administrator
...

• Real and effective group owner (RGID and EGID): The real group owner of a process is the primary
group of the user who started the process
...

Chapter 4
...
1
...
Displaying process information
The ps command is one of the tools for visualizing processes
...

With no options specified, ps only gives information about the current shell and eventual processes:
theo:~> ps
PID TTY
4245 pts/7
5314 pts/7

TIME CMD
00:00:00 bash
00:00:00 ps

Since this does not give enough information - generally, at least a hundred processes are running on your
system - we will usually select particular processes out of the list of all processes, using the grep command in
a pipe, see Section 5
...
2
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
If you don't want this to happen, use the pgrep command
...
Such login shells are preceded
with a dash (-)
...

More info can be found the usual way: ps --help or man ps
...

Note that ps only gives a momentary state of the active processes, it is a one-time recording
...
21, 0
...
03
89 processes: 86 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: 2
...
7% system, 0
...
6% idle

Chapter 4
...
9 6
...
1 0
...
5 1
...
5 14
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
0 0
...
01, 0
...
00

The data for these programs is stored among others in /var/run/utmp (information about currently
connected users) and in the virtual file system /proc, for example /proc/loadavg (average load
information)
...
Over at FreshMeat and SourceForge you will find tens of applications that centralize this
information along with other server data and logs from multiple servers on one (web) server, allowing
monitoring of the entire IT infrastructure from one workstation
...
Processes

75

Introduction to Linux
|-3*[kdeinit]
|-keventd
|-khubd
|-5*[kjournald]
|-klogd
|-lockd---rpciod
|-lpd
|-mdrecoveryd
|-6*[mingetty]
|-8*[nfsd]
|-nscd---nscd---5*[nscd]
|-ntpd
|-3*[oafd]
|-panel
|-portmap
|-rhnsd
|-rpc
...
rquotad
|-rpc
...
For more options and what they do, refer to the Info
pages
...


4
...
5
...
1
...
1
...
This child process has the
same environment as its parent, only the process ID number is different
...

After the forking process, the address space of the child process is overwritten with the new process data
...

The fork-and-exec mechanism thus switches an old command with a new, while the environment in which the
new program is executed remains the same, including configuration of input and output devices, environment
variables and priority
...
Even the first process, init, with process ID 1, is forked during the boot procedure in the
so-called bootstrapping procedure
...
The process ID changes after the fork procedure:

Figure 4-1
...
Processes

76

Introduction to Linux

There are a couple of cases in which init becomes the parent of a process, while the process was not started by
init, as we already saw in the pstree example
...
A window manager is a typical
example; it starts an xterm process that generates a shell that accepts commands
...
Using this mechanism, it is possible to
change window managers without interrupting running applications
...
In an exceptional case, a process might finish
while the parent does not wait for the completion of this process
...

4
...
5
...
Ending processes
When a process ends normally (it is not killed or otherwise unexpectedly interrupted), the program returns its
exit status to the parent
...
The system of returning information upon executing a job has its origin in the C
programming language in which UNIX has been written
...
The values of the return codes are
program-specific
...
Another example is the Bash builtin command true, which does nothing except
return an exit status of 0, meaning success
...
Processes

77

Introduction to Linux
4
...
5
...
Signals
Processes end because they receive a signal
...
Use the
kill command to send a signal to a process
...
Most signals are for
internal use by the system, or for programmers when they write code
...
Common signals
Signal name
SIGTERM

Signal number
15

Meaning
Terminate the process in an orderly way
...
A process can ignore this
SIGINT
2
signal
...
A process can not ignore
SIGKILL
9
this signal
...

You can read more about default actions that are taken when sending a signal to a process in man 7 signal
...
1
...
SUID and SGID
As promised in the previous chapter, we will now discuss the special modes SUID and SGID in more detail
...
In the ideal situation special modes
are used as sparsely as possible, since they include security risks
...
The Linux ps version, for example, uses the information stored in the /proc
file system, which is accessible to everyone, thus avoiding exposition of sensitive system data and resources
to the general public
...

While we generally try to avoid applying any special modes, it is sometimes necessary to use an SUID
...
Of course users will want to do this themselves instead of
having their password set by the system administrator
...
This is achieved by giving the passwd
program special permissions:
mia:~> which passwd
passwd is /usr/bin/passwd

Chapter 4
...

SGID modes on a file don't occur nearly as frequently as SUID, because SGID often involves the creation of
extra groups
...
This is the case
for the write and wall programs, which are used to send messages to other users' terminals (ttys)
...

Sending text to another user's terminal or graphical display is normally not allowed
...
When the write and wall commands are
granted SGID permissions, the commands will run using the access rights as applicable to this group, tty in
the example
...

In the example below, user joe first finds out on which terminal his correspondent is connected, using the who
command
...
Also illustrated are the access rights on the
write program and on the terminals occupied by the receiving user: it is clear that others than the user owner
have no permissions on the device, except for the group owner, which can write to it
...
callhost
...
callhost
...

hey Jenny, shall we have lunch together?
EOF

After receiving a message, the terminal can be cleared using the Ctrl+L key combination
...
To see which connected
users accept messages from others use who -w
...

Group names may vary
The group scheme is specific to the distribution
...

Chapter 4
...
2
...
2
...
Introduction
One of the most powerful aspects of Linux concerns its open method of starting and stopping the operating
system, where it loads specified programs using their particular configurations, permits you to change those
configurations to control the boot process, and shuts down in a graceful and organized way
...
A basic understanding of this process is quite beneficial to everybody who uses a Linux system
...
We will only discuss
GRUB, however, which is easier to use and more flexible
...
Both systems support dual boot installations, we refer to the HOWTOs on this
subject for practical examples and background information
...
2
...
The boot process
When an x86 computer is booted, the processor looks at the end of the system memory for the BIOS (Basic
Input/Output System) and runs it
...
The BIOS provides the lowest level interface to peripheral devices and controls the
first step of the boot process
...
Usually it checks the floppy drive (or CD-ROM drive on many newer systems) for bootable media, if
present, and then it looks to the hard drive
...
Once Linux is installed on the hard drive of a system, the BIOS looks
for a Master Boot Record (MBR) starting at the first sector on the first hard drive, loads its contents into
memory, then passes control to it
...
The MBR then loads the boot-loader, which takes over the process (if the boot-loader is
installed in the MBR)
...
Once GRUB has received the correct instructions for the operating system to
start, either from its command line or configuration file, it finds the necessary boot file and hands off control
of the machine to that operating system
...
2
...
GRUB features
This boot method is called direct loading because instructions are used to directly load the operating system,
with no intermediary code between the boot-loaders and the operating system's main files (such as the kernel)
...
For example,
Microsoft's DOS and Windows operating systems completely overwrite anything on the MBR when they are
installed without incorporating any of the current MBR's configuration
...
The Microsoft operating systems, as well as
various other proprietary operating systems, are loaded using a chain loading boot method
...
Processes

80

Introduction to Linux
necessary to actually boot that operating system
...

GRUB contains a number of other features; the most important include:
• GRUB provides a true command-based, pre-OS environment on x86 machines to allow maximum
flexibility in loading operating systems with certain options or gathering information about the
system
...
Before LBA, hard drives could encounter a 1024-cylinder limit, where the BIOS could not
find a file after that point
...

A full description of GRUB may be found by issuing the info grub command or at the GRUB site
...


4
...
4
...

When init starts, it becomes the parent or grandparent of all of the processes that start up automatically on
your Linux system
...
This instructs
init to read an initial configuration script for the environment, which sets the path, starts swapping, checks the
file systems, and so on
...

Then init continues to read the /etc/inittab file, which describes how the system should be set up in
each run level and sets the default run level
...
All UNIX-like
systems can be run in different process configurations, such as the single user mode, which is referred to as
run level 1 or run level S (or s)
...
It is
used to perform maintenance tasks without risks of damaging the system or user data
...
Another run level is the reboot
run level, or run level 6, which shuts down all running services according to the appropriate procedures and
then restarts the system
...
2
...

After having determined the default run level for your system, init starts all of the background processes
necessary for the system to run by looking in the appropriate rc directory for that run level
...
It then runs all of the start scripts (their
file names start with an S) in the appropriate run level directory so that all services and applications are started
correctly
...
d/httpd stop or service httpd stop logged in as root, in this case stopping the
Chapter 4
...

Special case
Note that on system startup, the scripts in rc2
...
d are usually executed
...
There are only services that are started
...
d
...
d are symbolic links that point to the actual scripts located in /etc/init
...
A
symbolic link is nothing more than a file that points to another file, and is used in this case because it can be
created and deleted without affecting the actual scripts that kill or start the services
...
You can change the order in
which the services start up or are killed by changing the name of the symbolic link that refers to the script that
actually controls the service
...
d, where crond and xfs are both started from a linkname starting with "S90"
...

[jean@blub /etc/rc5
...
getty opens tty lines, sets their
modes, prints the login prompt, gets the user's name, and then initiates a login process for that user
...
By default, most systems offer 6 virtual
consoles, but as you can see from the inittab file, this is configurable
...
As
the system should be properly shut down and restarted rather than immediately power-cycled, init is told to
execute the command /sbin/shutdown -t3 -r now, for instance, when a user hits those keys
...

On most RPM-based systems the graphical login screen is started in run level 5, where /etc/inittab runs
a script called /etc/X11/prefdm
...
This is typically gdm if you run GNOME or kdm
if you run KDE, but they can be mixed, and there's also the xdm that comes with a standard X installation
...
On Debian, for instance, there is an initscript for each of the display
managers, and the content of the /etc/X11/default-display-manager is used to determine which
one to start
...
3
...

The /etc/default and/or /etc/sysconfig directories contain entries for a range of functions and
services, these are all read at boot time
...


Chapter 4
...
But if all goes well, you
should be looking at a login prompt or login screen when the boot process has finished
...
Startup procedures may vary on other
architectures and distributions
...
d directories
...
d/init
...
d
...
2
...
Init run levels
The idea behind operating different services at different run levels essentially revolves around the fact that
different systems can be used in different ways
...

There are times in which you may want to operate the system in a lower mode
...
In these cases, running services that depend upon a higher system mode
to function does not make sense because they will not work correctly anyway
...

Available run levels are generally described in /etc/inittab, which is partially shown below:
#
# inittab
#

This file describes how the INIT process should set up
the system in a certain run-level
...
The run levels are:
#
0 - halt (Do NOT set initdefault to this)
#
1 - Single user mode
#
2 - Multiuser, without NFS
#
(The same as 3, if you do not have networking)
#
3 - Full multiuser mode
#
4 - unused
#
5 - X11
#
6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
<--cut-->

Feel free to configure unused run levels (commonly run level 4) as you see fit
...

This allows them to quickly move in and out of their custom configuration without disturbing the normal set
of features at the standard run levels
...

No graphics?
When you are working in text mode because you didn't get presented a graphical login screen on the
console of your machine, you can normally switch to console 7 or up to have a graphical login
...
Processes

83

Introduction to Linux
not the case, check the current run level using the command who -r
...
Contact your system administrator or read man init in that case
...

The discussion of run levels, scripts and configurations in this guide tries to be as general as possible
...
For instance, Gentoo Linux stores scripts in /etc/run levels
...
Refer to your system documentation for more information
...

4
...
5
...
Tools
The chkconfig or update-rc
...
d directory hierarchy
...
d
...
On SuSE Linux, you will find the yast and insserv
tools
...
In Mandriva this became the Mandriva Linux Control Center
...

All of these utilities must be run as root
...


4
...
6
...
After completing
the shutdown procedure, the -h option will halt the system, while -r will reboot it
...

If your computer does not power itself down, you should not turn off the computer until you see a message
indicating that the system is halted or finished shutting down, in order to give the system the time to unmount
all partitions
...


4
...
Managing processes
4
...
1
...

Chapter 4
...
Instead, we will study the daily problems a common user is
confronted with, and actions such a user can take to optimally use the resources available
...


Figure 4-2
...
3
...
How long does it take?
Bash offers a built-in time command that displays how long a command takes to execute
...
In the example below, it takes about a minute and a half to make
this book:
tilly:~/xml/src> time make
Output written on abook
...

Transcript written on abook
...

real
user
sys

1m41
...
190s
0m1
...
Processes

85

Introduction to Linux
The GNU time command in /usr/bin (as opposed to the shell built-in version) displays more information
that can be formatted in different ways
...
The same command as the above using the independent time gives this output:
tilly:~/xml/src> /usr/bin/time make
Output written on abook
...

Transcript written on abook
...

Command exited with non-zero status 2
88
...
74system 1:36
...


4
...
3
...
To a system manager, on the other hand, it
means much more: the system admin has to optimize system performance for the whole system, including
users, all programs and daemons
...

• reachability of remote systems (network performance)
• amount of users on the system, amount of users actually working simultaneously
• time of day

...
3
...
Load
In short: the load depends on what is normal for your system
...
Some (multi-CPU) systems I've seen were quite happy with a
load of 67
...
If
you don't, you will only be able to measure system load from the response time of the command line, which is
a very rough measurement since this speed is influenced by a hundred other factors
...
For example, a system
with a graphics card supporting hardware acceleration will have no problem rendering 3D images, while the
same system with a cheap VGA card will slow down tremendously while rendering
...


4
...
5
...
If you have lots of environment variables set (instead of shell
variables), long search paths that are not optimized (errors in setting the path environment variable) and more
of those settings that are usually made "on the fly", the system will need more time to search and read data
...
A really fancy desktop comes with
a price, even when you can download it for free, since most desktops provide add-ons ad infinitum
...
Processes

86

Introduction to Linux
is a virtue if you don't buy a new computer every year
...
3
...
1
...
A program with a high nice number is
friendly to other programs, other users and the system; it is not an important job
...

Making a job nicer by increasing its nice number is only useful for processes that use a lot of CPU time
(compilers, math applications and the like)
...

Defining the priority of a program is done with the nice command
...
Again, read the man page for your system-specific information
...

Use of these commands is usually a task for the system administrator
...

4
...
5
...
CPU resources
On every Linux system, many programs want to use the CPU(s) at the same time, even if you are the only
user on the system
...
There may be times
when there are not enough cycles because the CPU is too busy
...
There are some actions
you can undertake if you think your CPU is to blame for the unresponsiveness of your system:
• Run heavy programs when the load is low
...
See
next section for scheduling
...

• Run big jobs with a low priority
If none of these solutions are an option in your particular situation, you may want to upgrade your CPU
...

4
...
5
...
Memory resources
When the currently running processes expect more memory than the system has physically available, a Linux
system will not crash; it will start paging, or swapping, meaning the process uses the memory on disk or in
swap space, moving contents of the physical memory (pieces of running programs or entire programs in the
case of swapping) to disk, thus reclaiming the physical memory to handle more processes
...
The top command can
be used to display memory and swap use
...

Chapter 4
...

• Tuning system performance, which is beyond the scope of this document
...

4
...
5
...
I/O resources
While I/O limitations are a major cause of stress for system admins, the Linux system offers rather poor
utilities to measure I/O performance
...
Various graphical front-ends exist to put the output of these commands in a humanly
understandable form
...

Network I/O problems:
• Network overload:
The amount of data transported over the network is larger than the network's capacity, resulting in
slow execution of every network related task for all users
...

• Network integrity problems:
Occurs when data is transferred incorrectly
...

Disk I/O problems:
• per-process transfer rate too low:
Read or write speed for a single process is not sufficient
...

This kind of problem is more difficult to detect, and usually takes extra hardware in order to re-divide data
streams over buses, controllers and disks, if overloaded hardware is cause of the problem
...
This way, you get to keep the
same hardware
...

If overload is not the cause, maybe your hardware is gradually failing, or not well connected to the system
...


Chapter 4
...
3
...
5
...

• Users who run relatively few but large jobs: users running simulations, calculations, emulators or
other programs that eat a lot of memory, and usually these users have accompanying large data files
...

You can see that system requirements may vary for each class of users, and that it can be hard to satisfy
everyone
...

4
...
5
...
Graphical tools
For the graphical environment, there are a whole bunch of monitoring tools available
...
Gnome System Monitor

Chapter 4
...
xload is another small X application for monitoring system load
...
3
...
7
...
We already saw how you can display
processes and filter out processes that belong to a particular user, and what possible restrictions can occur
...
Make the process use less resources without interrupting it;
2
...

In the case that you want the process to continue to run, but you also want to give the other processes on the
system a chance, you can renice the process
...

Identify the process in the "NI" column, it will most likely have a negative priority
...
Then enter the nice value, for instance "20"
...

Examples of processes that you want to keep on running are emulators, virtual machines, compilers and so on
...
If you have the opportunity, first try to kill
the process softly, sending it the SIGTERM signal
...
4
...

Some processes are a little bit harder to get rid of
...
If that does not do the trick either, use the strongest signal, SIGKILL
...
4
...

If this only returns the grep process, you can be sure that you succeeded in stopping the process
...
And that is a good thing: if they would be easy to kill, you
woud loose your shell every time you type Ctrl-C on the command line accidentally, since this is equivalent
to sending a SIGINT
...
Processes

90

Introduction to Linux
UNIX without pipes is almost unthinkable
The usage of pipes (|) for using output of one command as input of another is explained in the next
chapter, Chapter 5
...
Just type the name of the command,
followed by an Enter and select the window of the application that you want to stop
...


4
...
Scheduling processes
4
...
1
...
Whether in an
office environment, a server room or at home, most Linux systems are just idling away during the morning,
the evening, the nights and weekends
...

There are three types of delayed execution:
• Waiting a little while and then resuming job execution, using the sleep command
...

• Running a command at a specified time, using the at command
...

• Regularly running a command on a monthly, weekly, daily or hourly basis, using the cron facilities
...


4
...
2
...
All sleep does is wait
...

So why does it exist? Some practical examples:
Somebody calls you on the phone, you say "Yes I'll be with you in half an hour" but you're about drowned in
work as it is and bound to forget your lunch:
(sleep 1800; echo "Lunch time
...

When you run a series of printouts of large files, but you want other users to be able to print in between:
lp lotoftext; sleep 900; lp hugefile; sleep 900; lp anotherlargefile
Chapter 4
...

Programmers often use the sleep command to halt script or program execution for a certain time
...
4
...
The at command
The at command executes commands at a given time, using your default shell unless you tell the command
otherwise (see the man page)
...

User steven does a strange thing here combining two commands; we will study this sort of practice in Chapter
5, Redirecting Input and Output
...
/configure; make
at>
job 2 at 2001-06-14 02:00

The -m option sends mail to the user when the job is done, or explains when a job can't be done
...
With the atrm command you can remove scheduled jobs if you change your mind
...
4
...
For example, jobs are often run at exactly 1 o'clock in the morning
(e
...
system indexing to update a standard locate database), so entering a time of 0100 may easily slow your
system down rather than fire it up
...
See the Info pages for more information
...
4
...
Cron and crontab
The cron system is managed by the cron daemon
...
Only the root user has access to the system crontabs,
while each user should only have access to his own crontabs
...

At system startup the cron daemon searches /var/spool/cron/ for crontab entries which are named after
accounts in /etc/passwd, it searches /etc/cron
...
It executes commands as the user who
owns the crontab file and mails any output of commands to the owner
...
Processes

92

Introduction to Linux
On systems using Vixie cron, jobs that occur hourly, daily, weekly and monthly are kept in separate
directories in /etc to keep an overview, as opposed to the standard UNIX cron function, where all tasks are
entered into one big file
...
hourly
# commands to execute every day
02 4 * * * root run-parts /etc/cron
...
weekly
commands to execute every month
42 4 1 * * root run-parts /etc/cron
...

Some variables are set, and after that there's the actual scheduling, one line per job, starting with 5 time and
date fields
...
An asterisk in these fields represents the total acceptable range for the field
...

Then comes the user who should run the processes which are listed in the last column
...
In these directories, the actual jobs to be executed at the scheduled time are
stored as shell scripts, like this little script that is run daily to update the database used by the locate
command:
billy@ahost cron
...
cron
#!/bin/sh
renice +19 -p $$ >/dev/null 2>&1
/usr/bin/updatedb -f "nfs,smbfs,ncpfs,proc,devpts" -e \
"/tmp,/var/tmp, /usr/tmp,/afs,/net"

Users are supposed to edit their crontabs in a safe way using the crontab -e command
...
The default editor is vi (see
Chapter 6, but you can use any text editor, such as gvim or gedit if you feel more comfortable with a GUI
editor
...

This crontab entry reminds billy to go to his sports club every Thursday night:
billy:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall
...
20264 installed on Sun Jul 20 22:35:14 2003)

Chapter 4
...
xml,v 1
...
You do not need to
restart the cron daemon for the changes to take effect
...
sh
<--write and quit-->
crontab: installing new crontab
billy:~>

The backup
...
See Section 7
...
5 for an introduction to shell
scripting
...
If no mail
service is configured, you might find the output of your commands in your local mailbox,
/var/spool/mail/, a plain text file
...
They are executed with the user's own
permissions by default
...
5
...

Execution speed of commands can depend on a thousand tiny things
...
Here's a list:

Table 4-3
...
Processes

Meaning
Queue jobs for later execution
...

Deletes jobs, determined by their job number
...

Maintain crontab files for individual users
...

Process control initialization
...

Terminate a process
...

Display network connections, routing tables, interface statistics, masquerade
connections and multicast memberships
...

Display processes
...

Display a tree of processes
...

Alter priority of running processes
...

Delay for a specified time
...

Display top CPU processes
...

Report virtual memory statistics
...

Send a message to everybody's terminals
...

Send a message to another user
...
6
...


4
...
1
...

• Run the ps command
...

• Run the command find /
...

• In graphical mode, start the xclock program in the foreground
...
Stop
the program using the kill command
...

• What does kill -9 -1 do?
• Open two terminals or terminal windows again and use write to send a message from one to the other
...
What does it tell?
• How long does it take to execute ls in the current directory?
• Based on process entries in /proc, owned by your UID, how would you work to find out which
processes these actually represent?
• How long has your system been running?
• Which is your current TTY?
• Name 3 processes that couldn't have had init as an initial parent
...
Explain why this is so
...


4
...
2
...

• Can you reboot the system as a normal user? Why is that?
• According to your current run level, name the steps that are taken during shutdown
...

Chapter 4
...

• Which kernel is currently load at startup?
• Suppose you have to start some exotic server at boot time
...
What do you have to do in order to have the service start up automatically in run level 4,
which you defined for this purpose only?

4
...
3
...

• Create an at job that copies all files in your home directory to /var/tmp within half an hour
...

• Make a cronjob that does this task every Monday to Friday during lunch
...

• Make a mistake in the crontab entry, like issuing the nonexistent command coppy instead of cp
...
Processes

96

Chapter 5
...
Topics include:
♦ Standard input, output and errors
♦ Redirection operators
♦ How to use output of one command as input for another
♦ How to put output of a command in a file for later referrence
♦ How to append output of multiple commands to a file
♦ Input redirection
♦ Handling standard error messages
♦ Combining redirection of input, output and error streams
♦ Output filters

5
...
Simple redirections
5
...
1
...
By
default, input is being given with the keyboard, and output is displayed on your screen
...

However, since Linux is a flexible system, these default settings don't necessarily have to be applied
...


5
...
2
...
1
...
1
...
This is known as redirecting output
...

As we saw before, the cat command concatenates files and puts them all together to the standard output
...

nancy:~> cat test1
some words
nancy:~> cat test2
some other words
nancy:~> cat test1 test2 > test3
nancy:~> cat test3
some words

Chapter 5
...
Many shells, including
Bash, have a built-in feature to protect you from that risk: noclobber
...
In Bash, you would want to add the set -o noclobber command to your
...

Redirecting "nothing" to an existing file is equal to emptying the file:
nancy:~> ls -l list
-rw-rw-r-1 nancy

nancy

117 Apr

2 18:09 list

nancy

0 Apr

4 12:01 list

nancy:~> > list
nancy:~> ls -l list
-rw-rw-r-1 nancy

This process is called truncating
...

Some examples using piping of commands:
To find a word within some text, display all lines matching "pattern1", and exclude lines also matching
"pattern2" from being displayed:
grep pattern1 file | grep -v pattern2
To display output of a directory listing one page at a time:
ls -la | less
To find a file in a directory:
ls -l | grep part_of_file_name
5
...
2
...
Input redirection
In another case, you may want a file to be the input for a command that normally wouldn't accept a file as an
option
...

Below is an example of sending a file to somebody, using input redirection
...
org < to_do

Chapter 5
...
If you want to reach somebody
on the Internet, enter the fully qualified address as an argument to mail
...

5
...
2
...
Combining redirections
The following example combines input and output redirection
...
txt is first checked for
spelling mistakes, and the output is redirected to an error log file:
spell < text
...
log
The following command lists all commands that you can issue to examine another file when using less:
mike:~> less --help | grep -i examine
:e [file]
Examine a new file
...

:p
* Examine the (N-th) previous file from the command line
...


The -i option is used for case-insensitive searches - remember that UNIX systems are very case-sensitive
...

:n
* Examine the (N-th) next file from the command line
...

:x
* Examine the first (or N-th) file from the command line
...

Sometimes they don't, but then there may be special options that instruct these commands to behave according
to the standard definitions; so read the documentation (man and Info pages) of the commands you use if you
should encounter errors
...
Redirecting output to existing files
will replace the content of those files
...
1
...
4
...
I/O redirection

99

Introduction to Linux
mike:~> cat wishlist
more money
less work
Thu Feb 28 20:23:07 CET 2002

The date command would normally put the last line on the screen; now it is appended to the file wishlist
...
2
...
2
...
Use of file descriptors
There are three types of I/O, which each have their own identifier, called a file descriptor:
• standard input: 0
• standard output: 1
• standard error: 2
In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection
operator is <, the redirection refers to the standard input (file descriptor 0)
...

Some practical examples will make this more clear:
ls > dirlist 2>&1
will direct both standard output and standard error to the file dirlist, while the command
ls 2>&1 > dirlist
will only direct standard output to dirlist
...

Things are getting quite complicated here, don't confuse the use of the ampersand here with the use of it in
Section 4
...
2
...
Here, it merely serves as an
indication that the number that follows is not a file name, but rather a location that the data stream is pointed
to
...
If it would be separated, we would be pointing the output to a file again
...
The second command expects that 2 is a file name, which does
not exist in this case, so an error is displayed
...


Chapter 5
...
2
...
Examples
5
...
2
...
Analyzing errors
If your process generates a lot of errors, this is a way to thoroughly examine them:
command 2>&1 | less
This is often used when creating new software using the make command, such as in:
andy:~/newsoft> make all 2>&1 | less
--output ommitted--

5
...
2
...
Separating standard output from standard error
Constructs like these are often used by programmers, so that output is displayed in one terminal window, and
errors in another
...
2
...
3
...

Using the -a option to tee results in appending input to the file(s)
...
The > and >> operators do not allow to perform both actions simultaneously
...
04, 0
...
26

mireille ~/test> cat file2
Thu Jun 10 11:10:34 CEST 2004
11:10:51 up 21 days, 21:21, 57 users,

load average: 0
...
16, 0
...
3
...

One of the most common uses of filters is to restructure output
...


Chapter 5
...
3
...
More about grep
As we saw in Section 3
...
3
...
All lines
containing the pattern will be printed to standard output
...

Some examples: suppose we want to know which files in a certain directory have been modified in February:
jenny:~> ls -la | grep Feb

The grep command, like most commands, is case sensitive
...
A lot of GNU extensions are available as well, such as --colour, which is helpful to
highlight searchterms in long lines, and --after-context, which prints the number of lines after the last
matching line
...
As usual, options can be combined
...
The best way to start with regular expressions is indeed to read the grep documentation
...
Since it would lead us too far discussing the ins and outs
of regular expressions, it is strongly advised to start here if you want to know more about them
...
The exercises at the end of this chapter will help you to get started, see Section
5
...


5
...
2
...
Looking at the file size, for instance
...

The sort command is also used in combination with the uniq program (or sort -u) to sort output and filter out
double entries:
thomas:~> cat itemlist
1
4
2
5
34

Chapter 5
...
4
...

Input/output redirection is a common task on UNIX and Linux machines
...

The most commonly used redirections are > and |
...


Table 5-1
...

Configure shell options
...

Remove duplicate lines from a sorted file
...
5
...
The main goal is to try and use the Enter
key as little as possible
...
While you're at it, don't forget to
read those man pages!
• Use the cut command on the output of a long directory listing in order to display only the file
permissions
...
Then use the wc to
count the different permission types in this directory
...
Append the output of ls to this file
...
When using Bash, you will see a
new mail notice upon success
...
I/O redirection

103

Introduction to Linux
• List the devices in /dev which are currently used by your UID
...

• Issue the following commands as a non-privileged user
...

♦ cat nonexistentfile
♦ file /sbin/ifconfig
♦ grep root /etc/passwd /etc/nofiles > grepresults
♦ /etc/init
...
d/crond start > /var/tmp/output 2>&1
♦ Now check your results by issuing the commands again, now redirecting standardoutput to
the file /var/tmp/output and standard error to the file /var/tmp/error
...

• Find out which file contains the following entry:
root:x:0:0:root:/root:/bin/bash

And this one:
system:

root

• See what happens upon issuing this command:
> time; date >> time; cat < time
• What command would you use to check which script in /etc/init
...
I/O redirection

104

Chapter 6
...
We will focus mainly
on the Improved vi editor
...
1
...
1
...
Why should I use an editor?
It is very important to be able to use at least one text mode editor
...

We will need to master an editor by the next chapter as we need it to edit files that influence our environment
...

Mastering an editor will immensely improve your productivity as well as your capabilities
...
1
...
Which editor should I use?
Our focus is on text editors, which can also be used on systems without a graphical environment and in
terminal windows
...

Since you don't need to transfer the entire graphical environment over the network, working with text editors
tremendously improves network speed
...
Let's see what editors are commonly available:
6
...
2
...
GNU Emacs
Emacs is the extensible, customizable, self-documenting, real-time display editor, known on many UNIX and
other systems
...
It is a real-time editor because the display is updated very frequently, usually after each character
or pair of characters you type
...
Emacs is called advanced because it provides facilities that go beyond simple insertion and deletion:
controlling subprocesses; automatic indentation of programs; viewing two or more files at once; editing
formatted text; and dealing in terms of characters, words, lines, sentences, paragraphs, and pages, as well as
expressions and comments in several different programming languages
...
Text editors

105

Introduction to Linux
options are
...
Customizable means that you can change the definitions of Emacs commands in little ways
...
Another sort of customization is
rearrangement of the command set
...

Extensible means that you can go beyond simple customization and write entirely new commands, programs
in the Lisp language that are run by Emacs's own Lisp interpreter
...
Almost any part of Emacs can be replaced without making a separate copy of all
of Emacs
...
Although only a programmer can write an extension,
anybody can use it afterward
...
But Emacs can provide many of the benefits of a window system on a text-only
terminal
...

6
...
2
...
Vi(m)
Vim stands for "Vi IMproved"
...
Vim is a text editor which includes almost all the commands from the UNIX program
vi and a lot of new ones
...
For those who want it, mouse support and a GUI version with scrollbars and menus can be activated
...
However, we recommend to at least get the vi basics in the fingers, because it is the standard
text editor on almost all UNIX systems, while emacs can be an optional package
...

Apart from the vim command, the vIm packages may also provide gvim, the Gnome version of vim
...


6
...
Using the Vim editor
6
...
1
...
We will only discuss the very basics here to get you started
...

The editor always starts in command mode
...
Text editors

106

Introduction to Linux
blocks and perform other editing tasks, and some of them switch the editor to insert mode
...

Pronunciation
It's pronounced "vee-eye"
...
2
...
Basic commands
6
...
2
...
Moving through the text
Moving through the text is usually possible with the arrow keys
...

6
...
2
...
Basic operations
These are some popular vi commands:
• n dd will delete n lines starting from the current cursor position
...

• x will delete the character on which the cursor is positioned
• :n moves to line n of the file
...

• :q! forces the exit when you want to quit a file containing unsaved changes
...

• :wq! overrides read-only permission (if you have the permission to override permissions, for instance
when you are using the root account
...

• / will perform the same search again, moving the cursor to the next match
...

• yy will copy a block of text
...

• :recover will recover a file after an unexpected interruption
...
2
...
3
...


Chapter 6
...
If you're not sure what mode you're in because you
use a really old version of vi that doesn't display an "INSERT" message, type Esc and you'll be sure to return
to command mode
...
This is normal behavior
...
2
...
The easy way
Instead of reading the text, which is quite boring, you can use the vimtutor to learn you first Vim commands
...
While you
can't learn everything about vim in just half an hour, the tutor is designed to describe enough of the
commands that you will be able to easily use Vim as an all-purpose editor
...
This will make a copy of the tutor file, so that you can edit it
without the risk of damaging the original
...
To find out if yours
is available, use the two-letter language code
...


6
...
Linux in the office
6
...
1
...

This monopoly situation of Microsoft proved to be a big disadvantage for getting new users to Linux, so a
group of German developers started the StarOffice project, that was, and is still, aimed at making an MS
Office clone
...
2 release
...
Nevertheless,
development on the original set of sources continues in the Open Source community, which had to rename the
project to OpenOffice
...
There is a screenshot in Section 1
...
2
...
Also a very common alternative to
using MS Office is KOffice, the office suite that used to be popular among SuSE users
...

Smaller projects deal with particular programs of the MS example suite, such as Abiword and MS Wordview
for compatibility with MS Word documents, and Gnumeric for viewing and creating Excel compatible
spreadsheets
...
3
...
Suites and programs
Current distributions usually come with all the necessary tools
...
For references, see you system
documentation or the web sites of the projects, such as
• http://www
...
org
Chapter 6
...
koffice
...


6
...
3
...
3
...
1
...

An example: it drives most Linux users crazy if you send them a mail that says in the body something like:
"Hello, I want to tell you something, see attach", and then the attachement proves to be an MS Word
compatible document like: "Hello my friend, how is your new job going and will you have time to have lunch
with me tomorrow?" Also a bad idea is the attachment of your signature in such a file, for instance
...

These users are not annoyed because they are unable to read these documents, or because they are worried
that these formats typically generate much larger files, but rather because of the implication that they are using
MS Windows, and possibly because of the extra work of starting some additional programs
...
3
...
2
...

Don't edit these files with any office component!
The default file format specification would make the program add several lines of code, defining the format of
the file and the fonts used
...
In some cases, you can save the file as
plain text, but you'll run into trouble when making this a habit
...
3
...
3
...
If you plan on doing anything serious, though, stick to a real text mode editor such as vim or
emacs
...
You still need to use vi commands, but if you
are stuck, you can look them up in the menus
...
4
...
While it depends on your own individual preference which one you
use, it is necessary to at least know how to use one editor
...

Most Linux distributions include an office suite and a graphical text editor
...
Text editors

109

Introduction to Linux

6
...
Exercises
This chapter has only one exercise: start the Vim tutor by entering vimtutor in a terminal session, and get
started
...

Practice is the only way!

Chapter 6
...
Home sweet /home
This chapter is about configuring your environment
...
After completing this
chapter, you will know more about:
♦ Organizing your environment
♦ Common shell setup files
♦ Shell configuration
♦ Configuring the prompt
♦ Configuring the graphical environment
♦ Sound and video applications
♦ Display and window managers
♦ How the X client-server system works
♦ Language and font settings
♦ Installing new software
♦ Updating existing packages

7
...
General good housekeeping
7
...
1
...
We can't put enough stress on the
importance of keeping the place tidy
...
Here are some ways of making life easier on yourself:
• Make a bin directory for your program files and scripts
...

Examples include separate directories for images, documents, projects, downloaded files,
spreadsheets, personal files, and so on
...

• Give your files sensible names, such as Complaint to the prime minister 050302
rather than letter1
...
1
...
Make space
On some systems, the quota system may force you to clean up from time to time, or the physical limits of
your hard disk may force you to make more space without running any monitoring programs
...

Run the quota -v command to see how much space is left
...
Home sweet /home

111

Introduction to Linux
7
...
2
...
Emptying files
Sometimes the content of a file doesn't interest you, but you need the file name as a marker (for instance, you
just need the timestamp of a file, a reminder that the file was there or should be there some time in the future)
...

For creating a new empty file, the same effect is obtained with the touch command
...
See the Info pages on touch for more details
...
Suppose user andy's wishlist becomes rather long because he
always adds stuff at the end but never deletes the things he actually gets
...
1
...
2
...
Usually there are options to only log
errors, or to log a minimal amount of information, for example setting the debugging level of the program
...
Here are some ways to get rid of them or at least set some
limits to their size:
• Try removing the log file when the program is not running, if you are sure that you won't need it
again
...

• If you remove the log file and the program recreates it, read the documentation for this particular
program in search for command options that avoid making log files
...

• Try replacing the log file with a symbolic link to /dev/null; if you're lucky the program won't
complain
...
These programs might replace the symbolic link with a small file that starts
growing again
...
Home sweet /home

112

Introduction to Linux
7
...
2
...
Mail
Regularly clean out your mailbox, make sub-folders and automatic redirects using procmail (see the Info
pages) or the filters of your favorite mail reading application
...

To redirect mail, use the
...
The Linux mail service looks for this file
whenever it has to deliver local mail
...
It can contain a single line holding a fully qualified E-mail address
...
For instance, when renting space for a website, you might want to forward the mail
destined for the webmaster to your own account in order not to waste disk space
...
forward may look like this:
webmaster@www ~/> cat
...
be

Using mail forwarding is also useful to prevent yourself from having to check several different mailboxes
...

You can ask your system administrator to define a forward for you in the local mail aliases file, like when an
account is being closed but E-mail remains active for a while
...
1
...
4
...

Multiple symbolic links may have different names, e
...
a link may be called monfichier in one user's
directory, and mylink in another's
...
This is often done in the /lib directory: when issuing the command
ls -l /lib
you will see that this directory is plenty of links pointing to the same files
...

7
...
2
...
Limit file sizes
The shell contains a built-in command to limit file sizes, ulimit, which can also be used to display limitations
on system resources:
cindy:~> ulimit -a
core file size (blocks)
data seg size (kbytes)
file size (blocks)
max locked memory (kbytes)
max memory size (kbytes)
open files
pipe size (512 bytes)
stack size (kbytes)
cpu time (seconds)
max user processes
virtual memory (kbytes)

Chapter 7
...
If you do want core dumps, you can set their size using the ulimit command
...

Core file?
A core file or core dump is sometimes generated when things go wrong with a program during its
execution
...

7
...
2
...
Compressed files
Compressed files are useful because they take less space on your hard disk
...
A lot of files, such as the man pages, are stored
in a compressed format on your system
...
You don't want to unpack a man page, for instance, read
about an option to a command and then compress the man page again
...

So we have tools that work on compressed files, by uncompressing them only in memory
...
Most systems support zgrep, zcat, bzless and other members of the
z-family to prevent unnecessary decompressing/compressing actions
...

See Chapter 9 for more on the actual compressing of files and examples on making archives
...
2
...
2
...
Environment variables
7
...
1
...
General
We already mentioned a couple of environment variables, such as PATH and HOME
...
But there are many other Linux utilities that need
information about you in order to do a good job
...
In text mode, this will be the linux terminal emulation, in graphical mode you are likely to use
xterm
...
The shell you are using is stored in the SHELL variable, the operating system type in OS and so
on
...

The environment variables are managed by the shell
...
New processes are assigned a copy
of these variables, which they can read, modify and pass on in turn to their own child processes
...
You may come up with any name you want, although there are standard variables that are
Chapter 7
...

7
...
1
...
Exporting variables
An individual variable's content is usually displayed using the echo command, as in these examples:
debby:~> echo $PATH
/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bin
debby:~> echo $MANPATH
/usr/man:/usr/share/man/:/usr/local/man:/usr/X11R6/man

If you want to change the content of a variable in a way that is useful to other programs, you have to export
the new value from your environment into the environment that runs these programs
...
You may declare it as follows, in order to be able to play with the flight
simulator software that is in /opt/FlightGear/bin:
debby:~> PATH=$PATH:/opt/FlightGear/bin

This instructs the shell to not only search programs in the current path, $PATH, but also in the additional
directory /opt/FlightGear/bin
...
If new software is added to the system in new or unusual directories, the
documentation for it will probably also be in an unusual directory
...
2
...

7
...
1
...
Reserved variables
The following table gives an overview of the most common predefined variables:

Chapter 7
...
Common environment variables
Variable name
DISPLAY
DOMAIN
EDITOR
HISTSIZE
HOME
HOSTNAME
INPUTRC
LANG
LD_LIBRARY_PATH
LOGNAME
MAIL
MANPATH
OS
OSTYPE

Stored information
used by the X Window system to identify the display server
domain name
stores your favorite line editor
size of the shell history file in number of lines
path to your home directory
local host name
location of definition file for input devices such as keyboard
preferred language
paths to search for libraries
login name
location of your incoming mail folder
paths to search for man pages
string describing the operating system
more information about version etc
...

PATH
search paths for commands
PS1
primary prompt
PS2
secondary prompt
PWD
present working directory
SHELL
current shell
TERM
terminal type
UID
user ID
USER(NAME)
user name
VISUAL
your favorite full-screen editor
XENVIRONMENT
location of your personal settings for X behavior
XFILESEARCHPATH paths to search for graphical libraries
A lot of variables are not only predefined but also preset, using configuration files
...


7
...
2
...
and ending in rc
...
bashrc
...

When logging into an interactive login shell, login will do the authentication, set the environment and start
your shell
...

bash then looks for ~/
...
bash_login and ~/
...
If none exists, /etc/bashrc is
applied
...
Home sweet /home

116

Introduction to Linux
When a login shell exits, bash reads and executes commands from the file ~/
...

This procedure is explained in detail in the login and bash man pages
...
2
...
A typical set of setup files
7
...
3
...
/etc/profile example
Let's look at some of these config files
...
If not, they are added
...

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

All trash goes to /dev/null if the user doesn't change this setting
...

if [ -z "$INPUTRC" -a ! -f "$HOME/
...
inputrc in the user's home directory, then the default
input control file is loaded
...
Home sweet /home

117

Introduction to Linux
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

All variables are exported, so that they are available to other programs requesting information about your
environment
...
2
...
2
...
d directory
for i in /etc/profile
...
sh ; do
if [ -r $i ]; then

...
d directory are read and executed
...
The temporary variable i is unset to prevent it from
disturbing shell behavior later on
...
2
...
3
...
bash_profile in the user's home directory:
debby:~> cat
...
bash_profile file
#
#
#
#
Executed from the bash shell when you log in
...
bashrc
source ~/
...
bashrc and then ~/
...

You will encounter the source built-in shell command regularly when working in a shell environment: it is
used to apply configuration changes to the current environment
...
2
...
4
...
bash_login file defines default file protection by setting the umask value, see Section 3
...
2
...

The ~/
...
It first reads /etc/bashrc, which describes the default prompt (PS1) and the
default umask value
...
If no ~/
...

7
...
3
...
/etc/bashrc example
Your /etc/bashrc file might look like this:
debby:~> cat /etc/bashrc
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# by default, we want this to get set
...
Home sweet /home

118

Introduction to Linux
# Even for non-interactive, non-login shells
...
Then, depending on the type of shell, the prompt is set:
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -x /usr/bin/tput ]; then
if [ "x`tput kbs`" != "x" ]; then
# We can't do this with "dumb" terminal
stty erase `tput kbs`
elif [ -x /usr/bin/wc ]; then
if [ "`tput kbs|wc -c `" -gt 0 ]; then
# We can't do this with "dumb" terminal
stty erase `tput kbs`
fi
fi
fi
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%
...
d/*
...
$i
fi
done
fi
fi

7
...
3
...
bash_logout example
Upon logout, the commands in ~/
...
bash_logout
# ~/
...
Keep info bash close at hand
...
Home sweet /home

119

Introduction to Linux

7
...
4
...
2
...
1
...
We can add other information such as
the current date and time, number of connected users etc
...
You will, of course, also get it back when you
reconnect, as long as you just fiddle with the prompt on the command line and avoid putting it in a shell
configuration file
...
2
...
2
...

• export PS1="[\t \j] "
Displays time of day and number of running jobs
• export PS1="[\d][\u@\h \w] : "
Displays date, user name, host name and current working directory
...

• export PS1="{\!} "
Displays history number for each command
...

• export PS1="\[\033[1;35m\]\u\[\033[0m\] \[\033[1;34m\]\w\[\033[0m\] "
Sets the user name in pink and the present working directory in blue
...

• export PS1="\[\033[4;34m\]\u@\h \w \[\033[0m\]"
Underlined prompt
...

• export PS1="\[\033[3;35m\]\u@\h \w \[\033[0m\]\a"
Chapter 7
...

• export PS1=
...
The
prompt configuration line that you want is best put in your shell configuration file, ~/
...

If you want, prompts can execute shell scripts and behave different under different conditions
...
More
information can be found in the Bash-Prompt HOWTO
...
2
...
Shell scripts
7
...
5
...
What are scripts?
A shell script is, as we saw in the shell configuration examples, a text file containing shell commands
...
This mode of operation creates a
non-interactive shell
...
If no additional arguments are supplied, the positional
parameters are unset
...
When Bash
finds such a file while searching the PATH for a command, it spawns a sub-shell to execute it
...
This sub-shell reinitializes itself, so that the effect is as if a new
shell had been invoked to interpret the script, with the exception that the locations of commands remembered
by the parent (see hash in the Info pages) are retained by the child
...
If the first
line of a script begins with the two characters "#!", the remainder of the line specifies an interpreter for the
program
...

The arguments to the interpreter consist of a single optional argument following the interpreter name on the
first line of the script file, followed by the name of the script file, followed by the rest of the arguments
...

Bash scripts often begin with
#! /bin/bash

(assuming that Bash has been installed in /bin), since this ensures that Bash will be used to interpret the
script, even if it is executed under another shell
...
Home sweet /home

121

Introduction to Linux
7
...
5
...
Some simple examples
A very simple script consisting of only one command, that says hello to the user executing it:
[jerry@nowhere ~] cat hello
...

Another one-liner, used for displaying connected users:
#!/bin/bash
who | cut -d " " -f 1 | sort -u

Here is a script consisting of some more lines, that I use to make backup copies of all files in a directory
...
Then it sets the
name of the copy for each file, and then it copies the file
...
sh
#!/bin/bash
# make copies of all files in a directory
LIST=`ls`
for i in $LIST; do
ORIG=$i
DEST=$i
...
old won't work, as you will notice when trying this on a set of test files
...
echo's are generally useful when a script won't
work: insert one after each doubted step and you will find the error in no time
...
d/init
...
Let's look at this script that controls the
fictive ICanSeeYou server:
#!/bin/sh
# description: ICanSeeYou allows you to see networked people
# process name: ICanSeeYou
# pidfile: /var/run/ICanSeeYou/ICanSeeYou
...
cfg
# Source function library
...
/etc/rc
...
d/functions
# See how (with which arguments) we were called
...
Home sweet /home

122

Introduction to Linux
killproc ICanSeeYou
echo
rm -f /var/lock/subsys/ICanSeeYou
rm -f /var/run/ICanSeeYou/ICanSeeYou
...
command (dot) a set of shell functions, used by almost all shell scripts in
/etc/rc
...
d, is loaded
...
An example might be ICanSeeYou start
...

When no compliant input is given, the default case, marked with an asterisk, is applied, upon which the script
gives an error message
...
In the start case the server program is
started as a daemon, and a process ID and lock are assigned
...
Options, such as the daemon option, and functions
like killproc, are defined in the /etc/rc
...
d/functions file
...
The initscripts on your system might use other functions, defined in other
files, or none at all
...

This script is a fine example of using functions, which make the script easier to read and the work done faster
...
On a Linux system,
calling bash as sh results in the shell running in POSIX-compliant mode
...
A comprehensible Bash course for system administrators and power users,
with exercises, from the same author as this Introduction to Linux guide, is at
http://tille
...
be/training/bash/
...


7
...
The graphical environment
7
...
1
...
The use and configuration of
window managers and desktops is straightforward and may even resemble the standard MS Windows, Apple
or UNIX CDE environment, although many Linux users prefer flashier desktops and fancier window
managers
...
Just experiment and read the documentation
using the built-in Help functions these managers provide and you will get along fine
...
Home sweet /home

123

Introduction to Linux
We will, however, take a closer look at the underlying system
...
3
...
The X Window System
The X Window System is a network-transparent window system which runs on a wide range of computing
and graphics machines
...
The X server
distributes user input to and accepts output requests from several client programs through a variety of different
interprocess communication channels
...
We will learn how to do this in Chapter
10 on networking and remote applications
...
The number of X client programs that use the X server is quite large
...

We refer again to the man pages of these commands for detailed information
...
The
/usr/share/doc directory contains references to these documents and many others
...
Good places to start
are http://www
...
org and http://www
...
org
...
Note that in normal operation, that is
in graphical mode, X clients and the X server on Linux run on the same machine
...
3
...
1
...
screennumber
This information is used by the application to determine how it should connect to the X server and which
screen it should use by default (on displays with multiple monitors):
Chapter 7
...
If the host name is not given, the most efficient way of communicating to a server on the
same machine will be used
...
Most workstations tend to only have one
keyboard, and therefore, only one display
...
To avoid
confusion, each display on a machine is assigned a display number (beginning at 0) when the X server
for that display is started
...

• screen number: Some displays share a single keyboard and pointer among two or more monitors
...
If the screen number is not given, screen 0 will be
used
...
This variable
is set automatically by the xterm terminal emulator
...
4
...
2
...

7
...
2
...
Window and desktop managers
The layout of windows on the screen is controlled by special programs called window managers
...

Since window managers are regular (albeit complex) client programs, a variety of different user interfaces can
be built
...
Sawfish and Enlightenment are popular examples
which allow each user to have a desktop according to mood and style
...
Among the most popular desktop managers are Gnome and KDE, which both run on
almost any Linux distribution and many other UNIX systems
...
If you have the
KDE libraries installed (the kdelibs package), you can run these applications from the Gnome menus or
start them from a Gnome terminal
...
However, the dependencies and thus extra packages you might have to install
will become clear when running or installing such an application
...
3
...
X server configuration
The X distribution that used to come with Linux, XFree86, uses the configuration file XF86Config for its
initial setup
...
Home sweet /home

125

Introduction to Linux
usually in /etc/X11
...

Because of licensing issues with XFree86, newer systems usually come with the X
...
The main configuration file here is xorg
...
The file
consists of a number of sections that may occur in any order
...
As a user, you needn't worry
too much about what is in this file, since everything is normally determined at the time the system is installed
...
See the man pages for more
information; your distribution might have its own tools
...


7
...
Region specific settings
7
...
1
...
Use your local X
configuration tool or edit the Keyboard section in XF86Config manually to configure the layout for
graphical mode
...
Change it to your local settings by replacing the quoted value with any of the names listed
in the subdirectories of your keymaps directory
...

Log out and reconnect in order to reload X settings
...
KDE has a similar tool for switching between keyboard layouts
...
4
...
Fonts
Use the setfont tool to load fonts in text mode
...
The system admin should then add
the line

Chapter 7
...


7
...
3
...
After that, it can be kept up to date using an NTP
(Network Time Protocol) client
...
The ntpd
daemon should not be running when you adjust the time using ntpdate
...
2
...
200
26 Oct 14:35:42 ntpdate[20364]: adjust time server 10
...
5
...
008049 sec

See your system manual and the documentation that comes with the NTP package
...

For setting the time zone correct, you can use tzconfig or timezone commands
...
Many systems have distribution-specific tools to configure
it, see your system documentation
...
4
...
Language
If you'd rather get your messages from the system in Dutch or French, you may want to set the LANG and
LANGUAGE environment variables, thus enabling locale support for the desired language and eventually the
fonts related to character conventions in that language
...

Note that on most systems, the default tends to be en_US
...
This is not a problem, because
systems where this is the default, will also come with all the programs supporting this encoding
...

Trouble starts when you connect to an older system not supporting this font encoding, or when you open a
UTF-8 encoded file on a system supporting only 1-byte character fonts
...
Read the man pages for an overview of features and
usage
...
pdf
Warning: charset "UTF-8" not supported, using "ISO8859-1"
...
UTF-8
debby:~> export LANG=en_US

Chapter 7
...
pdf
<--new window opens-->

Refer to the Mozilla web site for guidance on how to get Firefox in your language
...
org web
site has information on localization of your OpenOffice
...


7
...
5
...


7
...
Installing new software
7
...
1
...
Also common tools such as office suites, web browsers, E-mail and
other network client programs are included in the main distributions
...

If you just can't find what you need, maybe it is not installed on your system
...
Remember that Linux moves fast, and software
improves on a daily basis
...

You can update your system or add packages to it at any time you want
...

Extra software may be found on your installation CDs or on the Internet
...
Always read the documentation that comes with new
software, and any installation guidelines the package might contain
...


7
...
2
...
5
...
1
...
5
...
1
...
What is RPM?

RPM, the RedHat Package Manager, is a powerful package manager that you can use to install, update and
remove packages
...
A system is built-in so that you can verify the authenticity of packages downloaded from the
Internet
...

An RPM package consists of an archive of files and meta-data used to install and erase the archive files
...
Packages
come in two varieties: binary packages, used to encapsulate software to be installed, and source packages,
containing the source code and recipe necessary to produce binary packages
...
Home sweet /home

128

Introduction to Linux
Many other distributions support RPM packages, among the popular ones RedHat Enterprise Linux, Mandriva
(former Mandrake), Fedora Core and SuSE Linux
...

7
...
2
...
2
...
The RPM package contains a complete version of the program, which overwrites existing versions or
installs as a new package
...
99
...
fr
...
rpm
Preparing
...
That way, you will still be able to boot your system with the old kernel if the new
one does not work
...
1-29
vim-X11-6
...
1-29
vim-common-6
...
5
...
5
...
You only need to be root when adding, modifying or deleting packages
...
When in
doubt, use rpm -qa again to verify that the package has been removed
...


Chapter 7
...
5
...
2
...
deb) packages
7
...
2
...
1
...
It is used to select packages that you want to install
or upgrade, but it will also run during the installation of a Debian system and help you to define the access
method to use, to list available packages and to configure packages
...

According to the latest news, the Debian package format is becoming more and more popular
...
Also apt-get (see Section 7
...
3
...

7
...
2
...
2
...
For instance, if you want to know
which version of the Gallery software is installed on your machine:
nghtwsh@gorefest:~$ dpkg -l *gallery*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name
Version
Description
+++-==============-==============-============================================
ii gallery
1
...
Should you see "un" as a prefix, that means that the package is
known in the list that your computer keeps, but that it is not installed
...

7
...
2
...
Source packages
The largest part of Linux programs is Free/Open Source, so source packages are available for these programs
...
Sources for a program can be downloaded
from its web site, often as a compressed tarball (program-version
...
gz or similar)
...
src
...
Debian, and most
distributions based on it, provide themselves the adapted source which can be obtained using apt-get
source
...
You will
probably need a C compiler, gcc
...


Chapter 7
...
5
...
Automating package management and updates
7
...
3
...
General remarks
The first thing you do after installing a new system is applying updates; this applies to all operating systems
and Linux is not different
...
Lists of
sites offering this service can be found at your distribution's web site, see Appendix A
...

You really should try to have the most recent version of your distribution, since Linux changes constantly
...

The good news is that most Linux distributions provide tools so that you don't have to upgrade tens of
packages daily by hand
...
There is
much more to this subject, even regular updates of source packages is manageable automatically; we only list
the most commonly known systems
...

7
...
3
...
APT
The Advanced Package Tool is a management system for software packages
...
APT has its roots in the Debian
GNU/Linux distribution, where it is the default manager for the Debian packages
...
The main advantage of APT is that it is free and flexible to use
...

Generally, when first using apt-get, you will need to get an index of the available packages
...

Apart from this general usage, apt-get is also very fast for installing individual packages
...
Done
Building Dependency Tree
...
Home sweet /home

131

Introduction to Linux
0 packages upgraded, 1 newly installed, 0 removed and 3 not upgraded
...
6kB of archives
...

Get:1 http://ayo
...
net redhat/9/i386/os xsnow 1
...
6kB]
Fetched 33
...

Preparing
...
This way, you cannot forget to quit the root account
...

More information can be found in the APT HOWTO
...
5
...
3
...
This tool provides a complete system for updating the RPM
packages on a RedHat or Fedora Core system
...
On
the desktop, by default a small icon is activated, telleng you whether or not there are updates available for
your system
...
It is an interactive
but automated update program for installing, updating or removing RPM packages on a system
...

On SuSE Linux, everything is done with YaST, Yet another Setup Tool, which supports a wide variety of
system administration tasks, among which updating RPM packages
...
1 you can
also upgrade using a web interface and YOU, Yast Online Update
...
These tools combine with RPMDrake and MandrakeUpdate to
provide everything needed for smooth install and uninstall of software packages
...
See man urpmi, among others, for more info
...


7
...
4
...
The upgrade procedure will
install a new kernel when needed and make all necessary changes to your system
...

Whether compiling your own optimized kernel or using a pre-compiled kernel package, install it in
co-existence with the old kernel until you are sure that everything works according to plan
...
conf
...
Home sweet /home

132

Introduction to Linux
# grub
...

# NOTICE: You have a /boot partition
...
g
...
img
#boot=/dev/hde
default=0
timeout=10
splashimage=(hd0,0)/grub/splash
...
gz
title Red Hat Linux new (2
...
9-31)
root (hd0,0)
kernel /vmlinuz-2
...
9-31 ro root=/dev/hde8
initrd /initrd-2
...
9-31
...
4
...
4
...
img

After the new kernel has proven to work, you may remove the lines for the old one from the GRUB config
file, although it is best to wait a couple of days just to be sure
...
5
...
Installing extra packages from the installation CDs
7
...
5
...
Mounting a CD
This is basically done in the same way as installing packages manually, except that you have to append the
file system of the CD to your machine's file system to make it accessible
...
If
your CD is not made available automatically, issue the mount command in a terminal window
...

For automation purposes, the CD drive usually has an entry in /etc/fstab, which lists the file systems and
their mount points, that make up your file system tree
...
The noauto option
means that on this system, CDs are not mounted at boot time
...
You can check whether it worked issuing the mount command with no arguments:
[david@jupiter ~] mount | grep cdrom
/dev/cdrom on /mnt/cdrom type iso9660 (ro,nosuid,nodev)

Chapter 7
...
5
...
2
...
Use the same commands for dealing with files and directories as you
would use for files on the hard disk
...
5
...
3
...
Even being in one of the subdirectories of the mount point, /mnt/cdrom in our example, will be
considered as "using the file system", so you should get out of there
...
After that, you can either use the command
umount /mnt/cdrom
or
eject cdrom
Blocked drives
NEVER force the drive
...

Chances are likely that you will have to reboot to get the system back in a consistent state
...
When in doubt, use the lsof tool to trace
down the process(es) still using the CD resource
...
6
...

While keeping order is important, it is equally important to feel at home in your environment, whether text or
graphical
...
The graphical environment is
primarily dependent on the X server configuration, on which a number of other applications are built, such as
window and desktop managers and graphical applications, each with their own config files
...

Regional settings such as keyboard setup, installing appropriate fonts and language support are best done at
installation time
...

The following commands were introduced in this chapter:

Table 7-2
...
Home sweet /home

134

Introduction to Linux
aptitude
automount
dpkg
dselect
loadkeys
lsof
mount
ntpdate
quota
recode
rpm
setfont
timezone
tzconfig
ulimit
up2date
urpmi
yum

Manage packages Debian-style
...

Debian package manager
...

Load keyboard configuration
...

Include a new file system into the existing file system tree
...

Display information about allowed disk space usage
...

Manage RPM packages
...

Set the timezone
...

Set or display resource limits
...

Manage RPM packages
...


7
...
Exercises
7
...
1
...
Which variable may be used to store the CPU type of your
machine?
• Make a script that can say something on the lines of "hello, world
...
Test your script
...
Permanently add
this new directory to your search path
...

• Create subdirectories in your home directory to store various files, for instance a directory music to
keep audio files, a directory documents for your notes, and so on
...

• Display limits on resource usage
...

• Make an alias lll which actually executes ls -la
...
Don't forget to
unmount when you don't need it anymore
...
2
...
2 is not perfect
...
Adapt
the script so that it only selects plain files for copying
...
Do not forget
to make the script executable before you try to run it
...
Home sweet /home

135

Introduction to Linux

7
...
2
...

• Explore the menus
...

• Use the mouse buttons to copy and paste text from one terminal to another
...

• Add an applet, such as a load monitor, to the task bar
...

• Enable the so-called sloppy focus - this is when a window is activated by just moving the mouse over
it, so that you do not need to click the window in order to be able to use it
...

• Log out and select a different session type, like KDE if you were using Gnome before
...


Chapter 7
...
Printers and printing
In this chapter we will learn more about printers and printing files
...
1
...
1
...
Command line printing
8
...
1
...
Getting the file to the printer
Printing from within an application is very easy, selecting the Print option from the menu
...

lp file(s)
lpr file(s)
These commands can read from a pipe, so you can print the output of commands using
command | lp
There are many options available to tune the page layout, the number of copies, the printer that you want to
print to if you have more than one available, paper size, one-side or double-sided printing if your printer
supports this feature, margins and so on
...

8
...
1
...
Status of your print jobs
Once the file is accepted in the print queue, an identification number for the print job is assigned:
davy:~> lp /etc/profile
request id is blob-253 (1 file(s))

To view (query) the print queue, use the lpq or lpstat command
...

davy:~> lpq
blob is ready and printing
Rank
Owner
Job
File(s)
Total Size
active davy
253
profile
1024 bytes
davy:~> lpstat
blob-253
davy
1024
Tue 25 Jul 2006 10:20_01 AM CEST

Chapter 8
...
1
...
3
...
enabled since Jan 01 18:01

8
...
1
...
Removing jobs from the print queue
If you don't like what you see from the status commands, use lprm or cancel to delete jobs
...

In larger environments, lpc may be used to control multiple printers
...

There are many GUI print tools used as a front-end to lp, and most graphical applications have a print
function that uses lp
...

Why are there two commands for every task related to printing?
Printing on UNIX and alikes has a long history
...
For compatibility, Linux with CUPS supports the
commands from both styles
...
Which one you use is not
important, just pick the commands that you are comfortable with, or that you may know from previous
experiences with UNIX-like systems
...
1
...
Formatting
8
...
2
...
Tools and languages
If we want to get something sensible out of the printer, files should be formatted first
...

Modern Linux systems support direct printing, without any formatting by the user, of a range of file types:
text, PDF, PostScript and several image formats like PNG, JPEG, BMP and GIF
...
These commands can create files that
can then be used on other systems that don't have all the conversion tools installed
...
Printers and printing

138

Introduction to Linux
Apart from these command line tools there are a lot of graphical word processing programs
...
These do the formatting automatically upon submission of a print
job
...
org, KOffice, AbiWord, WordPerfect, etc
...
It is a front-end to the groff document formatting
system
...

It allows generation of PostScript files
...
Usually invoked as tex, it formats files and outputs a corresponding device-independent
representation of the typeset document
...

• SGML and XML: Free parsers are available for UNIX and Linux
...

Printing documentation
The man pages contain pre-formatted troff data which has to be formatted before it can roll out of your
printer
...
ps
Then print the PostScript file
...

8
...
2
...
Previewing formatted files
Anything that you can send to the printer can normally be sent to the screen as well
...

• TeX dvi files: with xdvi, or with KDE's kdvi
...
Adobe's reader supports PDF 1
...
5
...

• From within applications, such as Firefox or OpenOffice, you can usually select Print Preview from
one of the menus
...
2
...
2
...
General
Until a couple of years ago, the choice for Linux users was simple: everyone ran the same old LPD from
BSD's Net-2 code
...
CUPS is an implementation of the Internet Printing Protocol
(IPP), an HTTP-like RFC standard replacement protocol for the venerable (and clunky) LPD protocol
...
Printers and printing

139

Introduction to Linux
is distributed under the GNU Public License
...


8
...
2
...
They
let you choose the printer type from a list and allow easy testing
...
Check your system documentation before you attempt installing your printer
...
To check if this
feature is enabled, try browsing to localhost:631/help or localhost:631/
...
2
...
Buying a printer for Linux
As more and more printer vendors make drivers for CUPS available, CUPS will allow easy connection with
almost any printer that you can plug into a serial, parallel, or USB port, plus any printer on the network
...

Printers that only come with a Win9x driver could be problematic if they have no other support
...
org/ when in doubt
...
PostScript printers are usually a bit more expensive, but it is a
device-independent, open programming language and you're always 100% sure that they will work
...


8
...
Print problems
In this section, we will discuss what you can do as a user when something goes wrong
...


8
...
1
...
This will work when
other jobs are waiting to be printed in this printer's queue
...
Once they
arrive on the printer, it is too late to remove jobs using Linux tools
...
However, that might not be the best course of action, as you
might cause paper jams and other irregularities
...
3
...
My print hasn't come out
Use the lpq command and see if you can spot your job:

Chapter 8
...
699
Files
Size Time
(STDIN)
129 09:42:54
/etc/profile
917 09:43:20

Lots of printers have web interfaces these days, which can display status information by typing the printer's IP
address in your web browser:

Figure 8-1
...
Printers and printing

141

Introduction to Linux
Note that this is not the CUPS web interface and only works for printers supporting this feature
...

If your job ID is not there and not on the printer, contact your system administrator
...
If so, just wait, your job will get done in due time
...
If that's okay, the printer may need restarting
...

In the case of a network printer, try printing from another host
...
ps in case of a
PostScript printer, using an FTP client
...
If it doesn't work,
maybe the printer doesn't understand the format you are feeding it
...


8
...
Summary
The Linux print service comes with a set of printing tools based on the standard UNIX LPD tools, whether it
be the SystemV or BSD implementation
...


Table 8-1
...
5
...
If so, you may try:
• Installing the printer using the GUI on your system
...

• Printing a test page using the lp command
...

• Disconnect the printer from the network or the local machine/print-server
...
Printers and printing

142

Introduction to Linux
The following exercises can be done without printer or root access
...
g
...
Test the
results with the gv viewer
...

• Print the files anyway
...
Test it with gv
...
Test with xpdf
...
Test again with gv
...
Printers and printing

143

Chapter 9
...
In this chapter, we'll discuss how to get data to a safe
place using other hosts, floppy disks, CD-ROMs and tapes
...

Upon completion of this chapter, you will know how to:
♦ Make, query and unpack file archives
♦ Handle floppy disks and make a boot disk for your system
♦ Write CD-ROMs
♦ Make incremental backups
♦ Create Java archives
♦ Find documentation to use other backup devices and programs
♦ Encrypt your data

9
...
Introduction
Although Linux is one of the safest operating systems in existence, and even if it is designed to keep on going,
data can get lost
...


9
...
1
...
1
...
1
...
The process of archiving involves concatenating all listed files and taking out unnecessary blanks
...
tar was originally designed to archive data on tapes, but
it can also make archives, known as tarballs
...
1
...
2
It is common to leave out the dash-prefix with tar options, as you can see from the examples below
...
This may cause much headaches, such as if the archive needs to be recovered
Chapter 9
...
Use the GNU tar version on all systems to prevent your system
admin from bursting into tears
...
When working on other UNIX machines,
enter tar --help to find out which version you are using
...

In the example below, an archive is created and unpacked
...
jpg nimf
...
tar images/
images/
images/nimf
...
jpg
gaby:~> cd images
gaby:~/images> tar cvf images-without-a-dir
...
jpg
me+tux
...
jpg
gaby:~/images> cd
gaby:~> ls */*
...
tar
gaby:~> ls *
...
tar
gaby:~> tar xvf images-in-a-dir
...
jpg
images/me+tux
...
tar
-rw-r--r-- gaby/gaby 42888 1999-06-30 20:52:25 me+tux
...
jpg
gaby:~> tar xvf images/images-without-a-dir
...
jpg
nimf
...
jpg
me+tux
...
jpg

This example also illustrates the difference between a tarred directory and a bunch of tarred files
...

When a tape drive is connected to your machine and configured by your system administrator, the file names
ending in
...
A content listing is displayed because we used the verbose option
...
Fundamental Backup Techniques

145

Introduction to Linux
9
...
1
...
Incremental backups with tar
The tar tool supports the creation of incremental backups, using the -N option
...
If files are changed
more recent than date, they will be included in the backup
...
First, the initial archive is created and the timestamp on the initial backup
file is shown
...
tar java/*
...
java
java/error
...
java
java/income2
...
java
java/inputdevice
...
java
java/master
...
java
java/mood
...
java
java/test3
...
java
java/TestTwo
...
java
jimmy:~> ls -l /var/tmp/javaproggies
...
tar
jimmy:~> touch java/newprog
...
tar \
-cvp /var/tmp/incremental1-javaproggies
...
java 2> /dev/null
java/newprog
...
tar
java/newprog
...
If you don't do this, tar will print a message for each
unchanged file, telling you it won't be dumped
...
Say that you download an
archive into the directory containing your backups, and the archive contains files that have been created two
years ago
...

A better choice would be the -g option, which will create a list of files to backup
...
This is how it works:
jimmy:~> tar cvpf work-20030121
...
Fundamental Backup Techniques

146

Introduction to Linux
snapshot-20030121: ASCII text

The next day, user jimmy works on file3 a bit more, and creates file4
...
tar -g snapshot-20030121 work/
work/
work/file3
work/file4

These are some very simple examples, but you could also use this kind of command in a cronjob (see Section
4
...
4), which specifies for instance a snapshot file for the weekly backup and one for the daily backup
...

More information can be found in the tar documentation
...
There are tools that are easier to manage, however, when you want to archive entire
partitions or disks or larger projects
...
It will happen quite often that you need to install a software that comes in a
so-called "compressed tarball"
...
3 for an easier way to perform regular backups
...
1
...
3
...
The gzip command will add the suffix
...

jimmy:~> ls -la | grep tar
-rw-rw-r-- 1 jimmy jimmy

61440 Jun

6 14:08 images-without-dir
...
tar
jimmy:~> ls -la images-without-dir
...
gz
-rw-rw-r-- 1 jimmy jimmy
50562 Jun 6 14:08 images-without-dir
...
gz

Uncompress gzipped files with the -d option
...
See
the bzip2 info pages for more
...
The sensible thing to do after unpacking
that kind of archives is find the README and read it
...

The GNU tar command is aware of gzipped files
...
tar
...
tar
...
tgz files
...
tar
...

Chapter 9
...
1
...
4
...
It is a Java application that
combines multiple files into a single JAR archive file
...
When combined in a single archive, the
components of a Java application, can be downloaded much faster
...
In addition, it allows individual entries in an archive to be signed by the author, so that origins can be
authenticated
...

tar, jar and symbolic links
One noteworthy feature not really mentioned in the standard documentation is that jar will follow
symbolic links
...
The default in tar
is to only backup the symbolic link, but this behavior can be changed using the -h to tar
...
1
...
5
...
See Chapter 10
for more information on scp, ftp and more
...


9
...
Moving your data to a backup device
9
...
1
...
2
...
1
...
The name of the device may vary
depending on the size and number of floppy drives, contact your system admin if you are unsure
...

fdformat is the low-level floppy disk formatting tool
...

fdformat will display an error when the floppy is write-protected
...
Total capacity 1440 kB
...
done
Verifying
...


Chapter 9
...


Figure 9-1
...

Should you need it, install the mkbootdisk utility, which makes a floppy from which the current system can
boot
...
2
...
2
...
An example:
gaby:~> dd if=images-without-dir
...
gz of=/dev/fd0H1440
98+1 records in
98+1 records out
gaby~> dd if=/dev/fd0H1440 of=/var/tmp/images
...
gz
2880+0 records in
2880+0 records out
gaby:~> ls /var/tmp/images*
/var/tmp/images
...
gz

Note that the dumping is done on an unmounted device
...
For more
information on the possibilities of dd, read the man pages
...

Dumping disks
The dd command can also be used to make a raw dump of an entire hard disk
...
Fundamental Backup Techniques

149

Introduction to Linux

9
...
2
...
Your data will need to be formatted first
...
Check with df that
enough disk space is available, because a new file about the same size as the entire current directory will be
created:
[rose@blob recordables] df -h
...
2G 82% /home
[rose@blob recordables] du -h -s
...

[rose@blob recordables] mkisofs -J -r -o cd
...

<--snap-->
making a lot of conversions
<--/snap-->
98
...
After that, the CD can be created using the cdrecord tool with appropriate options:
[rose@blob recordables] cdrecord -dev 0,0,0 -speed=8 cd
...
10 (i686-pc-linux-gnu) (C) 1995-2001 Joerg Schilling
scsidev: '0,0,0'
scsibus: 0 target: 0 lun: 0
Linux sg driver version: 3
...
20
Using libscg version 'schily-0
...
0g'
Device seems to be: Generic mmc CD-RW
...

Driver flags
: SWABAUDIO
Starting to write CD/DVD at speed 4 in write mode for single session
...

Operation starts
...
Upon finishing the job, you will get a confirmation message:
Track 01: Total bytes read/written: 341540864/341540864
(166768 sectors)
...
One of the popular ones is xcdroast, which
is freely available from the X-CD-Roast web site and is included on most systems and in the GNU directory
...


Chapter 9
...
2
...
Backups on/from jazz drives, USB devices and other removables
These devices are usually mounted into the file system
...

In the example below, images are copied from a USB camera to the hard disk:
robin:~> mount /mnt/camera
robin:~> mount | grep camera
/dev/sda1 on /mnt/camera type vfat (rw,nosuid,nodev)

If the camera is the only USB storage device that you ever connect to your system, this is safe
...
Thus, if you first
connect a USB stick to your system, it will be on the /dev/sda entry, and if you connect your camera after
that, it will be assigned to /dev/sdb - provided that you do not have any SCSI disks, which are also on
/dev/sd*
...
6, a hotplug system called HAL (Hardware Abstraction Layer)
ensures that users don't have to deal with this burden
...

You can now copy the files:
robin:~> cp -R /mnt/camera/* images/
robin:~> umount /mnt/camera

Likewise, a jazz drive may be mounted on /mnt/jazz
...
conf and /etc/fstab to make this work
...
On systems with a 2
...
x kernel or higher, you may also
want to check the man pages for modprobe and modprobe
...


9
...
4
...
The mt tool is used for controlling the magnetic tape device, like
/dev/st0
...
Keep in mind that databases might need other backup procedures because
of their architecture
...
In larger environments, the freely available Amanda backup suite or a commercial
solution may be implemented to back up multiple machines
...


9
...
5
...
A short overview:
• SuSE: YaST now includes expanded backup and restore modules
...
They seem to be
in favour of the X-CD-Roast tool for moving backups to an external device
...

Chapter 9
...
This tool can write to a variety of devices and literally dumps the file(s) or file
system bit per bit onto the specified device
...


9
...
Using rsync
9
...
1
...
It is common on UNIX and UNIX-like
systems, easy to configure and use in scripts
...
Your "remote" device might just as well be a USB storage device or another partition on
your hard disk, you do not need to have two separated machines
...
3
...
An example: rsync to a USB storage device
As discussed in Section 3
...
2
...
Possibly, this should be done as root:
root@theserver# mkdir /mnt/usbstore
root@theserver# mount -t vfat /dev/sda1 /mnt/usbstore

Userfriendly
More and more distributions give access to removable devices for non-prilileged users and mount USB
devices, CD-ROMs and other removable devices automatically
...
See the USB Guide for help if
this does not work
...

Then you can start the actual backup, for instance of the /home/karl directory:
karl@theserver:~> rsync -avz /home/karl/ /mnt/usbstore

As usual, refer to the man pages for more
...
4
...
4
...
General remarks
9
...
1
...
Why should you encrypt data?
Encryption is synonym to secrecy
...

Apart from that, encryption can be applied to E-mails as well: normally, mail is not encrypted and it is often
sent in the open over the netwerk or the Internet
...


Chapter 9
...
4
...
2
...

In this guide we will only discuss the very simple usage of the encryption tools and show what you will need
in order to generate an encryption key and use it to encrypt data for yourself, which you can then safely store
in a public place
...


9
...
2
...
The pair consists of a private and
a public key
...
You always keep the private key, never share it with somebody else, or
they will be able to decrypt data that is only destined for you
...
The key pair is created using this command:
willy@ubuntu:~$ gpg --key-gen
gpg (GnuPG) 1
...
2
...
See the

2005 Free Software Foundation, Inc
...

welcome to redistribute it
file COPYING for details
...
gnupg' created
gpg: new configuration file `/home/willy/
...
conf' created
gpg: WARNING: options in `/home/willy/
...
conf' are not yet
active during this run
gpg: keyring `/home/willy/
...
gpg' created
gpg: keyring `/home/willy/
...
gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits
...

What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid
...
de>"
Real name: Willy De Wandel
Email address: wdw@mvg
...
vl>"

Chapter 9
...

Passphrase:

Now enetr your password
...
For verification, you need to enter the same phrase again
...
So it is a good idea to start some programs now, to move the mouse
cursor or to type some random characters in a terminal window
...


9
...
3
...
This is a sequence of 40
hexadecimal numbers, which is so long that it is very, very hard to generate the same key twice, on any
computer
...
The short form of this key consists of your
name, followed by the last 8 hexadecimal numbers
...
gnupg/pubring
...
vl>
sub
4096g/A3449CF7 2006-08-08

The key ID of this key is "BF5C3DBB"
...
Alternatively, you can send your
public key directly to the people who need it
...
Read the gpg man pages if you want to know more
...
4
...
Encrypt data
Now you can encrypt a
...
Use the gpg command like this:
gpg -e -r (part of) uid archive
The -e option tells gpg to encrypt, the -r option indicates who to encrypt for
...
An example:
willy@ubuntu:~$ gpg -e -r Willy /var/tmp/home-willy-20060808
...
Fundamental Backup Techniques

154

Introduction to Linux

9
...
5
...
The data will scroll over your
screen, but an encrypted copy will remain on disk
...
This is done using the -o
option to the gpg command:
willy@ubuntu:~$ gpg -d -o /var/tmp/home-willy-decrypt
...
tar
...
vl>"
4096 ELG-E key, ID A3449CF7, created 2006-08-08 (main key ID BF5C3DBB)
gpg: encrypted with 4096-bit ELG-E key, ID A3449CF7, created 2006-08-08
"Willy De Wandel (Willem) ...
Not even the system administrator will be able
to decrypt the data
...


9
...
Summary
Here's a list of the commands involving file backup:

Table 9-1
...

Record audio or data Compact Disks from a master
...

Encrypt and decrypt data
...

Copy MSDOS files to/from UNIX
...

Add an MSDOS file system to a low-level formatted floppy disk
...

Mount a file system (integrate it with the current file system by connecting it to a mount point)
...

Tape archiving utility, also used for making archives on disk instead of on tape
...


Chapter 9
...
6
...
Then further
compress the file using gzip or bzip2
...

• Format a floppy and put some files from your home directory on it
...

• DOS format the floppy
...

• What happens to an unformatted floppy when you want to mount it into the file system?
• If you have any USB storage, try to put a file on it
...

• When leaving files on a network server, it's best to encrypt them
...


Chapter 9
...
Networking
When it comes to networking, Linux is your operating system of choice, not only because
networking is tightly integrated with the OS itself and a wide variety of free tools and
applications are available, but for the robustness under heavy loads that can only be achieved
after years of debugging and testing in an Open Source project
...
After completing this, you will know more about
♦ Supported networking protocols
♦ Network configuration files
♦ Commands for configuring and probing the network
♦ Daemons and client programs enabling different network applications
♦ File sharing and printing
♦ Remote execution of commands and applications
♦ Basic network interconnection
♦ Secure execution of remote applications
♦ Firewalls and intrusion detection

10
...
Networking Overview
10
...
1
...

In order to get data over the network, for instance an E-mail from your computer to some computer at the
other end of the world, lots of different hard- and software needs to work together
...
Imagine your
E-mail program: it is able to talk to the computer operating system, through a specific protocol, but it is not
able to talk to the computer hardware
...
In turn, the computer needs to be able to communicate with the telephone line or other Internet
hookup method
...

All these different types of communication protocols are classified in 7 layers, which are known as the Open
Systems Interconnection Reference Model, the OSI Model for short
...
The simplified OSI Model
Layer name
Application layer
Transport layer
Network layer

Layer Protocols
HTTP, DNS, SMTP, POP,
...
Networking

157

Introduction to Linux
Network access layer PPP, PPPoE, Ethernet
Each layer can only use the functionality of the layer below; each layer can only export functionality to the
layer above
...
Let's take the example of your
E-mail message again: you enter it through the application layer
...
Your computer puts it on the network through the network access layer
...
At the destination, the receiving computer will
accept the message through it's own network layer, and will display it to the recepient using the transport and
application layer
...


10
...
2
...
We list only the most important:
10
...
2
...
TCP/IP
The Transport Control Protocol and the Internet Protocol are the two most popular ways of communicating
on the Internet
...

Very simply put, IP provides a solution for sending packets of information from one machine to another,
while TCP ensures that the packets are arranged in streams, so that packets from different applications don't
get mixed up, and that the packets are sent and received in the correct order
...

• man 7 tcp: Implementation of the TCP protocol
...

The Request For Comments documents contain the descriptions of networking standards, protocols,
applications and implementation
...

Your ISP usually has an RFC archive available, or you can browse the RFCs via
http://www
...
org/rfc
...

10
...
2
...
TCP/IPv6
Nobody expected the Internet to grow as fast as it does
...
Thus, IP version 6 was deviced to meet the needs of today's
Internet
...
Networking

158

Introduction to Linux
Unfortunately, not all applications and services support IPv6, yet
...
For some applications, the old protocol is still
used, for applications that have been reworked the new version is already active
...

More information can be found in the following documents:
• man 7 ipv6: the Linux IPv6 protocol implementation
...

10
...
2
...
PPP, SLIP, PLIP, PPPOE
The Linux kernel has built-in support for PPP (Point-to-Point-Protocol), SLIP (Serial Line IP), PLIP (Parallel
Line IP) and PPPP Over EThernet
...

Most Linux distributions provide easy-to-use tools for setting up an Internet connection
...
These data are entered in the graphical configuration tool, which will likely also
allow for starting and stopping the connection to your provider
...
1
...
4
...
Isdn4linux controls ISDN PC cards and can emulate a
modem with the Hayes command set ("AT" commands)
...

Check your system documentation
...
1
...
5
...
It allows a peer-to-peer network model which
provides basic functionality such as file and printer sharing
...

Linux provides full AppleTalk networking
...
It includes support for routing AppleTalk, serving UNIX
and AFS file systems using AppleShare and serving UNIX printers and accessing AppleTalk printers
...
1
...
6
...
The Server Message Block protocol (also called
Session Message Block, NetBIOS or LanManager protocol) is used on MS Windows 3
...

The basic functions of the Samba suite are: sharing Linux drives with Windows machines, accessing SMB
shares from Linux machines, sharing Linux printers with Windows machines and sharing Windows printers
Chapter 10
...

Most Linux distributions provide a samba package, which does most of the server setup and starts up smbd,
the Samba server, and nmbd, the netbios name server, at boot time by default
...
The daemons make a
Linux machine appear as an MS Windows host in an MS Windows My Network Places/Network
Neighbourhood window; a share from a Linux machine will be indistinguishable from a share on any other
host in an MS Windows environment
...
conf: describes the format of the main Samba configuration file
...
org mirror) contains an easy to read
installation and testing guide, which also explains how to configure your Samba server as a Primary
Domain Controller
...

10
...
2
...
Miscellaneous protocols
Linux also has support for Amateur Radio, WAN internetworking (X25, Frame Relay, ATM), InfraRed and
other wireless connections, but since these protocols usually require special hardware, we won't discuss them
in this document
...
2
...
2
...
Configuration of network interfaces
All the big, userfriendly Linux distributions come with various graphical tools, allowing for easy setup of the
computer in a local network, for connecting it to an Internet Service Provider or for wireless access
...

• RedHat Linux comes with redhat-config-network, which has both a graphical and a text mode
interface
...

• Mandrake/Mandriva comes with a Network and Internet Configuration Wizard, which is preferably
started up from Mandrake's Control Center
...

• On KDE systems: knetworkconf
...

Information that you will need to provide:
• For connecting to the local network, for instance with your home computers, or at work: hostname,
domainname and IP address
...

At work, this information is likely to be given to your computer automatically when you boot it up
...

• For connecting to the Internet: username and password for your ISP, telephone number when using a
modem
...

Chapter 10
...
2
...
Network configuration files
The graphical helper tools edit a specific set of network configuration files, using a couple of basic
commands
...
However, a couple of network configuration files are
common on all UNIX systems:
10
...
2
...
/etc/hosts
The /etc/hosts file always contains the localhost IP address, 127
...
0
...
Never remove this line! Sometimes contains addresses of additional hosts, which can be
contacted without using an external naming service such as DNS (the Domain Name Server)
...

127
...
0
...
localdomain
localhost
192
...
52
...
mylan
...
168
...
11
winxp
...
com
winxp

Read more in man hosts
...
2
...
2
...
conf
The /etc/resolv
...
3
...
This file contains your
domain name and the name server(s) to contact:
search mylan
...
134
...
4

Read more in the resolv
...

10
...
2
...
/etc/nsswitch
...
conf file defines the order in which to contact different name services
...
conf
hosts: files dns

This instructs your computer to look up hostnames and IP addresses first in the /etc/hosts file, and to
contact the DNS server if a given host does not occur in the local hosts file
...

More in man nsswitch
...


10
...
3
...
Networking

161

Introduction to Linux
10
...
3
...
The ip command
The distribution-specific scripts and graphical tools are front-ends to ip (or ifconfig and route on older
systems) to display and configure the kernel's networking configuration
...

The following commands show IP address and routing information:
benny@home benny> ip addr show
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127
...
0
...
255
...
255 scope host lo
inet6 ::1/128 scope host
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:50:bf:7e:54:9a brd ff:ff:ff:ff:ff:ff
inet 192
...
42
...
168
...
255 scope global eth0
inet6 fe80::250:bfff:fe7e:549a/10 scope link
benny@home benny> ip route show
192
...
42
...
0
...
0/8 dev lo scope link
default via 192
...
42
...
Do not
ever change the local loop configuration, or your machine will start mallfunctioning! Wireless
interfaces are usually defined as "wlan0"; modem interfaces as "ppp0", but there might be other
names as well
...
0
...
1, the physical interface can have
any other combination
...
The local loop has 6 pairs of all zeros, the
physical loop has 6 pairs of hexadecimal characters, of which the first 3 pairs are vendor-specific
...
2
...
2
...
Use it without
option for displaying network interface information:
els@asus:~$ /sbin/ifconfig
eth0
Link encap:Ethernet HWaddr 00:50:70:31:2C:14
inet addr:60
...
67
...
255
...
255 Mask:255
...
255
...
6 GiB) TX bytes:2874632613 (2
...
0
...
1

Chapter 10
...
0
...
0

162

Introduction to Linux
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:765762 errors:0 dropped:0 overruns:0 frame:0
TX packets:765762 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:624214573 (595
...
2 MiB)

Here, too, we note the most important aspects of the interface configuration:
• The IP address is marked with "inet addr"
...

Both ifconfig and ip display more detailed configuration information and a number of statistics about each
interface and, maybe most important, whether it is "UP" and "RUNNING"
...
2
...
3
...
This is done using the cardctl control utility, or the pccardctl on newer distributions
...
Prior to taking the
card out, use this command:
cardctl eject
However, a good distribution should provide PCMCIA support in the network configuration tools, preventing
users from having to execute PCMCIA commands manually
...
2
...
4
...
Your primary source for
extra information is the man pages for the services you want to set up
...

• LDP HOWTO Index, section 4
...

• Most systems have a version of the ip-cref file (locate it using the locate command); the PS
format of this file is viewable with for instance gv
...
2
...
Network interface names
On a Linux machine, the device name lo or the local loop is linked with the internal 127
...
0
...
The
computer will have a hard time making your applications work if this device is not present; it is always there,
even on computers which are not networked
...
Networking

163

Introduction to Linux
The first ethernet device, eth0 in the case of a standard network interface card, points to your local LAN IP
address
...
Routers, connecting networks
together, have one network device for each network they serve
...

There are many more names, for instance for Virtual Private Network interfaces (VPNs), and multiple
interfaces can be active simultaneously, so that the output of the ifconfig or ip commands might become quite
extensive when no options are used
...
In that case, they
are numbered sequentially: the first will get the number 0, the second will get a suffix of 1, the third will get 2,
and so on
...


10
...
5
...

Routing information can be displayed with the -nr option to the netstat command:
bob:~> netstat -nr
Kernel IP routing table
Destination Gateway
192
...
42
...
0
...
0
127
...
0
...
0
...
0
0
...
0
...
168
...
1

Genmask
255
...
255
...
0
...
0
0
...
0
...
It only has one network device, eth0
...

The modern way
The novel way to get this info from your system is by using the ip command:
ip route show
When this machine tries to contact a host that is on another network than its own, indicated by the line starting
with 0
...
0
...
168
...
1, and it
will use its primary interface, eth0, to do this
...
168
...
0, will also be contacted through the
primary network interface, but no router is necessary, the data are just put on the network
...
If you have the occasion to connect to an
application server, for instance at work, it is most educating to check the routing information
...
2
...
Other hosts
An impressive amount of tools is focused on network management and remote administration of Linux
machines
...
It would lead us too far to discuss them
in this document, so please refer to the program-specific documentation
...
Networking

164

Introduction to Linux
We will only discuss some common UNIX/Linux text tools in this section
...
2
...
1
...
eunet
...
eunet
...
has address 193
...
208
...
be
eunet
...
SOA dns
...
be
...
Belgium
...
net
...
be
...
eunet
...

eunet
...
name server ns
...
net
...
be
...
eunet
...


Similar information can be displayed using the dig command, which gives additional information about how
records are stored in the name server
...
2
...
2
...
If your system is configured to send more than one packet, interrupt ping
with the Ctrl+C key combination:
[emmy@pc10 emmy]$ ping a
...
be
PING a
...
be (1
...
8
...
20
...
26: 56(84) bytes of data
...
host
...
2
...
3):icmp_seq=0 ttl=244 time=99
...
host
...
977/99
...
977/0
...
2
...
3
...
eunet
...
eunet
...
74
...
177),30 hops max,38b packets
1 blob (10
...
0
...
297ms 0
...
174ms
2 adsl-65
...
be (217
...
111
...
120ms 13
...
009ms
3 194
...
255
...
78
...
177)
13
...
308ms 12
...
intl2
...
brussels
...
be (195
...
2
...
123ms 13
...
527ms
5 pecbru2
...
belbone
...
78
...
118)
16
...
889ms 13
...
kpnbelgium
...
119
...
9)
14
...
546ms 15
...
eunet
...
207
...
49)
16
...
661ms 18
...
Leuven
...
EU
...
207
...
1)
22
...
193ms 18
...
Belgium
...
net (193
...
208
...
758ms * 25
...


Chapter 10
...
2
...
4
...
com
[whois
...
net]
Whois Server Version 1
...
COM
Registrar: NETWORK SOLUTIONS, INC
...
networksolutions
...
networksolutions
...
NS
...
COM
Name Server: TWDNS-02
...
AOL
...
NS
...
COM
Name Server: TWDNS-04
...
AOL
...
COM,
...
ORG,
...

[whois
...
com]
$<--snap server message-->
Registrant:
Turner Broadcasting (CNN-DOM)
1 CNN Center
Atlanta, GA 30303
Domain Name: CNN
...

Record expires on 23-Sep-2009
...

Database last updated on 4-Apr-2002 20:10:00 EST
...
NS
...
COM
TWDNS-02
...
AOL
...
NS
...
COM
TWDNS-04
...
AOL
...
174
...
151
152
...
239
...
188
...
88
64
...
147
...
com,
...
org and
...
be domains:
whois domain
...
dns
...
Networking

166

Introduction to Linux

10
...
Internet/Intranet applications
The Linux system is a great platform for offering networking services
...


10
...
1
...
3
...
1
...
A daemon or service can run in standalone mode,
or it can be dependent on another service to be activated
...
They are most likely started up at system boot time,
and they wait for requests on the specific connection points or ports for which they are set up to listen
...
A web server is a typical
example: you want it to be available 24 hours a day, and if it is too busy it should create more listening
instances to serve simultaneous users
...

An example of a standalone network service on your home computer might be the named (name daemon), a
caching name server
...
0 1
...
Examples could be the FTP service, the secure copy service or the finger service
...

10
...
1
...
(x)inetd
On your home PC, things are usually a bit calmer
...
In those cases, starting all the services which you only need occasionally and having
them run all the time would be a waste of resources
...

This super-server, the Internet services daemon, is started up at system initialization time
...
One or the other is
usually running on every Linux system:
bob:~> ps -ef | grep inet
root 926
1 0 Mar14 ?
00:00:00 xinetd-ipv6 -stayalive -reuse \
-pidfile /var/run/xinetd
...
conf, for inetd, and in the directory /etc/xinetd
...
Commonly managed
services include file share and print services, SSH, FTP, telnet, the Samba configuration daemon, talk and
time services
...
Networking

167

Introduction to Linux
As soon as a connection request is received, the central server will start an instance of the required server
...
1 0
...
7 0
...
localdomain: anonymous/bob@his
...
com: IDLE

Of course, the same happens when you open connections to remote hosts: either a daemon answers directly, or
a remote (x)inetd starts the service you need and stops it when you quit
...
3
...
Mail
10
...
2
...
Servers
Sendmail is the standard mail server program or Mail Transport Agent for UNIX platforms
...
More information about how to configure Sendmail is included with the sendmail and sendmail-cf
packages, you may want to read the README and README
...

The man sendmail and man aliases are also useful
...
While
Sendmail is a monolithic program, Qmail consists of smaller interacting program parts that can be better
secured
...

These servers handle mailing lists, filtering, virus scanning and much more
...
Examples of mailing list software are Mailman, Listserv, Majordomo and
EZmlm
...

Amavis and Spamassassin are free implementations of a virus scanner and a spam scanner
...
3
...
2
...
IMAP and POP both allow offline
operation, remote access to new mail and they both rely on an SMTP server to send mail
...

• It can store as well as fetch mail messages
...

• It supports concurrent updates and shared mailboxes
...

• IMAP works both on-line and off-line
...


Chapter 10
...
3
...
3
...
Pick
your favorite
...
It is a simple interface
to send messages and small files to other users, who can then save the message, redirect it, reply to it etcetera
...
employer@whereIwant2work
...
txt
The elm mail reader is a much needed improvement to mail, and so is pine (Pine Is Not ELM)
...

For those users who prefer a graphical interface to their mail (and a tennis elbow or a mouse arm), there are
hundreds of options
...
Kmail is popular among KDE users
...
Evolution mail and news reader

Chapter 10
...

An overview is available via the Linux Mail User HOWTO
...
It fetches mail from
remote mail servers (POP, IMAP and some others) and forwards it to your local delivery system
...
It can be run in daemon mode to repeatedly poll one
or more systems at a specified interval
...

The procmail filter can be used for filtering incoming mail, to create mailing lists, to pre-process mail, to
selectively forward mail and more
...
Procmail has been around for years on UNIX and Linux machines and
is a very robust system, designed to work even in the worst circumstances
...

A note on E-mail Etiquette
Some people these days seem to think that an E-mail message shouldn't be too formal
...
If you are writing to someone you don't know, best to keep some distance, just like you would do
in a traditional letter
...


10
...
3
...
3
...
1
...
Most Linux
distributions include Apache
...
Given the appropriate hardware and configuration it can support the highest loads
...
The most
important configuration file is httpd
...
Should you need help, you can
find it in the httpd man page or on the Apache website
...
3
...
2
...
Netscape Navigator as the
only decent option has long been a thing of the past, as Mozilla/Firefox offers a competitive alternative
running on many other operating systems, like MS Windows and MacOS X as well
...
Opera is a commercial browser, compact and fast
...

Among the popular text based browsers are lynx and links
...
Text browsers are fast and handy when no graphical environment is
available, such as when used in scripts
...
Networking

170

Introduction to Linux
10
...
3
...
Proxy servers
10
...
3
...
1
...
Especially in environments with
lots of users, a proxy server can enable faster downloads of web pages
...

When a user asks for a web page that has already been requested previously, the proxy server will give that
page to the user directly, so that s/he does not need to get it from the Internet, which would take longer
...
In some environments, usage of the proxy server is compulsory, in other environments you
may have the choice whether or not to use it
...
3
...
3
...
Proxy configuration

If you have the proxy server name and port, it should be rather obvious to feed that information into your
browser
...
For your convenience, you might want to add a line like the following to
your ~/
...


10
...
4
...
3
...
1
...
See the exercises
...

Most Linux distributions contain the anonftp package, which sets up an anonymous FTP server tree and
accompanying configuration files
...
3
...
2
...
The ncftp program offers extra features such as a nicer and
more comprehensible user interface, file name completion, append and resume functions, bookmarking,
session management and more:
thomas:~> ncftp blob
NcFTP 3
...
3 (April 15, 2001) by Mike Gleason (ncftp@ncftp
...

Connecting to blob
...
some
...
6
...


Chapter 10
...

Guest login ok, access restrictions apply
...

ncftp / > help
Commands may be abbreviated
...

'help ' gives a brief description of
...
And again, a number of GUI applications
are available
...

Your user name and password might be captured by malevolent fellow network users! Use secure FTP
instead; the sftp program comes with the Secure SHell suite, see Section 10
...
4
...


10
...
5
...
A
short and incomplete list of the most popular programs:
• gaim: multi-protocol instant messaging client for Linux, Windows and Mac, compatible with MSN
Messenger, ICQ, IRC and much more; see the Info pages or the Gaim site for more
...
X-Chat

Chapter 10
...

• aMSN: an MSN clone
...

• gnomemeeting: videoconferencing program for UNIX (now Ekiga)
...

• psi: jabber client, see the PSI Jabber Client Homepage
...
skype
...
Skype is free but not open
...
gizmoproject
...


10
...
6
...

There are a couple of interesting newsgroups in the comp
...
A lot of mail clients support newsgroup browsing as well, check your program or
see your local Open Source software mirror for text clients such as tin, slrnn and mutt, or download Mozilla
or one of a number of other graphical clients
...
com keeps a searchable archive of all newsgroups, powered by Google
...


Chapter 10
...
3
...
The Domain Name System
All these applications need DNS services to match IP addresses to host names and vice versa
...
Most UNIX systems can run named, which is part of the BIND (Berkeley Internet
Name Domain) package distributed by the Internet Software Consortium
...

Your main client configuration file is /etc/resolv
...
org
nameserver 192
...
42
...
74
...
137

More information can be found in the Info pages on named, in the
/usr/share/doc/bind[-] files and on the Bind project homepage
...


10
...
8
...
It is used to control vital networking parameters such as IP addresses and name servers of
hosts
...
For configuring the server, you will need to read the
HOWTO
...
Check your system documentation if you need to configure your machine as a DHCP client
...
3
...
Authentication services
10
...
9
...
Traditional
Traditionally, users are authenticated locally, using the information stored in /etc/passwd and
/etc/shadow on each system
...

These files are often the first candidates for being examined by hackers, so make sure the permissions and
ownerships are strictly set as should be:
bob:~> ls -l /etc/passwd /etc/shadow
-rw-r--r-1 root
root
-r-------1 root
root

1803 Mar 10 13:08 /etc/passwd
1116 Mar 10 13:08 /etc/shadow

10
...
9
...
PAM
Linux can use PAM, the Pluggable Authentication Module, a flexible method of UNIX authentication
...

Chapter 10
...

• Great flexibility and control over authentication for the administrator and application developer
...
Instead, they can focus purely on the details of their program
...
d contains the PAM configuration files (used to be /etc/pam
...
Each
application or service has its own file
...

♦ account: checks to make sure that access is allowed for the user (the account has not
expired, the user is allowed to log in at this time of day, and so on)
...

♦ session: used after a user has been authenticated
...

The order in which modules are stacked, so that multiple modules can be used, is very important
...
Values can be required,
requisite, sufficient or optional
...

• Arguments: information for the modules
Shadow password files are automatically detected by PAM
...

10
...
9
...
LDAP
The Lightweight Directory Access Protocol is a client-server system for accessing global or local directory
services over a network
...
It includes slapd, a stand-alone
server; slurpd, a stand-alone LDAP replication server; libraries implementing the LDAP protocol and a series
of utilities, tools and sample clients
...

For example, all of the different lists of users within your organization can be merged into one LDAP
directory
...
It can
also be accessed by users who need directory information
...
500 Lite benefits include its ease of implementation (compared to X
...

On the negative side, if you want to use LDAP, you will need LDAP-enabled applications or the ability to use
LDAP gateways
...
Also, while LDAP does support some access control, it does not possess as
many security features as X
...


Chapter 10
...
Common examples are mail address lookups, central
authentication in combination with PAM, telephone directories and machine configuration databases
...
More information can be found in the LDAP Linux HOWTO, which discusses
installation, configuration, running and maintenance of an LDAP server on Linux
...


10
...
Remote execution of applications
10
...
1
...
The connections can be secure or insecure
...


10
...
2
...

While seldom used because they are blatantly insecure, they still come with almost every Linux distribution
for backward compatibility with UNIX programs
...
Telnet is one
of the most powerful tools for remote access to files and remote administration, allowing connections from
anywhere on the Internet
...

There is no difference between working on the local machine and using the remote machine
...

For normal remote execution of programs, Secure SHell or ssh is advised
...

However, telnet is still used in many cases
...
168
...
1
...

Escape character is '^]'
...
some
...
11
...
11
...
net
250-m1
...
net Hello blob
...
net [10
...
0
...
Networking

176

Introduction to Linux
250-ONEX
250-ETRN
250-XUSR
250 HELP
mail from: jimmy@some
...
1
...
net
...
net
250 2
...
5 davy@some
...
Recipient ok
data
354 Enter mail, end with "
...

250 2
...
0 g2MA1R619237 Message accepted for delivery
quit
221 2
...
0 m1
...
net closing connection
Connection closed by foreign host
...
some
...
39
...
23
...
some
...

Escape character is '^]'
...
1
HTTP/1
...
3
...
8
...
9
...
0
...
0
...
24_01
Last-Modified: Fri, 04 Jan 2002 08:21:00 GMT
ETag: "70061-68-3c3565ec"
Accept-Ranges: bytes
Content-Length: 104
Connection: close
Content-Type: text/html
Connection closed by foreign host
...


10
...
3
...
4
...
1
...
3
...

It is important to realize the distinction between the X server and the X client application(s)
...
The
X client, on the other hand, does not access the input and output devices directly
...
It is the X client which does the real work, like computing values,
running applications and so forth
...


Chapter 10
...
All the applications you are running (for example, Gimp, a terminal window, your
browser, your office application, your CD playing tool, and so on) are clients to your X server
...

This client/server nature of the X system makes it an ideal environment for remote execution of applications
and programs
...
Such machines, purely acting as servers for X, are called X terminals and were once
very popular
...

10
...
3
...
Telnet and X
If you would want to use telnet to display graphical applications running on a remote machine, you first need
to give the remote machine access to your display (to your X server!) using the xhost command, by typing a
command similar to the one below in a terminal window on your local machine:
davy:~> xhost +remote
...
com

After that, connect to the remote host and tell it to display graphics on the local machine by setting the
environment variable DISPLAY:
[davy@remote ~] export DISPLAY="local
...
com:0
...

This procedure assumes that you have some sort of X server (XFree86, X
...
The architecture and operating system of the client
machine are not important as long as they allow you to run an X server on it
...


10
...
4
...
4
...
1
...
Most Linux systems will run a version of OpenSSH, an Open Source implementation of the SSH
protocol, providing secure encrypted communications between untrusted hosts over an untrusted network
...

The ssh client connects and logs into the specified host name
...
The
configuration file is rather self-explanatory and by defaults enables most common features
...

When the user's identity has been accepted by the server, the server either executes the given command, or
logs into the machine and gives the user a normal shell on the remote machine
...

Chapter 10
...

When connecting to a host for the first time, using any of the programs that are included in the SSH
collection, you need to establish the authenticity of that host and acknowledge that you want to connect:
lenny ~> ssh blob
The authenticity of host 'blob (10
...
0
...

RSA fingerprint is 18:30:50:46:ac:98:3c:93:1a:56:35:09:8d:97:e3:1d
...
168
...
2' (RSA) to the list of
known hosts
...

lenny is in ~

It is important that you type "yes", in three characters, not just "y"
...
ssh/known_hosts
file, see Section 10
...
4
...

If you just want to check something on a remote machine and then get your prompt back on the local host, you
can give the commands that you want to execute remotely as arguments to ssh:
lenny ~> ssh blob who
jenny@blob's password:
root
tty2
Jul 24 07:19
lena
tty3
Jul 23 22:24
lena
0:
Jul 25 22:03
lenny ~> uname -n
magrat
...
com

10
...
4
...
X11 and TCP forwarding
If the X11Forwarding entry is set to yes on the target machine and the user is using X applications, the
DISPLAY environment variable is set, the connection to the X11 display is automatically forwarded to the
remote side in such a way that any X11 programs started from the shell will go through the encrypted channel,
and the connection to the real X server will be made from the local machine
...
Forwarding of X11 connections can be configured on the command line or in the sshd
configuration file
...
This is normal, and happens because ssh creates a proxy X server on the server machine (that runs the X
client application) for forwarding the connections over the encrypted channel
...
We use xclock in the example, since it is a small program which is
generally installed and ideal for testing:

Figure 10-3
...
Networking

179

Introduction to Linux

SSH will also automatically set up Xauthority data on the server machine
...
The real
authentication cookie is never sent to the server machine (and no cookies are sent in the plain)
...

The X server
This procedure assumes that you have a running X server on the client where you want to display the
application from the remote host
...
org server for
MS Windows clients and others) or Exceed, it should be possible to set up a remote connection with any
Linux or UNIX machine
...
4
...
3
...
Host keys are stored in $HOME/
...
Additionally, the file /etc/ssh/ssh_known_hosts is automatically checked for known hosts
...
If a host's identification ever changes, ssh warns
about this and disables password authentication to prevent a Trojan horse from getting the user's password
...
In environments where high security is needed, sshd can even be configured to
prevent logins to machines whose host keys have changed or are unknown
...
Networking

180

Introduction to Linux
10
...
4
...
Secure remote copying
The SSH suite provides scp as a secure alternative to the rcp command that used to be popular when only rsh
existed
...

Unlike rcp, scp will ask for passwords or passphrases if they are needed for authentication:
lenny /var/tmp> scp Schedule
...
gz blob:/var/tmp/
lenny@blob's password:
Schedule
...
gz 100% |*****************************| 100 KB 00:00
lenny /var/tmp>

Any file name may contain a host and user specification to indicate that the file is to be copied to/from that
host
...
See the Info pages for more information
...

lenny@blob's password:
sftp> cd /var/tmp
sftp> get Sch*
Fetching /var/tmp/Schedule
...
gz to Schedule
...
gz
sftp> bye
lenny /var/tmp>

Secure copy or FTP GUIs
Don't feel comfortable with the command line yet? Try Konqueror's capabilities for secure remote copy,
or install Putty
...
4
...
5
...
It can create RSA
keys for use by SSH protocol version 1 and RSA or DSA keys for use by SSH protocol version 2
...
ssh/identity, id_dsa or id_rsa
...

Normally this program generates the key and asks for a file in which to store the private key
...
pub appended
...
The
passphrase may be empty to indicate no passphrase (host keys must have an empty passphrase), or it may be a
string of arbitrary length
...
If the passphrase is lost or forgotten, a new key must be
generated and copied to the corresponding public keys
...
All information can be found in the man or Info pages
...
Networking

181

Introduction to Linux

10
...
5
...
You
could, for example, run MS Word on a Windows NT machine and display the output on your Linux desktop
...
VNC is probably the easiest way to have X connections on a PC
...
When you are running a PC X server, and the PC crashes or is restarted, all
remote applications that you were running will die
...

• It is small and simple, no installation needed, can be run from a floppy if needed
...

• Sharable: one desktop may be displayed on multiple viewers
...

More information can be found in the VNC client man pages (man vncviewer) or on the VNC website
...
4
...
The rdesktop protocol
In order to ease management of MS Windows hosts, recent Linux distributions support the Remote Desktop
Protocol (RDP), which is implemented in the rdesktop client
...

Surprise your friends (or management) with the fullscreen mode, multiple types of keyboard layouts and
single application mode, just like the real thing
...
The
project's homepage is at http://www
...
org/
...
4
...
Cygwin
Cygwin provides substantial UNIX functionality on MS Windows systems
...
From a Cygwin Bash shell, type the command
/usr/X11R6/bin/XWin
...
You need to change the X Display Manager (XDM) configuration and
possibly the X Font Server (XFS) configuration to enable this type of connection, where you get a login
screen on the remote machine
...

If you do not need to display the entire desktop, you can use SSH in Cygwin, just like explained in Section
10
...
4
...


Chapter 10
...
5
...
5
...
Introduction
As soon as a computer is connected to the network, all kinds of abuse becomes possible, be it a UNIX-based
or any other system
...
There are, however, a couple of fairly logical things even a
novice user can do to obtain a very secure system, because most break-ins are the result of ignorant or careless
users
...
The questions you should be asking yourself, however,
are more on the lines of:
• Do you want to be in control of your own system?
• Do you want to (unwittingly) participate in criminal activities?
• Do you want your equipment to be used by someone else?
• Do you want to take risks on losing your Internet connection?
• Do you want to rebuild your system every time it has been hacked?
• Do you want to risk personal or other data loss?
Presuming you don't, we will quickly list the steps you can take to secure your machine
...


10
...
2
...
If the number of ports that are open for the outside world are
kept to a minimum, this is all the better to keep an overview
...

A rule of thumb is that if you don't recognize a particular service, you probably won't need it anyway
...
Don't rely on what should be
running, check which services are listening on what TCP ports using the netstat command:
[elly@mars ~] netstat -l | grep tcp
tcp
0
0 *:32769
tcp
0
0 *:32771
tcp
0
0 *:printer
tcp
0
0 *:kerberos_master
tcp
0
0 *:sunrpc
tcp
0
0 *:6001
tcp
0
0 *:785
tcp
0
0 localhost
...

• X11 on server machines
...

Chapter 10
...

• Don't allow FTP unless an FTP server is required
...

• Don't run an MTA if you're not actually on a mail server
...

Stop running services using the chkconfig command, the initscripts or by editing the (x)inetd configuration
files
...
5
...
Update regularly
Its ability to adapt quickly in an ever changing environment is what makes Linux thrive
...
After that, update all the packages you use regularly
...
Check the documentation,
and ensure that everything runs normal after updating
...
General Linux only security issues are reported among others at
Linuxsecurity
...

Updating is an ongoing process, so it should be an almost daily habit
...
5
...
Firewalls and access policies
10
...
4
...
What is a firewall?
In the previous section we already mentioned firewall capabilities in Linux
...

Firewall is a vague term that can mean anything that acts as a protective barrier between us and the outside
world, generally the Internet
...
Or it can be a combination of components, including various combinations of hardware and
software
...

After disabling unnecessary services, we now want to restrict accepted services as to allow only the minimum
required connections
...

10
...
4
...
Packet filters
The first line of defense is a packet filter, which can look inside IP packets and make decisions based on the
content
...

One of the most noteworthy enhancements in the newer kernels is the stateful inspection feature, which not
only tells what is inside a packet, but also detects if a packet belongs or is related to a new or existing
Chapter 10
...

The Shoreline Firewall or Shorewall for short is a front-end for the standard firewall functionality in Linux
...

10
...
4
...
TCP wrappers
TCP wrapping provides much the same results as the packet filters, but works differently
...
It controls connections at the application level rather than at the network level
...
In
addition, these tools include logging and utilization management capabilities that are easy to configure
...

The host based access is controlled in the hosts
...
deny files
...

10
...
4
...
Proxies
Proxies can perform various duties, not all of which have much to do with security
...

Usually in combination with a packet filter, but sometimes all by themselves, proxies provide an extra level of
control
...

10
...
4
...
Access to individual applications
Some servers may have their own access control features
...
For every service you want to offer check which configuration files apply
...
5
...
6
...
" Of course, log files should be checked regularly, manually or automatically
...


10
...
5
...
They can either be
designed to catch an active break-in attempt in progress, or to detect a successful break-in after the fact
...
There are
two basic types of IDS: those protecting networks, and those protecting individual hosts
...
Networking

185

Introduction to Linux
For host based IDS, this is done with utilities that monitor the file system for changes
...
Anyone who gets
in and gets root access will presumably make changes to the system somewhere
...
Some systems come with the tripwire monitoring
system, which is documented at the Tripwire Open Source Project website
...
Snort is an Open Source example of such a program
...
com features an open Intrusion detection database, arachNIDS
...
5
...
More tips
Some general things you should keep in mind:
• Do not allow root logins
...

• Direct root access is always dangerous and susceptible to human errors, be it by allowing root login or
by using the su - command
...

• Take passwords seriously
...
Change your passwords regularly
...
Avoid telnet, FTP and E-mail clients and other client programs which
send unencrypted passwords over the network
...

• Limit resources using quota and/or ulimit
...

• The SANS institute has more tips and tricks, sorted per distribution, with mailing list service
...
Verify new packages before
installing
...

• Run private services on odd ports instead of the ones expected by possible hackers
...
After a while, you can almost feel when something is happening
...
5
...
Have I been hacked?
How can you tell? This is a checklist of suspicious events:
• Mysterious open ports, strange processes
...

• Login problems
...

• Damaged or missing log files, syslog daemon behaving strange
...

• Unexpectedly modified configuration files
...

• Unidentified temporary files
...
Networking

186

Introduction to Linux

10
...
8
...
Then take the following actions in this order:
• Disconnect the machine from the network
...

• Backup important non-system data
...

• Re-install the system
...

• Restore from system and data backups
...

• Re-examine the system: block off unnecessary services, check firewall rules and other access policies
...


10
...
Summary
Linux and networking go hand in hand
...
The standard UNIX networking tools are provided in each distribution
...

Linux is well known as a stable platform for running various Internet services, the amount of Internet software
is endless
...

We briefly touched the subject of security
...

Increasing network security is mainly done by applying frequent updates and common sense
...
New commands in chapter 10: Networking
Command
ftp
host
ifconfig
ip
netstat
ping
rdesktop
route
scp
sftp
ssh

Meaning
Transfer files to another host (insecure)
...

Display IP address information
...

Display routing information and network statistics
...

Display and MS Windows desktop on your Linux system
...

Secure copy files to and from other hosts
...

Make an encrypted connection to another host
...
Networking

187

Introduction to Linux
ssh-keygen
telnet
tracepath/traceroute
whois
xclock
xhost

Generate authentication keys for Secure SHell
...

Print the route that packets follow to another host
...

X Window clock application, handy for testing remote display
...


10
...
Exercises
10
...
1
...

• Suppose no DNS is available
...
com domain?
• Send an E-mail to your local account
...
How can you check
that it really arrived?
• Does your machine accept anonymous FTP connections? How do you use the ncftp program to
authenticate with your user name and password?
• Does your machine run a web server? If not, make it do so
...
7
...
Remote connections
• From your local workstation, display a graphical application, such as xclock on your neighbour's
screen
...
Use a secure connection!
• Set up SSH keys so you can connect to your neighbour's machine without having to enter a password
...
Archive and compress before starting the data transfer! Connect to the remote host using
ssh, unpack the backup, and put one file back on the original machine using sftp
...
7
...
Security
• Make a list of open (listening) ports on your machine
...
Which services would you deactivate? How would you do
that?
• Install available updates
...


Chapter 10
...
Sound and Video
This chapter addresses the following tasks (briefly, as the field of sound and video is very
wide):
♦ Sound card configuration
♦ Playing CDs, copying CDs,
♦ Playing music files
♦ Volume control
♦ Video and television
♦ Recording sound

11
...
Audio Basics
11
...
1
...
Likewise, should you ever need to replace your audio hardware, most systems provide tools that allow
easy setup and configuration of the device
...
If you can hear the samples that are played during configuration, just click OK and
everything will be set up for you
...
After that, you will have to provide the correct I/O port, IRQ and DMA
settings
...
If you are on a dual
boot system with MS Windows, this information can be found in the Windows Control Panel as well
...
These are
described in the Linux Sound HOWTO
...
1
...
Drivers and Architecture
There are generally two types of sound architecture: the older Open Sound System or OSS, which works with
every UNIX-like system, and the newer Advanced Linux Sound Architecture or ALSA, that has better support
for Linux, as the name indicates
...
We
will focus here on the ALSA system
...
Only some high-end professional solutions and
some cards developed by manufacturers refusing to document their chipset specifications are unsupported
...
alsa-project
...
php?vendor=All#matrix
...
Additionally, distributions usually
provide their own tools for configuring the sound card; these tools might even integrate the old and the new
way of handling sound devices
...
Sound and Video

189

Introduction to Linux

11
...
Sound and video playing
11
...
1
...
Desktop
managers usually include a graphical tool, such as the gnome-cd player in Gnome, that can be started from a
menu
...
You do not have to mount an audio
CD into the file system in order to listen to it
...
If your CD
is a data CD containing
...
How to mount CDs into the file system is
explained in Section 7
...
5
...
wav is probably the most
popular
...
mp3, come with most distributions
or are downloadable as separate packages
...

Audio-CD creation is eased, among many others, with the kaudiocreator tool from the KDE suite
...

CD burning is covered in general in Section 9
...
2
...
2
...
Playing music files
11
...
2
...
mp3 files
The popular
...
Most distributions include multiple
programs that can play these files
...


Figure 11-1
...

Restrictions
Chapter 11
...
You might need to install extra software to be able to play your
music
...
mp3
MPlayer 1
...
4
...
mp3
...
17% (98304 bytes)
Audio file detected
...
mp3
Artist: Diana-Krozon
Album: Super-Star
Year:
Comment:
Genre: Unknown
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
mpg123: Can't rewind stream by 450 bits!
AUDIO: 44100 Hz, 2 ch, s16le, 160
...
34% (ratio: 20000->176400)
Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le
...

Video: no video
Starting playback
...
8 (03:23:
...
8% 12%

11
...
2
...
Other formats
It would lead us too far to discuss all possible audio formats and ways to play them
...
The format was developed because MP3 is patented
...

• SoX or Sound eXchange: actually a sound converter, comes with th e play program
...
wav,
...

• Playmidi: a MIDI player, see the GNU directory
...

• mplayer: plays just about anything, including mp3 files
...

• hxplay: supports RealAudio and RealVideo, mp3, mp4 audio, Flash, wav and more, see HelixDNA
(not all components of this software are completely free)
...

Check your system documentation and man pages for particular tools and detailed explanations on how to use
them
...
Sound and Video

191

Introduction to Linux
I don't have these applications on my system!
A lot of the tools and applications discussed in the above sections are optional software
...
It might also very well be that the application that you are looking
for is not in your distribution at all
...

11
...
2
...
Volume control
aumix and alsamixer are two common text tools for adjusting audio controls
...
The alsamixer has a graphical interface when started from the Gnome menu or as gnome-alsamixer
from the command line
...

Regardless of how you choose to listen to music or other sounds, remember that there may be other people
who may not be interested in hearing you or your computer
...
Use a quality head-set, rather than the ones with the small ear pieces
...


11
...
3
...
For recording voice you can use
arecord on the command line:
alexey@russia:~> arecord /var/tmp/myvoice
...
wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
Aborted by signal Interrups
...
Play the sample using the simple play command
...
Keep in mind that the microphone input should be activated
...
It often happens that the microphone is muted or on verry low volume
...

In KDE you can start the krec utility, Gnome provides the gnome-sound-recorder
...
3
...

• okle: KDE version of ogle
• mplayer: Movie Player for Linux
• totem: plays both audio and video files, audio CDs, VCD and DVD
...

• hxplay: a Real alternative, see HelixDNA
...

Most likely, you will find one of these in your graphical menus
...
Sound and Video

192

Introduction to Linux
Keep in mind that all codecs necessary for viewing different types of video might not be on your system by
default
...

The LDP released a document that is very appropriate for this section
...
It is a fine
addition to the DVD HOWTO that explains installation of the drive
...

• zapping: Gnome-specific TV viewer
...


11
...
Internet Telephony
11
...
1
...
The big difference is that the data flows over a general purpose network,
the Internet, contrary to conventional telephony, that uses a dedicated network of voice transmission lines
...
In other words: it is very likely that you will not be able to call people who are using a conventional
telephone
...

While there are currently various applications available for free download, both free and proprietary, there are
some major drawbacks to telephony over the Internet
...
While some providers take their precautions, there is no guarantee
that you can reach the party that you want to call
...
If security is a concern for you, read the documentation that comes with
your VoIP client
...


11
...
2
...
4
...
1
...
This service might integrate traditional telephony and it
might or might not be free
...
Internet phone service only is offered by
Skype, SIP Broker, Google and many others
...


Chapter 11
...
4
...
2
...
If you have a
direct Internet connection, there won't be any problems, provided that you know on what server you can
connect, and usually that you also have a username and password to authenticate to the service
...
, 192
...
or another non-routable subnet prefix
...

Also, available bandwidth might be a blocking factor: some applications are optimized for low bandwidth
consumption, while others might require high bandwidth connections
...

Among the most common applications are the Skype client, which has an interface that reminds of instant
messaging, and X-Lite, the free version of the XTen softphone, which looks like a mobile telephone
...

Free and open VoIP clients are for instance Gizmo, Linphone, GnomeMeeting and KPhone
...
If you have the choice, opt for a USB headset, as it functions
independently from existing audio hardware
...

VoIP applications are definitely a booming market
...
voip-info
...


11
...
Summary
The GNU/Linux platform is fully multi-media enabled
...
The list of applications is sheer endless, that is
why we needed to shortenthe list of new commands below and limit ourselves to general audio commands
...
New commands in chapter 11: Audio
Command
alsaconf
alsamixer
arecord
aumix
cdp
cdparanoia
cdplay

Meaning
Configure the ALSA sound system
...

Record a sound sample
...

Play an audio CD
...

Play an audio CD
...
Sound and Video

194

Introduction to Linux
gnome-alsamixer
gnome-cd
gnome-sound-recorder
kaudiocreator
kmix
krec
mplayer
play

Gnome ALSA front-end
...

Gnome front-end for recording sound samples
...

KDE front-end for sound settings
...

Multi-media player
...


11
...
Exercises
1
...
Make sure audio boxes or
headset are connected to your system and find an output level that is comfortable for you
...

2
...
Make sure the input volume is
not too high, as this will result in high-pitched tones when you communicate with others, or in
transfering background noise to the other party
...

3
...

4
...

5
...
(You might need to install one first
...
Can you listen to Internet radio?
7
...


Chapter 11
...
Where to go from here?
This document gives an overview of useful books and sites
...
1
...
1
...
General Linux
• "Linux in a Nutshell" by Ellen Siever, Jessica P
...


A
...
2
...
Stallman, iUniverse
...
, ISBN 0595100333
• "Learning GNU Emacs" by Debra Cameron, Bill Rosenblatt and Eric Raymond, O'Reilly UK, ISBN
1565921526
• "Perl Cookbook" by Tom Christiansen and Nathan Torkington, O'Reilly UK, ISBN 1565922433

A
...
3
...
Kochan and Patrick H
...
1
...
X Window
• "Gnome User's Guide" by the Gnome Community, iUniverse
...
, ISBN 0595132251
• "KDE Bible" by Dave Nash, Hungry Minds Inc
...
0 Development" by David Sweet and Matthias Ettrich, Sams Publishing, ISBN 0672318911
• "GTK+/Gnome Application Development" by Havoc Pennington, New Riders Publishing, ISBN
0735700788

Appendix A
...
1
...
Networking
• "TCP/IP Illustrated, Volume I: The Protocols" by W
...
, Sams, ISBN
0672323168
• "Sendmail" by Brian Costales and Eric Allman, O'Reilly UK, ISBN 1565922220
• "Removing the Spam : Email Processing and Filtering" by Geoff Mulligan, Addison Wesley
Publishing Company, ISBN 0201379570
• "Managing IMAP" by Dianna & Kevin Mullet, O'Reilly UK, ISBN 059600012X

A
...
Useful sites
A
...
1
...
org: forum, downloads, docs and much more
• Google for Linux: the specialized search engine
• Google Groups: an archive of all newsgroup postings, including the comp
...
linux hierarchy
• Slashdot: daily news
• http://www
...
com: books on Linux System and Network administration, Perl, Java,
...


A
...
2
...
g
...
g
...
Configuration files for various models
...
2
...
Distributions
• The Fedora Project: RedHat-sponsored community effort OS
...
org: CD images for all distributions
...
Where to go from here?

197

Introduction to Linux
• Knoppix: distribution that runs from a CD, you don't need to install anything for this one
...
com: find a Linux that goes with your style
...


A
...
4
...

• Sendmail Homepage: A thorough technical discussion of Sendmail features, includes configuration
examples
...

• Official GIMP website: All information about the GNU Image Manipulation Program
...
net: Open SOurce software development site
...
Where to go from here?

198

Appendix B
...

As an extra means of orientation for new users with a Windows background, the table below lists MS-DOS
commands with their Linux counterparts
...
Read the Info or man pages on the command to find out more
...
Overview of DOS/Linux commands
DOS commands
/?
cd
chdir
cls
copy
date
del
dir
echo
edit
exit
fc
find
format
mem
mkdir
more
move
ren
time

Linux command
man or command
--help
cd
pwd
clear
cp
date
rm
ls
echo
vim (or other editor)
exit
diff
grep
mke2fs or mformat
free
mkdir
more or even less
mv
mv
date

Appendix B
...
Shell Features
This document gives an overview of common shell features (the same in every shell flavour)
and differing shell features (shell specific features)
...
1
...
Note that the stop, suspend, jobs, bg and fg commands are
only available on systems that support job control
...
Common Shell Features
Command
>
>>
<
<<
|
&
;
*
?
[]
()
``
""
''
\
$var
$$
$0
$n
$*
#
bg
break
cd
continue
echo
eval
exec

Meaning
Redirect output
Append to file
Redirect input
"Here" document (redirect input)
Pipe output
Run process in background
...
Shell Features

200

Introduction to Linux
fg
jobs
kill
newgrp
shift
stop
suspend
time
umask
unset
wait

Foreground execution
Show active jobs
Terminate running jobs
Change to a new group
Shift positional parameters
Suspend a background job
Suspend a foreground job
Time a command
Set or list file permissions
Erase variable or function definitions
Wait for a background job to finish

C
...
Differing features
The table below shows major differences between the standard shell (sh), Bourne Again SHell (bash), Korn
shell (ksh) and the C shell (csh)
...
bash has many more features of its own, and, as the table below demonstrates, many features
incorporated from other shells
...

Table C-2
...
Shell Features

Meaning/Action
Default user
prompt
Force redirection
Redirect stdout
and stderr to
file
Expand elements
in list
Substitute output
of enclosed
command
Home directory
Home directory
symbol
Access directory
stack

var=value
201

Introduction to Linux

export var export VAR=value

export
var=val

${nnnn}

${nn}

"$@"

"$@"

"$@"

$#

$#

$#

$?

$?

$?

$!

$!

$!

$-

$-

$-


...
file


...
Shell Features

alias -t
alias -t
cmds

Variable
assignment
Set environment
variable
More than 9
arguments can
be referenced
All arguments as
separate words
Number of
$#argv
arguments
Exit status of the
most recently
$status
executed
command
PID of most
recently
backgrounded
process
Current options
Read commands
source file
in file
Name x stands
alias x y
for command y
switch or
Choose
case
alternatives
End a loop
end
statement
End case or
endsw
switch
exit (expr) Exit with a status
Loop through
foreach
variables
Ignore
substitution
characters for
noglob
filename
generation
Display hashed
hashstat
commands
(tracked aliases)
Remember
rehash
command
locations
Forget command
unhash
locations

set
var=value
setenv var
val

202

Introduction to Linux
List previous
commands
Redo previous
ArrowUp+Enter or !!
r
!!
command
Redo last
!str
r str
!str
command that
starts with "str"
Replace "x" with
"y" in most
recent command
!cmd:s/x/y/
r x=y cmd !cmd:s/x/y/
starting with
"cmd", then
execute
...
This table is just to give you an idea of how
this shell incorporates all useful ideas from other shells: there are no blanks in the column for bash
...

history

history

history

More information:
You should at least read one manual, being the manual of your shell
...
Print it out and take it home, study it whenever you
have 5 minutes
...


Appendix C
...


A
a2ps
Format files for printing on a PostScript printer, see Section 8
...
2
...
1
...
2
...

alias
Create a shell alias for a command
...
1
...

alsamixer
Tune ALSA sound device output, see Section 11
...
2
...

anacron
Execute commands periodically, does not assume continuously running machine
...
3
...
2
...
5
...
2
...
2
...

aspell
Spell checker
...
1
...
2 and Section 4
...
3
...
2
...
3
...


B
bash
Bourne Again SHell, see Section 3
...
3
...
2
...

batch
Queue, examine or delete jobs for later execution, see Section 4
...
2
...

bg
Run a job in the background, see Section 4
...
2
...

bitmap
Bitmap editor and converter utilities for the X window System
...
1
...
3
...
2
...
3
...
2 and Section 3
...
4
...
2
...
2
...

cdparanoia
An audio CD reading utility which includes extra data verification features, see Section 11
...
1
...
2
...

chattr
Change file attributes
...
4
...
3
...
2
...
1
...
4
...
4
...
1 and Section 3
...
2
...

chown
Change file owner and group, see Section 3
...
2
...

compress
Compress files
...
3
...

crontab
Maintain crontab files, see Section 4
...
4
...
2
...
2
...
2
...
2
...

dd
Convert and copy a file (disk dump), see Section 9
...
1
...

df
Report file system disk usage, see Section 3
...
2
...

dhcpcd
DHCP client daemon, see Section 10
...
8
...

dig
Send domain name query packets to name servers, see Section 10
...
6
...

Glossary

205

Introduction to Linux
dmesg
Print or control the kernel ring buffer
...

dump
Backup file system, see Section 9
...
5
...
2
...

ediff
Diff to English translator
...

eject
Unmount and eject removable media, see Section 7
...
5
...

emacs
Start the Emacs editor, see Section 6
...
2
...

exec
Invoke subprocess(es), see Section 4
...
5
...

exit
Exit current shell, see Section 2
...

export
Add function(s) to the shell environment, see Section 3
...
1, Section 7
...
1
...
2
...
2
...
1
...

fdformat
Format floppy disk, see Section 9
...
1
...

fdisk
Partition table manipulator for Linux, see Section 3
...
2
...

fetchmail
Fetch mail from a POP, IMAP, ETRN or ODMR-capable server, see Section 10
...
2
...

fg
Bring a job in the foreground, see Section 4
...
2
...

file
Determine file type, see Section 3
...
1
...

find
Find files, see Section 3
...
3
...

firefox
Web browser, see Section 10
...
3
...

fork
Create a new process, see Section 4
...
5
...

formail
Mail (re)formatter, see Section 10
...
2
...

fortune
Print a random, hopefully interesting adage
...
3
...
2
...

gdm
Gnome Display Manager, see Section 4
...
4
...
3
...
3
...

gimp
Image manipulation program
...
4
...
2
...
3
...
4 and Section 5
...
1
...
1
...

grub
The grub shell, see Section 4
...
3 and Section 7
...
4
...
1
...
2
...
3
...
3
...
1
...
3
...
2
...

head
Output the first part of files, see Section 3
...
4
...

help
Display help on a shell built-in command
...
2
...
1
...
2
...
1
...
4
...

ifconfig
Configure network interface or show configuration, see Section 10
...
2
...

Glossary

207

Introduction to Linux
info
Read Info documents, see Section 2
...
3
...

init
Process control initialization, see Section 4
...
5
...
2
...
2
...

insserv
Manage init scripts, see Section 4
...
5
...

iostat
Display I/O statistics, see Section 4
...
5
...

ip
Display/change network interface status, see Section 10
...
2
...

ipchains
IP firewall administration, see Section 10
...
4
...

iptables
IP packet filter administration, see Section 10
...
4
...


J
jar
Java archive tool, see Section 9
...
1
...

jobs
List backgrounded tasks
...
2
...

kedit
KDE graphical editor, see Section 6
...
3
...

kill(all)
Terminate process(es), see Section 4
...
2
...

konqueror
File manager, (help) browser, see Section 3
...
2
...

ksh
Open a Korn shell, see Section 3
...
3
...

kwrite
KDE graphical editor, see Section 6
...
3
...


L
less
more with features, see Section 3
...
4
...

lilo
Linux boot loader, see Section 4
...

links
Text mode WWW browser, see Section 10
...
3
...

ln
Make links between files, see Section 3
...
5
...
4
...

Glossary

208

Introduction to Linux
locate
Find files, see Section 3
...
3
...
4
...

logout
Close current shell, see Section 2
...
3
...
1
...
1
...
1
...
1
...
1
...
2, Section 3
...
1
...
3
...
1
...
2
...
2
...
3
...
3
...
3
...

mc
Midnight COmmander, file manager, see Section 3
...
2
...

mcopy
Copy MSDOS files to/from Unix
...

memusage
Display memory usage, see Section 4
...
5
...

memusagestat
Display memory usage statistics, see Section 4
...
5
...

mesg
Control write access to your terminal, see Section 4
...
6
...
2
...
1
...

mkdir
Create directory, see Section 3
...
2
...
2
...

mplayer
Movie player/encoder for Linux, see Section 11
...
2 and Section 11
...

more
Filter for displaying text one screen at the time, see Section 3
...
4
...

mount
Glossary

209

Introduction to Linux
Mount a file system or display information about mounted file systems, see Section 7
...
5
...

mozilla
Web browser, see Section 10
...
3
...

mt
Control magnetic tape drive operation
...

mv
Rename files, Section 3
...
2
...
3
...

nautilus
File manager, see Section 3
...
2
...

ncftp
Browser program for ftp services (insecure!), see Section 10
...
4
...

netstat
Print network connections, routing tables, interface statistics, masquerade connections, and multi-cast
memberships, see Section 10
...
2
...
4
...

newgrp
Log in to another group, see Section 3
...
2
...

nfsstat
Print statistics about networked file systems
...
3
...
1
...

ntpd
Network Time Protocol Daemon, see Section 7
...
3
...
4
...

ntsysv
Simple interface for configuring run levels, see Section 4
...
5
...


O
ogle
DVD player with support for DVD menus, see Section 11
...


P
passwd
Change password, see Section 2
...
1
...

pccardctl
Manage PCMCIA cards, see Section 10
...
3
...

pdf2ps
Ghostscript PDF to PostScript translator, see Section 8
...
2
...

pg
Page through text output, see Section 3
...
4
...

pgrep
Look up processes based on name and other attributes, see Section 4
...
4
...
2
...
2
...
2
...

pr
Convert text files for printing
...
2
...

procmail
Autonomous mail processor, see Section 10
...
2
...

ps
Report process status, see Section 4
...
4 and Section 4
...
5
...

pstree
Display a tree of processes, see Section 4
...
4
...
2
...
2
...
3
...
4
...

reboot
Stop the system, see Section 4
...
6
...
4
...

renice
Alter priority of a running process, see Section 4
...
5
...

restore
Restore backups made with dump, see Section 9
...
5
...
4
...
5
...

rm
Remove a file, see Section 3
...
2
...
3
...
2
...
1
...

Glossary

211

Introduction to Linux
rpm
RPM Package Manager, see Section 7
...
2
...

rsh
Remote shell (insecure!), see Section 10
...
2
...
3
...
4
...
1
...
1
...
1
...

setterm
Set terminal attributes
...
4
...
1
...
2
...
2
...
2
...

sleep
Wait for a given period, see Section 4
...
1
...
3
...
3
...
2
...

snort
Network intrusion detection tool
...
3
...

spell
Spell checker, see Section 5
...
2
...

ssh
Secure shell, see Section 10
...
4
...

ssh-keygen
Authentication key generation, management and conversion, see Section 10
...
4
...

stty
Change and print terminal line settings
...
2
...
5
...
2 and Section 10
...
6
...

tail
Output the last part of files, see Section 3
...
4
...

Glossary

212

Introduction to Linux
talk
Talk to a user
...
1
...
1
...
2
...
2
...
2
...

telnet
User interface to the TELNET protocol (insecure!), see Section 10
...
2
...
1
...

time
Time a simple command or give resource usage, see Section 4
...
2
...
2
...

top
Display top CPU processes, see Section 4
...
4, Section 4
...
5
...
3
...
4
...
1
...

traceroute
Print the route packets take to network host, see Section 10
...
6
...

tripwire
A file integrity checker for UNIX systems, see Section 10
...
5
...
1
...

tvime
A high quality television application
...


U
ulimit
Controll resources, see Section 7
...
2
...

umask
Set user file creation mask, see Section 3
...
2
...

umount
Unmount a file system
...

uniq
Remove duplicate lines from a sorted file, see Section 5
...
2
...
5
...
3
...

update-rc
...
2
...
1
...
1
...
3
...
2
...
5
...
3
...


V
vi(m)
Start the vi (improved) editor, see Section 6
...
2
...

vimtutor
The Vim tutor
...
3
...
4
...

wall
Send a message to everybody's terminal, see Section 4
...
6
...
2
...

which
Shows the full path of (shell) commands, see Section 3
...
1 and Section 3
...
3
...

who
Show who is logged on, see Section 4
...
6
...

whois
Query a whois or nicname database, see Section 10
...
6
...

write
Send a message to another user, see Section 4
...
6
...
3
...
3
...

xawtv
An X11 program for watching TV
...
2
...

xclock
Analog/digital clock for X
...

xdm
Glossary

214

Introduction to Linux
X Display Manager with support for XDMCP, host chooser, see Section 4
...
4 and Section 7
...
2
...
1
...
2
...
3
...
3
...

xhost
Server access control program for X, see Section 10
...
3
...

xine
A free video player, see Section 11
...

xinetd
The extended Internet services daemon, see Section 10
...
1
...

xload
System load average display for X, see Section 4
...
5
...

xlsfonts
Server font list displayer for X
...
2
...
1
...
1
...
2
...


Y
yast
System administration tool on Novell SuSE Linux
...
5
...
3
...

zcat
Compress or expand files
...

zmore
Filter for viewing compressed text
Title: Introduction to linux
Description: this note based on those who takes computer science,because linux is open source window which run on PC and on various server which used on various organization.