Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Small Office Linux

by Michael J. Norton
12/01/2000

Learning computer technology these days can seem overwhelming. It's not the technology itself that is the root of this evil; it's often the size of the book that we must drag home from the Super Crown bookstore.

True system administration requires attention to detail, but in this age, I fear we are drowning in a little too much information. Do you really need a thousand-page book in order to become a Linux Administrator in 28 Days? Can anyone read a thousand-page Unix guide in 28 days? That's the real question.

Perhaps all you really need is a little practical direction. I know from personal experience that Linux administrators come from all walks of life. A Linux admin can be a precocious teenager enthralled with the wonders of technology, or a secretary in a small office with newly expanded job duties, or someone just looking to improve themselves for a better job.

Where to start? The truth of the matter is that professionals in this field today probably own the big Linux books, but it wasn't these books that helped them when they first started learning their craft. Today's successful administrators had someone called a mentor. Someone to SHOW them how to configure a Unix system. This is how many admins learned their trade.

Related Resources:

Living Linux - How does a new Linux user go about getting day-to-day tasks accomplished? This series of articles by Michael Stutz offers some solutions to newbies and advanced users alike.

FreeBSD Basics - Dru Lavigne's series on FreeBSD includes useful tips and tutorials that can often be helpful to Linux users as well.

This guide should help you get started in the basics of small office system Linux administration. We'll go step by step: setting up the network interface connection, creating user accounts, and then some simple package installation. Once these are configured, you can then consult the really big books.

Setting up the network connection

Probably wasn't any longer than 18 months ago when the standard equipment for getting online was a 56K modem. How things have changed. DSL and the cable modem are rapidly becoming the standard means of Internet connection for the small office/home office environment.

Both the DSL and cable modem service providers typically assign an IP address to clients in your network using Dynamic Host Configuration Protocol (DHCP). IP addresses for your network are most likely assigned by your DSL router or cable modem, which have a pre-assigned range of addresses for your equipment. You will need to configure your Linux system to request addresses from a DHCP server.

I'll walk you through a DHCP configuration. In this example, I have an administrator, Dr. Morbius, who is setting up a Linux system to store a database on important research he is conducting. He has completed the installation of Linux onto his system and now he is configuring his network interface so he can use his Netscape browser.

At the moment, the only account available to Dr. Morbius is the user root. Which is okay, because he will need to modify some privileged network files in the /etc directory.

Dr. Morbius will need to create a configuration file for his Ethernet adapter. He changes his current directory to /etc/sysconfig/network-scripts and creates the file ifcfg-eth0.

This file contains the following configurations for DHCP:

DEVICE=eth0
IPADDR=
NETMASK=
ONBOOT=yes
BOOTPROTO=dhcp
BROADCAST=
NETWORK=
USERCTL=no

Dr. Morbius closes this file after a careful inspection for typos. He then changes his current directory over to /etc/sysconfig and edits the file network. The following changes are made by Morbius for his DHCP connection:

NETWORKING=yes
FORWARD_IPV4=no
HOSTNAME='altairIV.unitedplanets.com'
DOMAINNAME=unitedplanets.com
GATEWAY=0.0.0.0
GATEWAYDEV=eth0

Dr. Morbius is from the old school of Unix; he really likes using vi. However, he's aware that under the GNOME window environment, when logged in as user root, there is a graphical interface to accomplish the same thing under the caption "Another Level of Menus," followed out to "Administration."

Now, Dr. Morbius is working on a workstation running LinuxPPC. He wants to use the pump utility to initialize his DHCP interface. The LinuxPPC installation does not install pump, so Dr. Morbius must install it from his LinuxPPC 2000 CD. This is easily accomplished when Morbius mounts his CD-ROM drive.

mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom/software

This is a quick example of how the CD-ROM is mounted on your system so you may access it. Dr. Morbius keeps in the back of his mind that he should later add this device to the /etc/fstab configuration.

To install the pump software, Dr. Morbius uses the Redhat Package Manager utility, called rpm. The install is simple.

[root@altairIV software] rpm -i pump-0.7.2-2.ppc.rpm

The pump utility is then installed onto Dr. Morbius' LinuxPPC workstation. He next brings up his network interface by typing the command

pump -i eth0

Our good doctor waits a moment and then the interface initializes. Morbius can also view the specifics of his connection by typing the command pump -s. More information on pump can be found on the man pages, the online manual for most Unix operations, for pump.

Adding user accounts

When your Linux system first boots, you'll have at least one user account, root. For initial setup, having the root super user account is okay. A safer approach is to create a user account and use this for most of your Linux usage needs. If you're learning Unix administration, creating user accounts is a basic and frequent task in system management.

Most Unix operating systems provide a utility for adding users. As super user (root), you can use the tool adduser. You may want to examine the man pages on the exact syntax of this command. At your prompt, type man adduser and hit the return key. Take a moment to examine the syntax; it may look like garble at the moment, but we'll examine the arguments to this command. (The term arguments identifies the options we will use with this command.)

