Skip to main content

Linux SEK 2005 Release 1: Basic tasks for new Linux developers

Help! I got my Linux installed. Now what?

Ian Shields (ishields@us.ibm.com), Senior Programmer, IBM
Ian Shields
Ian Shields works on a multitude of Linux projects for the developerWorks Linux zone. He is a Senior Programmer at IBM at the Research Triangle Park, NC. He joined IBM in Canberra, Australia, as a Systems Engineer in 1973, and has since worked on communications systems and pervasive computing in Montreal, Canada, and RTP, NC. He has several patents. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He has an M.S. and Ph.D. in computer science from North Carolina State University. You can contact Ian at ishields@us.ibm.com.

Summary:  IBM offers extensive trial software for Linux®. In most cases, installling it on a Linux system requires you to log in, become the super user (or root) for some tasks, open a terminal or shell window, and mount a CD-ROM. If you are new to Linux, this article will guide you through these tasks and more. You can get trial IBM software for Linux by ordering the Linux Software Evaluation Kit (SEK) 2005 Release 1 or by downloading the trial products directly from developerWorks.

Date:  01 Feb 2006 (Published 01 Aug 2003)
Level:  Introductory
Activity:  14877 views

Introduction

If you're a Windows® developer who wants to try developing on Linux using the IBM Software Evaluation Kit (SEK), and you are new to Linux, this article is for you. We'll cover a few basic tasks that may be different from what you are used to. Even if you're not a developer, but just a new Linux user, you may find this information helpful.

The IBM SEK for Linux contains software that supports Red Hat® Enterprise Linux® and SUSE Linux Enterprise Server, so this article focuses on those distributions. You won't find information here that is specific to Debian, Slackware, Gentoo, or a host of other Linux distributions. And because this article aims to simply help you get started, you won't find information on more advanced tasks like recompiling your kernel or installing software. We recommend our no-charge Linux (LPI) certification tutorials for deeper information; see the Resources section later in this article for links (a quick registration is required for accessing these tutorials).

If you haven't yet ordered your SEK for Linux, visit our Software Evaluation Kit (SEK) page. And check back often, because we are adding specific instructions to help you install each of the trial products on the SEK.


Logging in

These instructions and examples focus on Red Hat Enterprise Linux Version 3 using a GNOME desktop, as well as SUSE Linux Enterprise Server Version 9 (SLES9) using a KDE desktop. Other desktops and window managers are available, such as fvwm2, windowmaker, and twm. Before using these instructions, install a Linux system, for example, according to "Installing and configuring SUSE Linux Enterprise Server (SLES) 8" and create at least one non-root user as part of your installation process.

Once you have installed your system and booted it, you should see a login screen similar to Figure 1 for a Red Hat Enterprise Linux system or Figure 2 for a SLES9 system.


Figure 1. Red Hat Enterprise Linux 3 login screen
Red Hat Enterprise Linux 3 login screen

Figure 2. SLES9 login screen
SLES9 login screen

As you can see, the appearance of the screen varies according to your Linux distribution, and it will probably come as no surprise that you can customize it further, although we won't cover that in this short article. The Red Hat Enterprise Linux 3 screen has an entry field for your login name and hot spots at the bottom that allow you to change your language and session type default (for example, Gnome or KDE), as well as shut down or reboot the system. When you enter an id and press Enter, you will be prompted for your password. The SLES9 screen has entry fields for both id and password, as well as a selection box to choose an id from. Clicking the Menu dropdown gives you access to functions similar to those on the bottom of the Red Hat Enterprise Linux 3 screen.

This screen and its features can be customized. By default, Red Hat Enterprise Linux 3 displays date and time in a digital format, while SLES9 uses an analog time display. Another difference is that on the Red Hat system, anyone at the login screen can reboot or shut down the system, while these functions require a root password on the SLES9 system.

You should type your login name (or root if you are so instructed) in the login field and then press Enter. You will see a password prompt, or your cursor will move to the password entry field, according to which type of login prompt you had. Type in your password and press Enter again. You should now be logged in and see your desktop. Figure 3 shows what you might see as user ian on a Red Hat Enterprise Linux 3 system.


