NICs and ifconfig

NIC drivers are one of the most important types of kernel modules (more information about modules). Generally these autoload at boot.

 

Did Linux find your NIC?

dmesg | grep eth

lists boot messages involving your NIC.

 

Basic ifconfig syntax

ifconfig <interface>

gives you the basic information on your first NIC (interface). If you have more than one NIC, use the syntax:

ifconfig <interface> #where “interface” is eth0, eth1, etc.

If you want information on all NICs (interface), command:

ifconfig -a

 

Options:

ifconfig interface <aftype> options | address

 interface #e.g. eth0

 up #start the NIC; this is implicit if you assign an address

 down #stop the NIC

 [-]promisc #start or stop promiscuous mode

(and many more; see man ifconfig)

 

Set your IP address

ifconfig eth0 192.168.2.7

which also starts your NIC.

 

Set your subnet mask

ifconfig eth0 netmask 255.255.255.0

 

Turn your NIC on and off

ifconfig eth0 up #or down

starts (or stops) your NIC. You can also use:

ifup eth0
and
ifdown eth0

 

Check that your NIC is communicating

ping -c 127.0.0.1 #loopback

If you get no response from your loopback interface, TCP/IP itself is hosed. It’s time to look REALLY closely at your configuration.

The -c option to ping stops the pinging after 5 repetitions. Otherwise pinging continues until you press CTRL-c, which can be very rude.

ping -c 192.168.2.1 #use the NIC’s IP address

This tells you if you have a valid IP address assignment. If this doesn’t fly, make sure you’re not duplicating an address already in use (among other issues).

ping -c google.com #or your company’s domain, for instance

This tells you if you’re getting DNS resolution. If not, make sure you’ve specified the correct gateway and DNS servers (see Configuration files).

 

Set your default gateway

On the command line:

route add default gw 192.168.0.1 netmask 255.255.255.0 eth0

or edit /etc/sysconfig/network to add:

GATEWAY=192.168.0.1

 

A complete configuration from the command line

ifconfig eth0 192.168.2.26 netmask 255.255.255.0 broadcast 192.168.2.255

Sets up your first NIC.

route add default gw 192.168.2.1 netmask 255.255.255.0 eth0

Necessary to define your gateway.

 

Another network information command

Compare the output of the command:

netstat -i

 

Where is this NIC configuration stored?

Each NIC gets its own configuration file:

/etc/sysconfig/network-scripts/ifcfg-eth0 #Red Hat

/etc/sysconfig/network/ifcfg-eth0 #SUSE

for instance. Go to this directory, find your NIC, and cat the config file.

Networking Basics

An intranet is a Local Area Network: a LAN.

The Internet is a Wide Area Network: a WAN.

Otherwise there is little difference.

 

Client/Server Architecture

There are physical Servers and Clients: a server computer, a client computer.

And there are “virtual” Servers and Clients: a server application (like a web server) a client application (like a web browser).

 

Behind every good server is a daemon

A server application can run on a server computer or on a client computer.

But generally a “server” application is a daemon (in Unix/Linux) or simply a server (in Windows).

 

A daemon runs a service

A service is not a server.

The Apache web server, for instance, is actually an http daemon.

Look in your Services applet: You’ll find Apache running as httpd, which provides http services to remote clients.

 

LAN topologies

Wired topologies include:

Star: all computers are connected to a common hub using Cat 5 cable. All newer networks use this.

Bus: all computers share a common coaxial cable, and connect using “balun” or T connectors. No new networks are created this way. There are many older networks still using it.

Ring: the famous “Token Ring” architecture is largely outdated. Computers on a shared loop of cable take turns transmitting. The computer that holds the “token” (really just a digital packet) gets to transmit. UPS, for instance, still has a lot of Token Ring gear.

 

Wireless LAN topologies

Wireless LANs are still rare in the enterprise because of security issues. They can be:

“Peer-to-peer” or “Ad hoc” networks, which function without a wireless hub

“Access point” or “Infrastructure” networks, which depend on a hub to coordinate traffic.

 

Now for the tricky stuff

The whole issue in any network is identifying who you are and who you’re talking to.

At the lowest level lies the actual network card (or network interface or NIC). Every NIC has a unique address, a Media Access Control (MAC) address.

The MAC address is a 12-byte number usually represented like this:

00:80:C8:8C:8E:49

 

MAC is forever; IP is transient

Ranges of MAC addresses are allocated to NIC manufacturers. In theory at least, every MAC address is unique forever.

Thus, we need a way to assign IP addresses to every client computer, and match up those IP addresses to MAC addresses.

 

MACs are ugly
IPs are painful
Hostnames a
re nice

One of the most important functions of networking is to make things human-readable (notice the –h option of many commands – see man du).

Nobody wants to say, “You can find my project on the share at 192.168.2.1.”

It’s lots easier to say, “Look in my share folder on Icarus.”

 

You already have a MAC address…
…so how do you get an IP address?

  1. Define it at installation. You’ll need to know the range of IP addresses your network uses, and choose an unused one.
  2. Define it later. Use ifconfig (see the man page) or the Network Configuration applet (neat command or Main>System Settings>Network).
  3. Get it automatically through DHCP, either from your server or from your router.

 