Now the task at hand is to create a new user. The very first user account you should create is one for yourself. As I mentioned, using your system as user root is not advised. For this example, Dr. Morbius has chosen to use the tc shell for his activities and would like for his new account to reside in the /home directory. As a user, Dr. Morbius will also need a unique ID, uid, so he will use his employee ID, 2257.

Now, having read the man pages, Dr. Morbius takes a bold step and creates a user account for himself. Using the utility adduser, he types the following:

adduser morbius -d /home/morbius -u 2257 -s /bin/tcsh -c "Krell Research Admin"

The account login name is morbius, the home directory (the -d option from the man page) is /home/morbius with user ID (the -u option is uid) 2257, and the login shell is the tc shell. Now, in simple terms, this is what this means: Whenever Dr. Morbius logs into his system, he will log in as user morbius, and his default directory will be /home/morbius.

What's a uid?

A unique ID (uid) is a 32-bit integer that is paired with a login name. The super user, root, is assigned the uid of 0. You will want to start assigning your users unique IDs starting at or above the integer 100. Most IS organizations pair the employee number with the user login, since the employee number is unique within the company. In our example, Dr. Morbius is employee 2257 and we used this for his uid.

This unique pairing of login names and IDs is important especially in networked environments where privileges to different Linux machines are to be assigned. An example would be using Network File Services (NFS).

What files does adduser modify?

The boot of the man pages for function adduser clearly identifies which files this utility modifies. Two files the utility changes are /etc/passwd and /etc/shadow. The passwd file is primarily the key file where we create the user account. The adduser command added the following line to create the morbius account:

morbius:x:2257:2257:Krell Research Admin:/home/morbius:/bin/tcsh

The other file modified is /etc/shadow which contains the encrypted password string. Currently, there is no password for the morbius account. We can create one in the following manner,

passwd morbius
Changing password for user morbius
New UNIX password:
Retype new UNIX password:
Passwd: all authentication tokens updated successfully

Cool prompts

By now you probably have noticed that the system prompts for root and morbius differ significantly. The prompt for root displays the username, root, the hostname, altairIV, and the current working directory. Recall that Dr. Morbius set up his default shell for /bin/tcsh, the enhanced C-shell. We can add functionality to a user account by creating a resource file, .tcshrc, for our enhanced C-shell. Using his favorite editor, Dr. Morbius created the following .tcshrc (note the leading period for this file name) resource file in his account home directory (/home/morbius):

# .tcshrc
# executables PATH
setenv PATH "/usr/sbin:/sbin:$PATH"
# user specific aliases and tools
alias win 'xterm -sb -sl 1000 -T \!* -e telnet \!* &'
set prompt='[%n@%m %c]# '

Upon closing the saving the file and exiting his editor, Dr. Morbius uses the source command to invoke the functionality in his resource file.

source .tcshrc
[morbius@altairIV ~]

The changes take place in your shell environment immediately. You'll also notice that the prompt isn't the only thing Dr. Morbius tossed into his resource file. He included an environment variable, PATH, for executables and also an alias, win, to condense the long xterm command.

Shell resource files can get pretty complex, and knowledgeable users may customize their own files. An exhaustive listing of the capabilities of the .tcshrc file can be found on your system using the command man tcsh.

Substitute user -- su

Now that Dr. Morbius has created an account for himself, he is now the company guru and will be given the responsibility of maintaining the system. From time to time Dr. Morbius may need to quickly change from user morbius to root to examine a problematic account or to turn on a daemon. The substitute user, su, command provides the flexibility user morbius will need so he doesn't have log out and then log in as root.

Before user morbius can use the su command to become root, some modifications must be made to the /etc/group file. On Unix systems there exist group IDs (gids), which are similar to the previously mentioned uids. The uid identifies the owner of a file or process and the gid identifies a specific group of users.

To allow user morbius to use the su command to change to user root, morbius needs to be a member of the wheel group. The master group file is located in /etc/group. Edit the file, using emacs or vi, and modify the wheel group entry to include the user:

wheel::10:root, morbius

Making this little modification will allow user morbius to quickly change himself to root in the following manner:

[morbius@altair /home/morbius] su
Password:
[root@altair /home/morbius]

Software package installation

At this point we have set up a network interface to get out to the Internet. We have also set up a user account. Now let's watch as our Linux guru, Dr. Morbius, installs a Java development package on his system. Dr. Morbius is running LinuxPPC 2000 on his G4, so he must download LinuxPPC JDK from penguinppc.org. This URL will take you to the image download page. (Remember to hit the shift key when downloading.) There are other Linux devices in the unitedplanets.com domain that aren't LinuxPPC, and these JDKs can be found at blackdown.org. Regardless, the same installation instructions will apply. For this example, Dr. Morbius is going to download the JDK 1.3.0 FCS (First Customer Ship) image from penguinppc.org.