Figure 3. Sample initial window for Red Hat Enterprise Linux 3 and GNOME desktop
Sample initial window   for Red Hat Enterprise Linux 3      and GNOME desktop

To explore the desktop, move your mouse over the icons. In Figure 3, the mouse is over the red fedora icon in the lower left, and the hover help shows main menu. Note also the small icon with four smaller rectangles within it at the right of the row of application icons. You have four distinct desktops, and you can switch between them by clicking the appropriate smaller square or by using the key combination Ctrl-Alt-left arrow or Ctrl-Alt-right arrow to cycle through them in the same way that Alt-tab will cycle through application windows on a given desktop. When exploring, remember to avoid starting applications until you log in as a non-root user.

Figure 4 shows what you might see with SLES9 and a KDE desktop.


Figure 4. Sample initial window for SUSE Enterprise Server 9 and KDE desktop"
Sample   initial window for SUSE Enterprise Server 9      and KDE desktop

As with the GNOME desktop above, you can mouse over icons to see what they do. In Figure 4, we have dragged the panel to the right side of the screen (click on an empty area of the panel and drag to any side of the screen to accomplish this). We also have the mouse hovering over the Start button. As you can see, SUSE Linux presents you with a tip each time you log on. and you will also see such tips when you open terminal windows.


Switching to left-handed mouse usage

A right-handed user is generally assumed, but you can change your mouse configuration for left-handed use. If you are using the GNOME desktop, you can access the mouse preferences using the start here icon on the desktop as shown in in Figure 5. Using the start here icon, you can see icons for some of the other settings that you can customize. For comparison, we have also shown how you can access the same mouse preference setting from the main menu by selecting preferences then mouse.


Figure 5. Accessing mouse settings from GNOME Start here window
Accessing mouse settings from GNOME Start here window

You should see a window similar to Figure 6 where you can change your mouse settings. Notice that the mouse switches sides in the image as you check or uncheck the Left-handed mouse checkbox.


Figure 6. GNOME window to change mouse settings
GNOME window to change mouse settings

If you are using a KDE desktop on a SUSE SLES9 system, you have an option for mouse settings under the control panel (accessible from the start menu). However, at the time of writing, the option to change to left-handed use is grayed out and therefore inoperative (see Figure 7).


Figure 7. KDE mouse settings window
KDE mouse settings window

However, all is not lost. You can run some commands in a terminal window (see Opening a terminal or shell window below) to alter your mouse behavior. Run the xmodmap -pp command, and you will see output similar to Listing 1.


Listing 1. xmodmap -pp output

	

There are 7 pointer buttons defined.



    Physical        Button

     Button          Code

        1              1

        2              2

        3              3

        4              6

        5              7

        6              4

        7              5


To swap the functions of mouse button 1 and mouse button 3, specify a new mapping using xmodmap -e and your desired mapping. To save this new mapping so it takes effect every time the user logs on, save the pointer specification in the file .Xmodmap in the user's home directory. Both these commands are shown in Listing 2.


Listing 2. Changing mouse settings with xmodmap

	

xmodmap -e "pointer = 3 2 1 6 7 4 5"

echo "pointer = 3 2 1 6 7 4 5">~/.Xmodmap


Note the use of ~ for the reference to the home directory of the current user.


Opening a terminal or shell window

You often need to open a terminal or shell window. This window is similar to a DOS command prompt under Windows®. On a KDE desktop, you have a KDE panel at the bottom of the screen, similar to Figure 8. Click the shell icon as shown.


Figure 8. KDE shell icon
KDE shell icon

On a GNOME desktop, you can use the right mouse button on a blank area of the desktop to bring up a context menu similar to Figure 9 where you can select a new terminal. A new terminal window is also available using Start > System tools > Terminal


Figure 9. Opening a terminal window from the Gnome desktop popup menu
Opening a   terminal window from the Gnome desktop      popup menu