DHCP
Dynamic Host Configuration Protocol

DHCP is a service (yes, there’s a daemon involved) that has a pool of IP addresses it can assign to hosts as needed.

Within a network, this is typically the 192.168 range: any number from 192.168.0.1 to 192.168.254.254.

 

Take a deep breath: Here comes IP

192.168.0.1

What gives with this number?

Once again it’s a “human-readable” version of a very ugly number. The dots divide it into “octets,” which are called this because they are actually groups of eight bits that have a value like this:

10111001

 

Doing it binary

The trick with any 8 bits like these is that they can express, in base 2, numbers up to 254 (more specifically, 255 numbers from 0 to 254, inclusive).

So any IP octet can be (theoretically) any number from 0 to 254. Thus:

192.168.0.1

 

Can’t get anything past you

Some IP addresses are “non-routable,” meaning they won’t make it through a router onto the Internet. They’re strictly for LAN use.

The most common of such non-routable addresses begin with:

192.168.

and more specifically, most routers will try to take:

192.168.0.1 for themselves.

 

My network, your network

Generally, when you’re inside a LAN, you’ve got an IP address like:

192.168.0.56

This (more or less) means that I’m on the 192.168.0 “subnet” and my computer is number 56. All other computers are outside this subnet.

However, you may be behind a DSL modem (for instance) that’s passing traffic from the Internet to the 192.168.0 subnet, where it’s caught by a local router that passes it in turn to the 192.168.2 subnet.

Now your address will likely be something like 192.168.2.56 .

 

Subnet masks

The thing you notice in this example is that the beginning numbers are the same. Actually, to find each other, the computers on our 192.168.2 subnet only need the very last octet to find each other:

“Hey, 56, are you there?”

We can mask the rest of the numbers with this strange set of numbers:

255.255.255.0

In binary this is actually:

11111111111111111111111100000000

 

1 means I can’t see you

11111111111111111111111100000000

See what we’re actually doing?

Down at the bit level we’re just “masking” those first bits and looking at the last eight bits.

In our case, they’d equal (in base 10) 56.

“Hey, 56, you there?”

“Yeah! Here I am!”

 

Meanwhile, back at the router

If the router is providing DHCP service, you can configure a range of addresses for it to use, for instance:

192.168.2.10 – 192.168.2.225

This leaves you IP addresses at the low end for servers, and the high end for printers.

 

Subnet Classes

Class A:
0.xxx.xxx.xxx through 127.xxx.xxx.xxx
Millions of numbers per Class A subnet

Class B:
128.0.xxx.xxx through 191.254.xxx.xxx
65,534 numbers per subnet

Class C:
192.0.0.xxx through 223.254.254.xxx
254 numbers per subnet

Class D:
Multicast addresses, shared by multicast groups

Class E:
Reserved for experimental uses

 

What this really means

This business of Classes just means people “back in the day” thought they had far more IP addresses than they needed.

They split out subnets every three numbers, at the dots.

You can actually split out subnets at every single number, instead, and just reveal how many you’ve masked:

192.168.2.56/24

 

Masking one byte at a time

So you could mask three octets:

192.168.2.56/24

Or two-and-two-thirds octets:

192.168.2.56/23

Or two-and-a-third octets:

192.168.2.56/22

And so forth.

 

Classless Inter-Domain Routing

This method of slicing apart thinner slices of IP addresses is called Classless Inter-Domain Routing (CIDR).

You’ll see this notation a lot….

Assignment: Set your IP

  1. Open a terminal window.
  2. Run ifconfig and find your IP address.
  3. Open Main>System Settings>Network.
  4. Double-click your ethernet adapter.
  5. Set your IP operation to Manual, and enter the IP address you got in step 2.
  6. Save and restart your network.

 

Once you have an IP address how do you get a host name?

  • Set it during installation.
    The hostname will remain until you change it.
  • Set it from the command line: hostname Icarus
    The hostname will disappear upon reboot.
  • Set it using a configuration file: /etc/sysconfig/network
    The hostname is set – for good, until you change this file.

 

Assignment: Set your hostname

Edit /etc/sysconfig/network and set your hostname.

You may be fanciful but you may not be obscene.

 

Time to talk over the network

Now you’ve got a MAC address (set at the NIC factory), an IP address (set manually or by DHCP) and a hostname (set manually).

Let’s plug in….

 

Hubs

Once upon a time, every LAN used a hub. A hub is just a box everyone’s Cat 5 cable plugs into.

All traffic shares the same “room”: I hear everything everyone says, and everyone hears everything I say.

Once there are dozens or hundreds of computers on the same hub-based network, there’s tremendous traffic contention. It’s hard to be heard over everyone else’s shouting.

 

Switches

Then came switches.

Switches segregate traffic: each conversation is effectively isolated to a “private room.”

If I’m HostA and I’m talking to HostB, HostC can’t hear a word!

How do they do this?

MAC addresses. The switch remembers MAC addresses and matches them to IP addresses so it can handle every conversation like a private, switched telephone line.

yum.conf Examples