JDK 1.3.0 FCS installation

For simplicity, Dr. Morbius downloads his compressed JDK image to his home directory, /home/morbius. Knowing that the compressed image is going to take some time to download over his DSL connection, Dr. Morbius first downloads the README.ppclinux text file. This gives him something to read while he waits for the large file to transfer to his home directory.

[morbius@altairIV ~] ls j2sdk*
j2sdk-1.3.0-FCS-linux-ppc.tar.bz2

The file has successfully downloaded; now Dr. Morbius changes to user root, using the handy su command he set up earlier. This file, according to the README.ppclinux document, most be moved to the /usr/local directory, owned by root.

[morbius@altairIV ~] su
Password:
[root@altairIV morbius] mv j2sdk-1.3.0-FCS-linux-ppc.tar.bz2 /usr/local
[root@altairIV morbius] cd /usr/local
[root@altairIV local]

To this point, Morbius, now root user, has moved the compressed JDK file, j2sdk-1.3.0-FCS-linux-ppc.tar.bz2, from his /home/morbius directory over to /usr/local. Now he will proceed to install the JDK 1.3.0 package using the tar compression utility to uncompress the file.

[root@altairIV local] tar -Ixf j2sdk-1.3.0-FCS-linux-ppc.tar.bz2

When the file decompresses, it will set up a directory structure under /usr/local/j2sdk1.3. Since the file is installed by root, its privileges are set to those of root. For the time being, Dr. Morbius will set up the directory privileges for user morbius. This is what he does:

[root@altairIV local] chown -R morbius:morbius j2sdk1.3

Now user morbius has privileges set for accessing this SDK. As more users want access to this JDK, Dr. Morbius will have to establish a group, dev_tools, for instance, and add individual users to this group, thus assigning the dev_tools group as the privilege level for the JDK.

Environment variables

Now that a JDK package is installed, it's time for Dr. Morbius to set up environment variables to access these tools. And where does he do this? Why, in his C-shell resource file of course. The following lines are added to user morbius' .tcshrc file:

set path = ( $path /usr/local/j2sdk1.3/bin )

After this path variable is set, Dr. Morbius then closes his resource file and uses the source command to update the changes. Now, for a test run, Dr. Morbius creates a simple Java file, test.java.

import java.io.*;
public class test {
public static void main( String[] args ) {
System.out.println("hello\n");
}
}

To compile this, he enters the following commands from his prompt:

[morbius@altairIV ~] javac test.java
[morbius@altairIV ~] java test
hello

That's it! The JDK package is now installed. The README file for some packages may be a little intimidating. But once you have a good mentor, like Dr. Morbius, to show you the ropes, these tasks can seem a lot simpler.

Other exciting packages to install

Now that Dr. Morbius has whetted your appetite and built your confidence, there are two packages I strongly recommend you download.

One is the 3D rendering program, Blender. This is a full featured 3D rendering suite and a game tools library. This suite alone makes owning a Linux system worth the while. The other nice download is the RealPlayer 8 Basic free software. This multimedia player software is supported by the Linux community and is available for the LinuxPPC. Select the Unix OS and a new page will launch listing various Unix operating systems, LinuxPPC 2000 included. If you really want to see what cool things are available, I recommend heading over to the freshmeat.net site. If it's written for Linux users, you'll probably find the software you're looking for there.

Where do you go from here?

Related:

UNIX in a Nutshell: System V Edition, 3rd Edition

UNIX in a Nutshell: System V Edition, 3rd Edition
By Arnold Robbins

As I mentioned earlier, Linux books usually are published by weight. A thicker book isn't necessarily better. I purchased a book in the early nineties that is still the most often used book on my bookshelf. This is O'Reilly's UNIX in a Nutshell, by Daniel Gilly. It's a relatively inexpensive book, and it's the book I always turn to when I need to seek help for Linux commands.

This book isn't a tutorial; rather, it's a quick reference manual on how to use various Unix commands. I'll admit that I am one who rarely gets much use out of reading man pages, but this book helps out a great deal.

The other great resource is the Internet. Use it to seek advice through mailing lists. Once you're there, don't be afraid to ask questions. For any LinuxPPC questions, consult the linuxppc-user list, which has a huge knowledgebase online.

Use these resources as your online mentors. Many of these people are willing to dive in and give newbies a hand.

Michael J. Norton is a software engineer at Cisco Systems.


Related Resources:

Living Linux - How does a new Linux user go about getting day-to-day tasks accomplished using open source software? This series of articles offers some solutions to newbies and advanced users alike.

FreeBSD Basics - Dru Lavigne's series on FreeBSD includes useful tips and tutorials that can often be helpful to Linux users as well.

Discuss this article in the O'Reilly Network Linux Forum.

Return to the Linux DevCenter.

 

Copyright © 2009 O'Reilly Media, Inc.