The appearance of your shell window depends on your distribution and your choice of desktop. To resize it, you can use the left mouse button to drag the corners or sides of the window. To scroll back through the most recent history, you can use the scroll bar. The command prompt ends with a # character indicating that the user of this shell is user root. For users other than root, the command prompt ends with a $ character. You can use the up arrow to recall previous commands and modify them if necessary. A typical KDE Konsole shell window is shown in Figure 10. You can use the Settings menu to change things like window colors and fonts.


Figure 10. KDE Konsole shell window
KDE Konsole shell window

Figure 10 shows a few commands and their output:

whoami
Shows who is using this terminal window, iant in this case.
pwd
Prints the full name of the current working directory, which is /home/ian in this case. Note that the tilde (~) before the $ in the command prompt shows that the user is currently in his or her home directory.
cd
Changes the current or working directory. We illustrate changing to the / (or root) directory and then to the /tmp directory, which is usually used for storing temporary files. Note that / is the root of the whole file system, and /root is the home directory of the root user. Using cd without any directory name returns the user to the home directory, and using cd - returns you to the last directory you were in before the current one. Users other than root will normally have a home directory under /home. For example, /home/ian is my home directory on a system where my id is ian. Remember that tilde (~)? The home directory for user ian can also be referenced as ~ian.
uname
Without parameters, shows the name of the operating system: Linux. With the -a parameter, additional information is displayed about your system.
which
Scans the directories in your PATH environment variable, and shows the full path to an executable program that would be executed if you typed the command at the shell prompt. In this case, we see that the xclock program would be run from /usr/X11R6/bin/xclock.
xclock
Launches a new window on your desktop with a clock. Note the trailing & on the command, which indicates that the command processor should return control to the terminal window rather than wait for the command to finish. Note also that this is the first such process spawned by this terminal window, and it has a process id (PID) of 4900.
ps
With the -T option, displays all processes started by this terminal. On some systems, the default display from the ps command includes a process status. See the man pages for details on all possible options and output columns. If the status were displayed in this example, you would see the bash shell program waiting for input (status S for sleeping) as would be the xclock process. The ps command is running and would have status R for runnable.

Some other commands that you might find useful include:

info cmd_name
Displays information about the command named cmd_name. Try info info to find out about the info documentation system.
man cmd_name
Is an interface to the online manual (man) pages about the command named cmd_name. Some information is in info format, while some is available only in man page format. Try man man to find out more about manual pages.

Becoming superuser (or root)

For many of the tasks in this article, you will use the special login name of root. The root user, sometimes called the superuser, is the user that is normally used for administrative tasks like configuring the system or installing software. Use root only when you need to do administrative tasks; avoid using root for your normal work. The root user can do anything, including accidentally destroying your system, which is usually not a good thing. Normal users have fewer privileges, and the system is protected from being inadvertently damaged by normal users.

You can always switch to another userid by logging out of the current userid and logging in as the new userid. But what if you only need to run a couple of quick commands as another user? Linux has a solution for you in the form of the su (substitute user) command, which allows you to temporarily run commands as another user. This is often used for tasks that require root access. Indeed, if you connect in remotely to a system using a terminal program such as telnet, then many Linux distributions will prevent you from signing in as root. This is a good security practice, and we encourage you not to try to circumvent it. Rather, you should sign in as a non-privileged user and then use the su command to become root.

So suppose you are logged in and looking at a terminal window and you are not the root user but need to run a command as root. The two most common forms of su for doing this are:

su
su -

The first form (without the - sign) simply switches you to become root, but does not change your environment variables, including your path. The second form uses the - sign, which may also be typed as -l or -login if you really like typing extra letters. This allows the login startup files for the substitute user to be read, thus setting things such as the path, environment, and prompt. Listing 3 shows examples of these two forms on a SUSE Linux system. We've used the pwd (print working directory) command to show the current working directory in each case. Note how the prompts differ. If you'd like to understand more about how to customize your own prompts or what makes these prompts appear as they do, check out the "Prompt magic" tip on developerWorks.


Listing 3. Switching to the root user
	

ian3@echidna:~> su

Password:

echidna:/home/ian3 #pwd

/home/ian3


ian3@echidna:~> su - Password: echidna:~ # pwd /root