A default yum.conf file:

 

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
retries=20

[base]
name=Fedora Core $releasever - $basearch - Base
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/

[updates-released]
name=Fedora Core $releasever - $basearch - Released Updates
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/

#[updates-testing]
#name=Fedora Core $releasever - $basearch - Unreleased Updates
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/testing/$releasever/$basearch/

#[development]
#name=Fedora Core $releasever - Development Tree
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/development/$basearch/

 

An updated yum.conf:

 

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
retries=20

[base]
name=Kernel.org Fedora Core Mirror $releasever - $basearch - Base
baseurl=http://mirrors.kernel.org/fedora/core/2/$basearch/os

[updates-released]
name=Fedora Core Mirror $releasever - $basearch - Released Updates
baseurl=http://mirrors.kernel.org/fedora/core/updates/2/$basearch

[dag]
name=DAG RPM Repository for Fedora Core
baseurl=http://apt.sw.be/fedora/2/en/$basearch/dag

#[updates-testing]
#name=Fedora Core $releasever - $basearch - Unreleased Updates
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/testing/$releasever/$basearch/

#[development]
#name=Fedora Core $releasever - Development Tree
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/development/$basearch/

 

The Red Hat Network and yum

What is the Red Hat Network?

The Red Hat Network isn’t Red Hat’s intranet. It’s like Windows Update: a way to keep your system patched.

If you are using a Red Hat Enterprise release, you’ll want to run updates periodically to ensure your system’s safety.

If you are using Fedora, you’re using a “bleeding edge” release that will be getting frequent updates. Consider updating once a week.
Setting up Red Hat Network
In the GUI desktop, select:
Main > System Settings > Red Hat Network Configuration

You’ll enter a configuration tool that lets you select a server on the first tab.
Retrieval, verification and installation options are on the second.
The third tab, Package Exceptions, lets you exclude packages you don’t want to install or update.

Running Red Hat Update

The setup tool doesn’t actually give you a way to start updates.
For that, you have two methods.

  • At the command line, type up2date, or
  • Use the GUI tool at Main > System Tools > Red Hat Network, which presents you with a wizard interface.

What really happens then
If you’re working in a shell environment, up2date will present you with a text-based interface and options.

If you call up2date from the GUI, you’ll get a GUI tool.

But behind it all is up2date.

 

Assignment: Configuring up2date

up2date has its configuration file in /etc/sysconfig/rhn/sources.

Needless to say (I say it anyway): back up this file before changing it!

