| |||||
|
Accessing a console This multi-console behavior is different from the multiple-desktop in Windows. In Linux, each console can be controlled by a completely different user. For example, you can be logged as root on console 1, and logged in as joeuser on console 2. Both consoles run different programs in their own user space. In the same vein, different users can be logged into a Windows system remotely. In this instance, Linux provides capabilities more like a mainframe than a simple server or workstation. If you are in a graphical mode, then you can open a terminal to get access to a console screen. The terminal will usually have a button on your desktop's task bar, or you can find it under System Tools in the Program menu. You can also open a terminal from the context menu (right click on the desktop). Commands cd ls
cp Copying files
mv cat more less vi man man man info Which shell? The default shell is a parameter in each user account. The typical default shell in Linux is /bin/bash, though others are available. The man documentation for each shell is actually very good and goes into detail about shells and how they work. Rather than try to paraphrase that information here, select a shell from the list below and look at its man page. bash csh ksh tcsh zsh
Logging in as root 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 you will need to move the cursor to the password entry field, according to which type of login prompt you had. Type in your password and press Enter again, and you should be logged in and see your desktop. Figure 1 is an example of what you might see as the root user with SuSE Linux 7.3 and a KDE desktop. Figure 2 is an example of what you might see with Red Hat Linux 7.2 and a GNOME desktop. Figure 1. Sample initial window for root
user with SuSE Linux 7.3 and a KDE desktop Figure 2. Sample initial window for root
user with Red Hat Linux 7.2 and a GNOME desktop To explore the desktop, move your mouse over the icons (but try to avoid starting applications until you log in as a non-root user).
The GNOME desktop has similar capabilities. We'll illustrate accessing them via the main menu in Figure 5, but you can also access your preferences from the Start Here view (see Figure 2). As shown in Figure 5, click the Main Menu, then Settings, Peripherals, and finally Mouse. Figure 5. Accessing mouse settings from
GNOME Main menu Opening a terminal or shell window
Figure 7. KDE shell icon
Figure 8. KDE shell icon The appearance of your shell window will depend 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 9. You can use the Settings menu to change things like window colors and fonts. Figure 9. KDE Konsole shell window In Figure 9, we've shown a few commands and their output:
whoami Shows who is using this terminal window, root in this case. pwd Prints the full name of the current working directory, which is /root 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. Users other than root will normally have a home directory under /home. For example, /home/ian would be my home directory on a system where my id was 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 waiting 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 4313. ps With the -T option, displays all processes started by this terminal. In this example, the bash shell program is waiting for input (status S for sleeping) as is the xclock process. The ps command is running (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 only available in man page format. Try man man to find out more about manual pages. Mounting the CD-ROM The examples in these steps refer to a SuSE Linux SLES8 system with KDE desktop and a CD-RW drive mounted as /media/cdrecorder. A CD-ROM would be mounted as /media/cdrom. On earlier SuSE systems your CD drive may be mounted as /cdrom. On a Red Hat Linux 7.3+ system, your CD is likely to be at /mnt/cdrom instead of /cdrom. Use the command cat /etc/fstab from a terminal window to see where the installation process thinks it should be mounted. You will see lines similar to the following:
For this example we'll use a SuSE Linux 7.3 system, and we'll point out the differences for Red Hat Linux afterwards. Let's see how this is all glued together by examining the three commands and their output:
Listing 1. Mounting the CD-ROM
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. 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 third line of output in Listing 1 shows that the CD-ROM device (/dev/cdrom) will be mounted at /media/cdrom unless the mount command specifies otherwise. Linux also has the concept of shortcuts to directories and files, and these are called symbolic links. SuSE Linux has created one for us to make accessing the CD-ROM easier. Let's use the ls command to display the contents of the / directory. Remember that / is the root of our file system, which should not be confused with /root, which is the home directory of the root user. We see from the output in Listing 1 that the / directory contains an entry called cdrom. Now we use the ls command again, but with the -l (for long output) flag and the name /cdrom to display more information about this entry. We see from the -> after the date and timestamp in the output that it is a symbolic link to the /media/cdrom directory. This means that we can use /cdrom anywhere we would have used /media/cdrom. Before mounting the CD-ROM you might want to try displaying the contents of the /cdrom directory. Try entering the ls /cdrom command. If no CD-ROM has been mounted, you should see an entry for . (the /media/cdrom directory itself) and .. (the /media directory, which is the parent directory of /media/cdrom). Normally you will mount devices over an empty directory such as /media/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. At last we are ready to mount the CD-ROM. Insert the disk
in the drive, close the tray, and enter the mount command: If all is well, the CD-ROM drive will spin for a moment and
then your command prompt will return. That's it! Note that you could have
entered this command instead to achieve the same result: Once the 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:
Listing 2. Displaying the contents of disk 1 of the Software Evaluation Kit
Mount differences for Red Hat Linux Listing 3. Displaying /etc/fstab
Red Hat chose to mount the CD-ROM device at /mnt/cdrom
rather than /media/cdrom. If you enter a ls / command on the root directory, you
will not see an entry for cdrom. The Red Hat installation does not create a
symbolic link the way that the SuSE installation did. To create a symbolic link
called /cdrom pointing to /mnt/cdrom, enter this command: To remove such a link, enter the rm command: If Red Hat automount does not automatically mount a CD-ROM
for you, you can use the mount command: Or you can substitute a symbolic link such as /cdrom if you created one. Unmounting and ejecting the CD-ROM 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, then you can use umount /media/cdrom (SuSE) or umount /mnt/cdrom (Red Hat) instead. Logging out Figure 10. KDE logout icon Figure 11. Adding a GNOME logout icon A logout icon will be added to your panel as shown in Figure 12. To secure your terminal without logging out, click the padlock icon to lock the screen. You will 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 Switching to another userid So let's 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 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 4 shows examples of these two forms on a SuSE 7.3 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 (developerWorks, September 2000).
Listing 4. Switching to the root user
You will notice, not surprisingly, that you had to provide a password to switch to root. You can also use the sucommand 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, simply 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 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 be set. Listing 5 shows how to use the echo command to display the DISPLAY environment variable, followed by a switch to another user and an attempt to start the xclock application, first with an empty DISPLAY environment variable and then with the value set to :0.0. Listing 5. Attempting to start xclock
Let's take a look at what is going on here. In this case, the user ian3 logged in to the system and his DISPLAY environment was set to :0.0 as we expect. When ian3 switched to user db2inst1, the DISPLAY environment variable was not set and an attempt to start xclock failed because the application could not open the display. So the substituted user db2inst1, 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. 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 db2inst1 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, ian3 in this case. The simplest solution to this problem is for ian3 to use the xhost command to allow other users on the system to use the display. Open another 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. In the present example, the window running db2inst1 can now launch xclock or other X applications. For more details on using xhost, you can use the command info xhost or man xhost to view the online manual pages. If you are interested in security for X connections, start with the manual pages for Xsecure. Adding users and groups to your system Adding users and groups to your system
with YaST2
Figure 14. 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. 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 User administration near the top of the screen and you will switch from group administration to user administration. Note again that there is a checkbox to allow you to view system users. Click on the Add button to add the mqm user. You may specify a first and last 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.
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.
We will now add the mqm and mqbrkrs group to the root userid. In order to do this we first need to click on Also view system users, then click on the line for the root user, 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 users and groups to your Red Hat
Linux system 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 20. 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 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.
Adding users and groups using the command
line
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.
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. | |||||||||||||||||||||||||||||||||||||||||||||||||||
|