You will notice, not surprisingly, that you had to provide a password to switch to root. You can also use the su command to switch to another non-root user. For example:

su - db2inst1

If you are already the root user, you will not need to provide a password, but if you are not root, then you will need to provide the correct password.

To return to the previous id, press Ctrl-d or type exit and press Enter if you are using the bash shell, which is the default on most Linux systems.


Using a GUI application as another user

You may have noticed in the discussion of the su command in the previous section that we ran only commands that displayed output in the terminal window. Depending on the Linux distribution, you may have to take some additional steps to be able to run GUI applications. GUI applications on Linux use the X Window System, which was designed to allow multiple users to access a computer across a network using windowed applications.

An X display is known by a name of the form hostname:displaynumber.screennumber. For Linux running on a workstation such as a PC, there is typically only one display with a single screen. In this case, the displayname may be, and usually is, omitted so the display is known as :0.0. We assume you are using a graphical login if you are reading this, so your startup will have already set the DISPLAY environment variable for you. However, when you use su to switch to a different user, this will not usually be set. Listing 4 shows how to use the echo command to display the DISPLAY environment variable, followed by a switch to root and an attempt to start the xclock application, first with an empty DISPLAY environment variable and then with the value set to :0.0. This example is on a SUSE SLES9 system. There are some differences on a Red Hat system that we'll mention later.


Listing 4. Attempting to start xclock

ian@lyrebird:~> whoami

ian

ian@lyrebird:~> echo $DISPLAY

:0.0

ian@lyrebird:~> su -

Password:

lyrebird:~ # echo $DISPLAY



lyrebird:~ # xclock

Error: Can't open display:

lyrebird:~ # export DISPLAY=:0.0

lyrebird:~ # echo $DISPLAY

:0.0

lyrebird:~ # xclock

Xlib: connection to ":0.0" refused by server

Xlib: No protocol specified



Error: Can't open display: :0.0

lyrebird:~ # export XAUTHORITY=~ian/.Xauthority

lyrebird:~ # xclock

lyrebird:~ # ls -l ~ian/.Xauthority

-rw-------  1 ian users 206 Feb 18 16:20 /home/ian/.Xauthority


Let's take a look at what is going on here. In this case, the user ian logged in to the system and his DISPLAY environment was set to :0.0 as we expect. When user ian switched to user root, the DISPLAY environment variable was not set, and an attempt to start xclock failed because the application did not know what display to use.

So the substituted user, root, set the DISPLAY environment variable, and exported it so that it would be available to other shells that might be started from this terminal window. Note that setting and exporting an environment variable does not use the leading $ sign, while displaying or otherwise using the value does. Note too, that if the su command had omitted the - (minus) sign, the DISPLAY environment variable would have been set as it had been for user ian. Nevertheless, even with the environment variable set, xclock still failed.