Now, comment out (by placing a # at the beginning of the lines) the lines beginning:
yum fedora-core-4 …
yum fedora-core-4-updates …
Alternate mirrors for up2date
Now replace these lines with:

yum fedora-core-4 http://mirrors.kernel.org/fedora/core/4/i386/os
yum fedora-core-4-updates http://mirrors.kernel.org/fedora/core/updates/4/i386

 

How up2date will act

Once it’s configured and running, Red Hat Network will manifest as an icon in your system tray, either a checkmark (you’re up to date) or a glowing red dot (new updates have been added to the Fedora mirror).

 

What is yum?

The name “yum” is (like many Unix names) a pseudo-acronym, in this case for the Yellow Dog Updater Modified tool.

Note that Yellow Dog is another distribution of Linux, and in fact is intended for installing Linux on Mac hardware!

Like all open-source projects, yum was returned to the community, and is now used by several other distibutions.

 

Assignment: Configuring yum

Your yum configuration file is:

/etc/yum.conf

The very first thing you should do is back this file up:

cp  /etc/yum.conf  /etc/yum.conf.bak

 

The default yum.conf file

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
retries=20

[base]
name=Fedora Core $releasever – $basearch – Base
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/

[updates-released]
name=Fedora Core $releasever – $basearch – Released Updates
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/

 

Why not to use the default config?

 

  • Everyone and their brother is using these download sites.
  • It’s slow and unreliable as a consequence
  • During peak hours, the server is likely to time out your connection.

 

Better update locations

Where should you get updates instead?
One very good choice is the mirrors at kernel.org: it’s got lots of very fast connections, it’s one of the first sites to get updated with changes, and it carries a larger range of releases (such as the AMD64 versions of Linux).
There are also third-party repositories with software from outside the Fedora project that can be used with Fedora, such as DAG and FreshRPMs.org.

 

Setting Up yum Configuration Files

In older Fedora Core distros, all the yum configuration information was stored in a single file: yum.conf. If you’re using an older Fedora, you will make all these edits directly into this file.

In Fedora Core 4, this configuration has been moved to the directory /etc/yum.conf.d . Each repository (marked by a name in square brackets) will go into a separate file in /etc/yum.conf.d/ , with an appropriate file name, such as dag.repo or freshrpms.repo.
For example, the file fedora.repo looks like this:

[base]
name=Fedora Core $releasever – $basearch – Base
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/
mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-$releasever
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
More mods to yum.conf
You could consider modifying the [updates-released] section (or the fedora-updates.repo file) to:

[updates-released]
name=Fedora Core Mirror $releasever – $basearch – Released Updates
baseurl=http://mirrors.kernel.org/fedora/core/updates/$releasever/$basearch

Visit mirrors.kernel.org and consider how yum is using what you see.

 

Plus an addition

Now add a new section to yum.conf, or create a new yum configuration file called dag.repo:

[dag]
name=DAG RPM Repository for Fedora Core
baseurl=http://apt.sw.be/fedora/$releasever/en/$basearch/dag

 

About these changes

Take note that in yum.conf or in *.repo files:

  • The section heading can be called anything, as long as you enclose it in brackets: [dag].
  • The name heading can be nearly anything you want to call it.
  • The baseurl line is critical, and must point to a real repository.

 

Other repositories

Many third-party mirrors of fedora.us also provide access to wide ranges of software outside the Fedora distribution. See the HOWTO document at http://www.fedora.us/wiki/FedoraHOWTO

Also visit freshrpms.net.

 

Updating with yum

You can begin the update process with the command:

yum update

yum then connects with the repositories and downloads the headers for each RPM that needs to be updated. (Header files are essentially descriptions of what each RPM does.)

Then yum prompts you to choose and install updated files.

 

What next with yum?

Depending on your connection speed, you might want to order a pizza.

yum may update a few or very many packages, including the kernel.

If you endure many updates, reboot at the end.

If yum installs a fresh kernel, reboot to take advantage of it.

So here’s the fun part

Fedora is loaded with features, but there are lots of things it doesn’t have, like MP3 players, rippers and encoders, video players and plugins, and alternate file managers and web browsers.

Let’s try some….

 

Assignment: Setting up MP3 support in Fedora

Let’s say you want to install a couple of MP3 players to try out. You can install these using:

yum install alsaplayer
yum install zinf

Don’t forget to get an encoder and a disk ripper:

yum install lame
yum install grip

 

Adding video support

Get a couple of video (MPEG) players:

yum install xine
yum install mplayer

And an MPEG player plugin for Mozilla:

yum install mplayerplug-in

 

Alternate programs

Add a Norton Utilities-like file manager for KDE:

yum install krusader

And an alternate lightweight web browser:

yum install mozilla-firefox

Now you try it

Install at least two of these, then test them:

yum install alsaplayer
yum install zinf
yum install lame
yum install grip
yum install xine
yum install mplayer
yum install mplayerplug-in
yum install krusader
yum install mozilla-firefox

Helpful yum commands

yum list

List all available packages

yum check-update or yum list updates

See if updated packages are available

yum update

Update all installed packages that have new versions

yum install package [package…]

Install packages and dependencies

yum search word

Search all known package entries for word.

yum info package

Show basic info about a package

Assignment: Install Another Package Manager: APT

Debian’s Advanced Package Tools (APT) is unique in providing good GUI tools for searching for third-party applications.

To install APT (provided yum.conf is configured for DAG or FreshRPMS or Fedora.org):

yum install apt
yum install synaptic
yum install kpackage

APT tools

synaptic is an APT GUI for Gnome.

kpackage is an APT GUI for KDE.

The configuration files for APT are in  /etc/apt/.

There may be one file, sources.list, or a whole directory, sources.list.d/, containing a config file for each repository.

Running APT

Update the APT database:

apt-get update

Once the update is current, run

synaptic
or
kpackage

and pick the packages you want to install.

Why would you want APT?

  • APT is distribution-neutral. You can use it in practically any distro, for a uniform set of tools.
  • APT accepts command-line and scripting commands (like rpm but unlike many others).
  • APT lets you easily point to third-party package sites, to get support after vendors drop it, and to get updates without registering.

Dude, you’re gonna get a sourceforge!

Are you familiar with sourceforge.net? Check it out. Try:

http://apt4rpm.sourceforge.net

…which is far from the only project they support. Before you pay, look their way.
Choosing the right apt
Go to the download page and look at your options:

 

  • You can install server packages that let you manage a large number of client updates.
  • You can install the simple client package. This is the one you want.

 

Assignment:

Find the rpm and install it

Finding Software Packages

Where do you get software/packages?

You can get Linux software in a huge range of forms (as the preceding page about installers should have made clear). You can get complete groups of software that are all required for a single application: for instance, all the libraries, daemons and interfaces necessary to run MySQL. Or if you’re a hardcore developer, you can compile and install your choice of specific versions of all of the above, to build your own custom application.

 

“Just Plain RPMs”

There are lots of sites that offer RPM packages:

FreshRPMs at http://freshrpms.net/ caters to Fedora and some YellowDoc platforms.

RPM Search at http://rpm.pbone.net/ offers RPMs for a huge range of distros. Be sure to use the Advanced Search.

 

Lots of Applications

FreshMeat.net is the prince of free software projects, at http://freshmeat.net/. It’s easy to use, and the Search feature actually works when it comes to finding what you need.

The King of Open Source Application Repositories is undeniably Sourceforge, at http://sourceforge.net/. Looking for the truly bleeding-edge, the astonishing, the Godzilla programming? These are the people who are doing it. Some of them are doing documentation, too, but don’t count on it. Don’t worry; Google will take care of you.

You might consider Icewalkers.com at http://www.icewalkers.com/ as a very reasonable compromise of the above two. A geek’s paradise, this site offers WAY more than just packages. Not to be missed: check out the Best Rated link.

Feeling greedy yet? Now visit the LinuxForums.org’s download page at http://dir.linuxforums.org/. The array of software goodies is most tasty, but what you’re going to appreciate longer-term is the eponymous forums. There really are cool people there.

The search function may not seem as user-friendly initially, but Ibiblio.org has a huge repository of packages. You’ll need to figure out what they are elsewhere, though, because you’re going to land in a directory full of obscurely-named files sooner or later. If you know what you’re looking for, go to http://ibiblio.org/.

A cool Czech/English site, http://www.linuxsoft.cz/en/, has a heavy-duty selection of packages, how-tos and interviews that’s more interesting than some magazines I’ve followed.

LinuxLinks.com has a great page at http://linuxlinks.com/Software/ with literally thousands of packages.

Not a repo in itself, LinuxQuestions.org at http://www.linuxquestions.org/ is often the first place you should visit when you’re not quite sure what a package is called or which one works on your distry. Highest recommendation from me.

Using Package Installers

What are packages anyway?

You can think of packages as installers. In Red Hat/Fedora, Red Hat Package Manager (RPM) is the primary tool. Debian-based distributions use the Debian Package Manager, dpkg. Both of these are very low-level tools that install individual applications, but don’t manage whole systems very well.

Higher-level tools monitor entire systems, and manage upgrades and updates. These tools include APT on Debians like Ubuntu, and Yum for Red Hat/Fedora or in fact most distributions.

The basic idea of package management is to group the tens of thousands of installed files on your computer into a manageable set of packages that allow the administrator to easily install and uninstall them from the computer. For the moment we’ll look at the RPM-based system.

 

Checking the Integrity of Packages Using md5 Checksums

You should check the packages you download to make sure you don’t have a download error, and also to confirm the packages haven’t been tampered with.

1. Most packages will have a small associated checksum file. Open the file and note the number.

2. In the shell of your preference, type the command:

md5sum packagename.rpm
or
sum packagename.rpm

3. Compare the calculated checksum that results with the one listed in the checksum file.

4. If the checksums do not match, it may have been caused by an error during downloading, or may indicate that tampering has occurred.

 

RPM

RPM, however, extends this notion substantially. Each RPM package contains all the information needed to install itself on your computer:

what the package does,

what other packages it may depend upon,

what capabilities the package brings to your system, and

where the files should go on your computer.

Your operating system keeps a database of every package installed on your computer and its capabilities and dependencies.

 

Learning to RPM

Before trying graphical “point-and-click” tools for managing packages, look at the RPM command itself.

Documentation for RPM is very thorough – see the man page.

The web site www.rpm.org is a treasure-trove of HOW-TOs.

It includes the excellent book Maximum RPM, the best reference on RPM itself. (And mandatory reading for anyone wanting to build their own RPM packages.)

 

Basic RPM Options

RPM is invoked with the command:

rpm

Followed by options:

-i = Install a package

-b = Build New Package

-q = Query information from installed or uninstalled packages

-U = Upgrade packages on the system

-F = Freshen packages existing on the system

-e = Uninstall packages from the system

-V = Verify the validity of packages on the system, or an uninstalled package

 

Installing RPM Packages

How do I install a new package, or upgrade it if it already exists? Or:

rpm -Uvh package.rpm

This is the most important RPM command to know!

rpm -Fvh *.rpm

rpm -e package

Some applications, like OpenOffice, will download as a whole directory full of rpm files. Trying to install them yourself, in the right order, is tricky if not impossible.

Use the command:

rpm –Uvh *rpm

to perform the rpm-based installation.

 

Querying Package Info

rpm -qa | less

rpm -qi package

rpm -ql package

 

Further Queries

rpm -qilp package.rpm

rpm -qf /usr/bin/weirdo

rpm -qilf /usr/bin/weirdo

 

Verifying Packages

rpm -Va

rpm -Va

rpm -Vv package

rpm -K –nopgp package.rpm

 

Building From a “Source” Package

Sometimes you’ll get an RPM that contains only source code, not compiled binaries for your specific computer.

rpmbuild –rebuild package.src.rpm

then

rpm -Uvh package.rpm

 

Optimizing the rpm Database

If your system has lots of packages installed, your queries may run quite slowly. You should optimize the RPM database periodically:

rpm –rebuilddb

 

GUI Tools for rpms

In Red Hat/Fedora, choose Applications > Add/Remove Software.

 

In SUSE, open YAST > Software > Software Management.

 

Assignment: Installing an rpm

Go to freshrpms.net.

Select the package list for the Fedora version on which you’re currently running.

Browse the packages and select one.

Download it and install it.

 

The Debian Package Manager

Of course, not every system is a Red Hat system. Probably the most popular other package manager is the Debian Package Manager, or dpkg.

The general format of a Debian package file (.deb) is:

packagename_packageversion-debversion.deb

 

dpkg Options

-I Queries Package

-i Installs software

-l Lists installed software (equivalent to rpm -qa)

-r Removes the software from the system

 

Basic dpkg Options

dpkg -i package.deb

dpkg -I package.deb

dpkg -c package.deb

dpkg –l

How do I remove ‘package-name’ from the system (as listed by dpkg -l)?

dpkg -r package-name

 

The Debian dselect GUI Tool

dselect is a simple, menu-driven interface which helps install packages. It takes you through the package installation process in the order of the on-screen menu:

In this menu you choose the method to obtain and install the packages.

dselect reads the Packages database and creates a database of the packages available on your system.

Choose your the package you want and press Enter. To exit the Select screen after all of the selections are complete, press Enter. This returns you to the main screen if there are no problems with your selection. You must resolve those problems first. When you are satisfied with any given screen, press Enter.

Dependency conflicts are quite normal and to be expected.

dselect runs through the entire 800 packages and installs the ones that are selected.

 

Debian Package Priorities

The priority of a package indicates how essential or necessary it is. Debian GNU/Linux classifies all packages into four different priority levels:

Packages must be installed for the system to operate correctly and have been installed as part of the base system.

Important packages are found on almost all UNIX-like operating systems.

Packages that comprise the “standard,” character based, Debian GNU/Linux system. The Standard system includes a fairly complete software development environment and GNU Emacs.

Optional packages comprise a fairly complete system. The Optional system includes TeX and the X Window System.

Extra packages are only useful to a small or select group of people, or are installed for a specific purpose. Extra packages might include such programs as electronics and ham radio applications.

Extra packages are abbreviated in dselect as Xtr.

 

A Word About alien

See http://kitenet.net/programs/alien .

This is a program which converts between package formats. From kitenet.net:

“A program that converts between the rpm, dpkg, stampede slp, and slackware tgz file formats. You can use alien to convert it to your preferred package format and install it.

“Alien should not be used to replace important system packages, like sysvinit, shared libraries, or other things that are essential for the functioning of your system.”

 

Flying Solo: Autoconfiguring Packages (Tarballs)

An autoconfiguring package usually has a filename like: “foo-1.0.tar.gz” where the number is a version number.

To install it, first you have to unpack the package to a directory someplace:

Use the gunzip command to uncompress the package:

gunzip foo-1.0.tar.gz
or
tar –zxvf foo-1.0.tar.gz

If you used gunzip you will now have to use the tar command to extract the package archive:

tar -xf foo-1.0.tar

Now change into the foo directory and look for files like ´README’ or ´INSTALL’. The README or INSTALL files will explain how to configure the package, but the general format is:

cd foo-1.0

./configure

make

make install

su –

make install

 

How To make It

./configure invokes a shell script that is distributed with the package that configures the package for you automatically.

It will probe your system through a set of tests that allow it to automatically generate a makefile from a template stored in a file called ‘makefile.in’.

To install your software, you need to explicitly invoke make again with the target install.

 

Where Files End Up

Executables:

/usr/local/bin or /opt/ (among others)

Libraries:

/usr/local/lib

Header files:

/usr/local/include

Man pages:

/usr/local/man/

Info files

/usr/local/info

 

Installing to Your Home Instead

If you want to install the package to your home directory instead of /usr/local, you would use the ‘prefix’ option:

configure –prefix=/home/foo

 

Assignment: Installing a tarball

Go to www.nagios.org.

Select a download site and download the tar.gz package.

Unpack it in an appropriate place.

Read the INSTALLATION file.

Perform the installation.

Further Study

Learn more about the wave of the future, Yum, at Roderick Smith’s article “Linux Software Management with yum,” at
http://www.linux-mag.com/id/2908/

Software Packages and GPG Signing

What GPG Package Signing Is

“GPG” as an acronym means “GNU Privacy Guard.”

It’s a play on the older and compatible but not open-source PGP – “Pretty Good Privacy.”

Both are means of digitally signing messages or other digital packages.

 

1: In order to use any keys you must first get them, then import them. Get the Fedora key from:

See the Fedora GPG Keys page for details (http://fedora.redhat.com/about/security/). Change directories to the directory containing the key.

Note that a key also has a fingerprint, distributed as either a file or a simple text string that you save to a file. The fingerprint of the fedora@redhat.com key is:

CAB4 4B99 6F27 744E 8612 7CDF B442 69D0 4F2A 6FD2

 

2: SAVE THIS FINGERPRINT (DIRECTLY ABOVE) AS A FILE NAMED “fingerprint”.

-Assignment: see Gstreamer for an example of how to confirm a key using a fingerprint. (We’re only interested in Step 2.)

(How can a public key be distributed like this and still provide security?)

-Assignment: see the man page on wget for instructions on this simple ftp program

 

3: Now, working in a terminal in the directory containing the key and the fingerprint (saved as a text file), and using the Gstreamer site as an example, issue this command:

gpg –with-fingerprint RPM-GPG-KEY-fedora | head -n 3 | diff – fingerprint

The final diff command had better not show any “difference!” If it does the key is suspect. Get it again, or get the heck out.

 

Importing Keys

It is essential to ease-of-use that you be working in a terminal in the directory containing the key. When you download a key, go to the directory containing the key.

Now you can issue an import command:

Red Hat 7.x
gpg –import <keyfile>

Red Hat 8.0 and later (including Fedora)
rpm –import <keyfile>

Now that you’ve done this, packages from the Fedora/Red Hat (.com) repository will be accepted without complaint (under most circumstances). If you accept packages from other repositories, you’ll need their keys as well (and you’ll need to import them).

Assignment: Go to FreshRPMs and install their package-management configuration package: http://stentz.freshrpms.net/rpm.html?id=390

 

Installation Troubleshooting

Graphical Installation

One of the most common problems you’ll encounter is video corruption in graphical-installation mode or upon first boot after installation. Here’s one way to escape from a corrupted Xwindows environment:

Ctl – Alt – Backspace

This will kill Xwindows and return you to a terminal. Actually, you’ve been there the whole time; you’ve just been working in a graphical subenvironment.

You always have several terminals available to you. You can switch between terminals like this:

Ctl – Alt – F2

Or F3 or F4. When you’re running Xwindows you’re “in” F7, so you can use that Function key to return to your graphical environment. Do note, however, that if you try to run startx you’ll get an error; X is already running!

One of the primary reasons for bad video is frame buffering. When you’re at the boot: prompt, rather than hitting Return or entering linux then Return, use this command:

boot: linux nofb

This disables framebuffer support. You could also force a 640×480 resolution:

boot: linux lowres

Finally, you can force a text-mode installation:

boot: linux text

 

Abnormal Terminations of Installation

There are a handful of problems that can all give you a “fatal error 11” and a crash during installation.

Fatal error 11 is a memory segmentation fault, which is vaguely similar to a buffer overflow: both result from software writing to memory it doesn’t own.

Sound like a software error? Actually it’s often a RAM error. If you’re running RAM that’s rated slower than your motherboard’s maximum, you will likely need to change some settings in your BIOS.

  • Turn off CPU cache memory
  • Increase the number of wait states
  • Get faster RAM

 

Failure to Install the Boot Loader Properly

This is the infamous “1024 cylinders” problem: your boot loader is beyond those cylinders accessible by the BIOS.

Either:

  • Make sure your / partition starts before cylinder 1024 (somewhere before the 8 GB mark), or
  • Set up your /boot partition as the first partition on the disk.

 

Troubleshooting Problems After Installation

Installation Log Files

To see the list of packages that were installed: /root/install.log

To see a list of system events that occurred during installation: /root/install.log.syslog

 

The /proc directory

Do a listing of /proc. There are two kinds of items here:

  • process information (numbered directories), and
  • kernel parameters.

A tremendous lot of information is available to you in this directory.

 

CPU Info

cat /proc/cpuinfo

 

RAM Info

cat /proc/meminfo

 

DMA, IRQs and IO Ports

cat /proc/dma

cat /proc/interrupts

cat /proc/ioports

 

Kernel Modules

cat /proc/modules

 

dmesg

dmesg

dmesg | tail

 

Boot Logs

View a list of system processes, and whether they started successfully or not.

more /var/log/boot.log

tail /var/log/boot.log

Don’t forget that logs are rotated! The most recent archived log is boot.log.1, and older log files are boot.log.2, boot.log.3, etc.

 

Linux Rescue

One good way to get into a damaged system is using the linux rescue command when you get to the boot: prompt after booting the first distro CD.

Installation

About Installation In General

 

There have been many installers in Linux history, but the details are generally the same no matter what distribution you choose. One of the most common installers is the anaconda tool created by Red Hat, and used in other distributions including the Debian-based Progeny distro. SUSE includes package installation management in the all-encompassing YaST utility.

This area of these materials includes both practical discussion and specialized information that you might encounter on certification tests, specifically the Linux+.

 

Boot Loaders

There are (primarily) two boot loaders: lilo and grub.

They can be installed either:

  1. In the Master Boot Record (MBR), or
  2. In the first sector of the active partition; the MBR then holds a pointer to that partition.

LILO

If your system uses LILO, command lilo and you’ll quickly arrive at a

boot:

prompt. Press the TAB key to see the operating systems available.b

Configuration for LILO is performed by the /etc/lilo.conf file. Run:

cat /etc/lilo.conf

to see available options. Visit Peter’s Linux Pages: lilo for deeper discussion.

If you alter /etc/lilo.conf, you MUST reinstall LILO. This is easy:

lilo

does the trick.

Note that you can uninstall LILO using the command:

lilo -U

 

GRUB: The Grand Unified Boot Loader

GRUB is the newer common Linux boot loader; it resembles proprietary Unix boot loaders in design and function.

Stage1 of GRUB is (usually) placed in the MBR. It’s just a pointer to Stage1.5.

Stage1.5 and Stage2 are in the directory /boot/grub/. GRUB refers to the partition containing the GRUB boot loader as the GRUB root partition.

Stage1.5 loads filesystem support, then passes control to Stage2.

Stage2 then begins loading daemons and displays a graphical boot loader screen.

GRUB is configured in the file /boot/grub/grub.conf. Unlike LILO, you do NOT have to reload/reinstall GRUB after making configurations changes.

Also note that there is (usually) a symlink, /etc/grub.conf, to /boot/grub/grub.conf.

Hard drive partitions are referred to using the syntax (hddrive#,partition#), for instance, the first partition of the first drive: (hd0,0).

 

Visit OpenFree.org’s GRUB “Plain English Tutorial” for details and examples.

 

Partitioning

Typically, wizard-based tools perform partitioning during installation, for instance the Disk Druid utility used in Red Hat and Fedora installations.

 

You’ll generally use fdisk for other partitioning needs. Fire it up with the name of the disk to be partitioned:

fdisk /dev/hdc

This places you in an interactive environment, where one-letter commands let you

  • list (l),
  • delete (d),
  • add new partitions (n),
  • set filesystem type (t),
  • write/save (w),
  • ask for help (m) and
  • quit (q).

Of course we all know that a disk can have four primary partitions. One can be used as an extended partition, allowing further partitioning into logical partitions.

 

The /usr directory has to have the room to hold an ever-expanding collection of utilities and programs.

The /var directory can grow wildly as logs, spoolers and email explode.

Free space on the / filesystem must always stay above 10%.

The swap partition (these days) should be at least twice the size of the physical RAM, and can be much larger if you’re running applications that can use it.

Beyond Partitions: Logical Volumes

If you outgrow a partition, tough luck. Get another disk and move your data to a new partition, right?

Not necessarily, if you abstract physical disks from logical volumes. Take a look at the article “Storage Management with an LVM GUI” at
http://www.linux-mag.com/id/7796.

 

The init Daemon

Once the boot loader has performed its function, system initialization is passed to the initialize (init) daemon. This daemon loads all the others, and handles runlevel transitions.

init is also a command, with which you can change runlevels, for instance, from 3 to 5:

init 5

 

The FirstBoot Wizard (Red Hat/Fedora)

Carefully note the User Account screen (in Red Hat distros). You’ll need the Use Network Login button to configure NIS, LDAP (like Active Directory or NDS), Winbind, SMB, and/or Kerberos authentication.

 

Ins and Outs of SCSI

You’re likely to encounter questions dealing with SCSI types, connectors, pin counts, and speeds.

Some Common SCSI Standards
SCSI-1
“narrow/slow”
5
8
50-pin Centronics or 50-pin D (LPT type)
7
SCSI-2
“fast”
10
8
50-pin Centronics or 50-pin D (LPT type)
7
SCSI-2
“wide”
20
16
68-pin D
15
SCSI-3
“Ultra”
40
16
68-pin D
15
SCSI-3
“Ultra2 Wide”
80
16
68-pin D
15
SCSI-3
“Ultra3 Wide”
160
16
68-pin D
15

 

Know at least a few default I/O addresses

Default I/O Addresses
3F8-3FF
COM1
2F8-2FF
COM2
3E8-3EF
COM3
2E8-2EF
COM4
378-37F
LPT1

 

And remember the default IRQ assignments

Default IRQ Assignments
0
System timer
1
Keyboard
2
Linked to IRQ 9
3
COM2, COM4
4
COM1, COM3
5 Available: usually for sound card
6 Floppy controller
7 LPT1
8 Real-time clock
9 Linked to IRQ 2
10 Available
11 Available
12 Available
13 Math coprocessor
14 Primary IDE controller
15 Secondary IDE controller

 

APM and ACPI

APM and ACPI are mutually exclusive. Most computers made in 2002 or later use ACPI.

Edit /boot/grub/grub.conf;
Add line:
apm=off acpi=on

Edit /boot/lilo.conf;
Add line:
apm=off acpi=on

 

RAID

0
Mirroring or Duplexing: Two identical disks
1
Striping: Two disks that look like one, but read/write twice as fast
2
Made obsolete by SMART and similar
3
Obsolete;
disk striping with separate parity;
min. 3 drives;
1 drive holds parity information
4
Obsolete;
Improved on RAID 3 by using block storage
5
Disk striping with striped parity;
min. 3 drives;
parity striped across drives
6
Same as RAID 5 but with 2 sets of parity bits;
allows 2 drives’ failures at once
Combined
e.g. RAID 15, a stripe set with parity, and the whole thing mirrored

 

Creating Bootable Media (Red Hat/Fedora)

Can’t you just boot from the first CD? Yes, you can, if you’re going to install from that CD. But if you’ve already copied the installation ISO images to the hard drive, you need a way to get to a basic working environment.

Insert and access the first Fedora CD.

Navigate to the images directory.

Find the boot.iso file, and use your favorite CD burning software to create a CD directly from the ISO.

There’s also an image named bootdisk.img. Use the “disk to disk” command, dd, like this:

dd if=/mnt/cdrom/images/bootdisk.iso of:/dev/sda1

This assumes your CD is mounted on /mnt/cdrom, and your USB drive appears as /dev/sda1 (both are likely).

Linux II : Supporting Linux Workstations

Linux II : Supporting Linux Workstations

UNM Continuing Education Course

Instructor: Glenn Norman

Text:

Objectives

An advanced understanding of Linux workstation functionality

Familiarity with support, maintenance and deployment of Linux workstations

Continued preparation for the CompTIA Linux+ Certification Exam