The reason for the second failure lies in the client/server nature of X. Although root is running in a window on the one and only display on this system, the display is actually owned by the user who logged in originally, ian in this case. For local displays on Linux systems, authorization usually depends on a so-called MIT-MAGIC-COOKIE-1 which is usually regenerated every time the X server restarts. A user can extract the magic cookie from the .Xauthority file in his or her home directory (using the xauth extract command and give it to another user to merge into that user's .Xauthority file using the xauth merge command. Alternatively, a user can grant authority for other users to access the local system using the xhost +local: command.

There is another alternative which is to set the XAUTHORITY environment variable to the location of a file containing the appropriate MIT-MAGIC-COOKIE-1. When switching to root, it is easy to do this, since root can read files owned by other users. This is, in fact, what we did in Listing 4, so after setting and exporting XAUTHORITY to ~ian/.Xauthority, root is now able to open graphical windows on the desktop. We said we'd mention a difference with Red Hat systems, and that is that using su to switch to root on a Red Hat system is slightly different to a SUSE system in that the display setup is done automatically for you.

So what if you switch to another non-root user? You will notice from listing 4, that the .Xauthority file for user ian only allows user read and write access. Even members of the same group cannot read it, which is what you want unless you'd like someone to open up an application that takes over your screen and prevents you doing anything! So, if you do extract an MIT-MAGIC-COOKIE-1 from your .Xauthority file, then you have to find some secure way to give it to your friendly non-root user. Because of this difficulty, you may find that, for a Linux system with a single user, xhost is easier to use, even though the xauth approach is generally preferred over the xhost command, However, keep in mind the network heritage of the X Window System so that you do not accidentally grant more access than you intended and thereby open up your system and allow arbitrary network users to open windows on your desktop.

To give all local users authority to open applications on the display (:0.0) user ian can use the xhost command. Open a terminal window on your desktop and enter this command:

xhost +local:

Note the trailing colon (:). This will allow other users on the same system to connect to the X server and open windows. Since you are a single user system this means that you can su to an arbitrary non-root user and can now launch xclock or other X applications.

For more details on using the xauth and xhost commands, you can use the commands info xauth, man xauth info xhost or man xhost as appropriate to view the online manual pages. If you are interested in security for X connections, start with the manual pages for Xsecure.


Mounting the DVD or CD-ROM

On Linux and UNIX® systems, all files are accessed as part of a single large tree that is rooted at /. To access the files on a CD-ROM, you need to mount the CD-ROM device at some mount point in the file tree. If your distribution installed the automount package, this step might be automated for you. If so, you need only insert the disc and it will be recognized and mounted. In any event, your installation process is likely to have done some work for you to make mounting a DVD or CD-ROM device easy.

The examples in these steps refer to a Red Hat Enterprise Linux 3 system. You will notice some differences according to the type and location of your optical drive (CD or DVD, IDE, SCSI or USB, and so on). There are also some differences between Red Hat and SUSE implementations, so you should consider this information as guidance that will help you find the right settings for your own system. In particular, most removable devices are mounted in the /mnt tree on Red Hat Enterprise Linux 3, while they are mounted in the /media tree on SLES9.

Many of the settings for your Linux system are stored in the /etc directory. Among these settings is a file containing a table of descriptive information about your file systems. The cat command copies and writes files. If no output files are given, the output is directed to standard output, which is usually your terminal window. Use the command cat /etc/fstab from a terminal window to display etc/fstab and see where the installation process thinks your CD or DVD should be mounted. You will see lines similar to Listing 5. The last two lines of output in Listing 5 show that this system has two CD or DVD devices (/dev/cdrom1 and /dev/cdrom), which will be mounted at /mnt/cdrom1 or /mnt/cdrom unless the mount command specifies otherwise.


Listing 5. Contents of /etc/fstab



[root@lyrebird root]# cat /etc/fstab

LABEL=RHEL3       /             ext3    defaults        1 1

none              /dev/pts      devpts  gid=5,mode=620  0 0

LABEL=GRUBFILE    /grubfile     ext3    defaults        1 2

none              /proc         proc    defaults        0 0

none              /dev/shm      tmpfs   defaults        0 0

/dev/hda7         swap          swap    defaults        0 0

/dev/fd0          /mnt/floppy   auto    noauto,owner,kudzu 0 0

/dev/cdrom1       /mnt/cdrom1   udf,iso9660 noauto,owner,kudzu,ro 0 0

/dev/cdrom        /mnt/cdrom    udf,iso9660 noauto,owner,kudzu,ro 0 0


Let's see how this is all glued together when we mount our disc using the mount and ls commands as shown in Listing 6.


Listing 6. Mounting the DVD or CD disc

	

[root@lyrebird root]# ls /mnt/cdrom

[root@lyrebird root]# mount /mnt/cdrom

[root@lyrebird root]# ls /mnt/cdrom

autopp.ini   autorun.inf  install         product.list  rr_moved

autorun      html         installinfo.sh  products      SK3T-9867-00.001

autorun.exe  index.html   patch           readme


This example used the ls command to display the contents of /mnt/cdrom and got no output. This is normal for the mount point of a filesystem that is not yet mounted. Compare this to the behavior of the dir a: command on a drive with no floppy on a Windows system. Next we used the mount command to mount the disc. Note that we only gave the mount point. For mount points defined in .etc.fstab, it suffices to give either the mount point or the device name (/dev/cdrom or .dev.cdrom1) in this case. When mounting other file systems, you may need to use some of the parameters that you saw in the listing of /etc/fstab. Notice the different output from the ls command after the disc is mounted. Depending on your system, you may also be prompted as to whether to run the autorun file in the root of the disc or not.

Here, we used the root user to mount the disc. Depending on the values in /etc/fstab, it may be possible for a non-root user to mount the disc. The disc may also be mounted automatically on some systems. Once mounted, you should see an icon for the disc on your desktop.

Linux also has the concept of shortcuts to directories and files, and these are called symbolic links. We won't cover them in this article, but they can be extremely handy. For example, you could create a symbolic link in your root directory to the CD drive so that you could refer to /cdrom instead of /mnt/cdromby using the command:

ln -s /mnt/cdrom /cdrom

If you do this and then run the ls command again, but with the -l (for long output) flag and the name /cdrom to display more information about the entry for /cdrom, you would see additional information showing that it is a link and that it points to /mnt/cdrom. This means that you can now use /cdrom anywhere you would have used /mnt/cdrom.

To remove a symbolic link, enter the rm command:

rm /cdrom

Normally you will mount devices over an empty directory such as /media/cdrom or /mnt/cdrom. If you happen to mount a device over a directory that contains files, you will not be able to see those files until you unmount the mounted file system. Your data will still be there, but you won't be able to access it.

Once a DVD or CD is mounted, you can use the files on the disk as they are now part of your file system. Using the ls command, you can display the contents of disk 1 of the Software Evaluation Kit as we did above.


Unmounting and ejecting the CD-ROM

While a CD-ROM is mounted, Linux will lock the CD so that it cannot be ejected with the Eject button. Instead, when you no longer need the disk, use the umount /cdrom to unmount it (assuming you have /cdrom as a symbolic link). (Note that umount is spelled without an n after the u!) This command will only succeed if no user is using the disk, which includes having a terminal window with the current working directory as a directory on the disk and if you have sufficient authority to unmount the volume.

You can also use eject /cdrom to both unmount the file system and eject the disk.

If you don't have /cdrom as a symbolic link (or even if you do), then you can use umount /media/cdrom (SuSE) or umount /mnt/cdrom (Red Hat) instead.

Finally, if you are using a KDE or Gnome desktop and you were the user who mounted the disk you can probably right click on the disc icon on your desktop and use the context menu to either eject or unmount the disc. Once the disc is unmounted, the icon will disappear from your desktop.


Logging out

To log out click Start and then logout. On Both SUSE and Red Hat systems you can easily add a panel icon for logout and one for locking the screen. The method is similar for both systems. We will illustrate here using a Red Hat system. Start by right clicking on a blank part of the panel. If you explore the menus available, you will find an options to add logout and lock icons tot he panel. For Red Hat these may be added individually. On SUSE SLES9, they are added together as a pair. The Red Hat menus look like Figure 11,


Figure 11. Adding a logout button with Red Hat enterprise Linux 3
Adding a logout button with Red Hat enterprise Linux      3

A logout icon will be added to your panel as shown in Figure 12.


Figure 12. GNOME logout icon
GNOME logout icon

You may add a button to lock the screen in the same way. On SUSE SLES9 systems you will add both together. To secure your terminal without logging out, click the padlock icon to lock the screen. You will then need your login password to unlock the screen.

Note: On some SuSE systems running KDE, you may lock the screen and not be able to unlock it with your password. The first time this happens, you will probably have to turn off the machine and restart. To prevent it in the future, make the kscreensaver in /etc/pam.d the same as the xscreensaver. For example, if you want to save the existing kscreensaver as kscreensaver. original and make sure that the new kscreensaver has the same timestamp as the xscreensaver from which it is copied, log in as root and use the following commands:

cd /etc/pam.d
mv kscreensaver kscreensaver.original
cp -p xscreensaver kscreensaver

Adding users and groups to your system

Sometimes you will need to define new users of your system and new groups for those users. You may need to define a user called mqm and a group also called mqm (as well as another group called mqbrkrs when installing the embedded messaging component in WebSphere Application Server. Usually you will define the group first and then define the users who will use the group, so that's what we will do here. You can either use the graphical tools for user administration or enter commands in a terminal window. We'll give an overview of the graphical process here using SuSE's YaST2 tools to create a user called mqm and a group also called mqm. Then we'll tell you where to find the corresponding tools on a Red Hat Linux system. Finally we'll give you the commands if you really want to do it from the command line.

Adding users and groups to your system with YaST2

On a SUSE SLES9 system with KDE, you should have a YaST icon on your desktop (as we saw in Figure 4). Open this application and click on Security and users in the left panel to view the tasks shown in the main panel of Figure 13. .


Figure 13. YaST2 Control Center
YaST2 Control Center

Click the Edit and create groups item. On the next screen you will see any existing groups. Note that there are a number of system groups that were created when you installed your system. If you'd like to see them, click on the Set filter dropdown near the bottom of the screen and select System groups. .


Figure 14. YaST2 User and group administration
YaST2 User and group administration

Click on the Add button to add a new group. For this example we will enter the group name mqm and leave all other fields unchanged. Then click on Create to create the group. You will return to the screen shown in Figure 14 and it will now show your new group. In the same way, add a group called mqbrkrs.


Figure 15. Adding a group
Adding a group

This time, when you return to the screen of Figure 14 you will see your two new entries. You are now ready to add the mqm user. Click on the radio button for Users near the top of the screen and you will switch from group administration to user administration. Note again that there is a dropdown to set a filter for which users you see. Click on the Add button to add the mqm user. You may specify a name for the user. specify mqm as the User login> and specify a password. Then repeat the password to make sure you did not make a typing error. Check your entries and click the Details button as we have some more to do for this user.


Figure 16. Adding a user - part 1
Adding a user - part 1

By default, new users have a home directory created for them in /home, so the default for mqm would be /home/mqm. However, the MQ Series software usually uses /var/mqm as the home directory for the mqm user, so we will change the home directory to /var/mqm. We will also use the dropdown list to make mqm the default group for our new user. finally, we will scroll down the list of additional groups and make mqm a member of the mqbrkrs group. Click Next to return to the screen of Figure 16, then click on Create to create the new user.


Figure 17. Adding a user - part 2
Adding a user - part 2

We will now add the mqm and mqbrkrs group to the root userid. In order to do this we first need to click on Set filter dropdown, then click on System Users. Then click on the line containing root to select it, and then click on the Edit button. As you did for the mqm user above, click on Details and scroll down the Additional groups list and click the check boxes for both the mqm and mqbrkrs groups to add root to these groups.


Figure 18. Adding groups to a user
Adding groups to a user

Click on Next to return to the first edit screen, then Next to return to the user administration screen. Finally, click on finish to commit all your changes.

Adding users and groups to your Red Hat Linux system

For the purposes of this exercise we will assume a Red Hat Linux 8.1 system running the GNOME desktop. If you are using the KDE desktop or a different version of Red Hat Linux, you will find some differences. A review of this section and the previous section should give you a good idea of what to expect and enough information to accomplish the tasks.

First you need to start the Red Hat User Manager. Click on the GNOME Menu icon (with the red hat logo) at the left of the taskbar, then System Settings, and then Users and Groups.


Figure 19. Users and Groups from the taskbar
 Users and Groups from the taskbar

You may also access System Settings, and then Users and Groups from the Start Here icon on your desktop.


Figure 20. Red Hat Start Here icon
Red Hat Start Here icon

If you are not logged in as root you will need to provide the root password when prompted. You will then see the Red Hat User Manager screen. To view system users and groups click on the filter setting under the preferences menu as shown in Figure 21.


Figure 21. Red Hat User Manager
Red Hat User Manager

We could do as we did above for the SuSE system and define our groups first. However, the Red Hat User Manager has a feature that will be convenient for us which is to create a private group for a user with the group name being the same as the user name. So we will click on the Add User button and fill in the details for the mqm user. Remember to set the home directory to /var/mqm.


Figure 22. Adding a user in Red Hat Linux
Adding a user in Red Hat Linux

After you click OK you will be returned to the Red Hat User Manager. Click on Add Group to add the mqbrkrs group. Once you have the group defined you will need to add root to the mqbrkrs and mqm groups. You can either select a group and use its properties to add users or select a user and use the properties to add groups. We'll click on the Users tab above the list and then click on the root user and then click on the Properties button to open the user properties. When the properties window is open, click on the Groups tab and scroll down to the mqm and mqbrkrs entries. Click to place a check mark in each of these indicating that root is now a member of these groups. When you are done, click on OK to return.


Figure 23. Red Hat User Manager
Red Hat User Manager

Figure 24. Adding groups to a user
Adding groups to a user

Repeat this procedure to make the mqm user a member of the mqbrkrs group. If you prefer you can switch to the group list view and try adding mqm to the group rather than adding mqbrkrs to the user. You may close the Red Hat User Manager when you are done.

Adding users and groups using the command line

Information on groups is stored as a flat file in /etc/group. You may use the groupadd command to add a new group. This is fairly simple. Adding a new user is a little more complex as there are more parameters and you will need the numerical number of the mqm group when you add the mqm user. Let's use the groupadd command to add our two groups, mqm and mqbrkrs, and then use the grep command to search /etc/group and tell us what group numbers were assigned.


[root@echidna root]# groupadd mqm

[root@echidna root]# groupadd mqbrkrs

[root@echidna root]# grep mq /etc/group

mqm:x:501:

mqbrkrs:x:502:


In this case, the mqm group is group number 501 and the mqbrkrs group is 502. Now let's use the useradd command to add the mqm user. The -c option allows us to specify a comment which is usually a user's real name. The -d option allows us to specify the home directory for the user. The -g option specifies the user's primary group. Here we use 501, which is the mqm group as we just learned above. This number may be different on your system. The last option we use the -G option to specify additional groups for this user. Here we can use the group name. Once you have added the user you can use the grep command again and you will see that user mqm has been added to the mqbrkrs group. At this point you have created a new user, but the user does not have a password and cannot log on to the system. Some users do not need to log on, so that would be alright for those users. The root user has the authority to set (or reset) passwords for other users. To do this, you use the passwd command and give the username as a parameter. You will be prompted for the new password and then you will be prompted to retype it for verification.


[root@echidna root]# useradd -c"MQ Messaging" -d/var/mqm -g 501 -G mqbrkrs mqm

[root@echidna root]# grep mq /etc/group

mqm:x:501:

mqbrkrs:x:502:mqm

[root@echidna root]# passwd mqm

Changing password for user mqm.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.


Finally, you may need to add users to an existing group.You can use the usermod command to do this but you require the list of existing groups for the user as you will replace the list of additional groups. It is therefore easier to simply edit /etc/group. Make a backup copy first, just in case you make a mistake. To add the root user to both the mqm and mqbrkrs groups that we have just created, edit /etc/group and update the lines for mqm and mqbrkrs so they look as follows.


mqm:x:501:mqm,root

mqbrkrs:x:502:mqm,root


You will find much of the user information in /etc/passwd. However, if you are not a full time system administrator you will probably find it easier to do occasional manipulation of users and groups through the graphical interfaces.


Resources

Learn

Get products and technologies

  • Order the SEK for Linux, a two-DVD set containing the latest IBM trial software for Linux from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.

  • With IBM trial software, available for download directly from developerWorks, build your next development project on Linux.

Discuss

About the author

Ian Shields

Ian Shields works on a multitude of Linux projects for the developerWorks Linux zone. He is a Senior Programmer at IBM at the Research Triangle Park, NC. He joined IBM in Canberra, Australia, as a Systems Engineer in 1973, and has since worked on communications systems and pervasive computing in Montreal, Canada, and RTP, NC. He has several patents. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He has an M.S. and Ph.D. in computer science from North Carolina State University. You can contact Ian at ishields@us.ibm.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=49680
ArticleTitle=Linux SEK 2005 Release 1: Basic tasks for new Linux developers
publish-date=02012006
author1-email=ishields@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers