(pt)Sun Certified System Administrator for Solaris 8 Study Guide, Exam 310-011
(cn)Chapter 1
(ct)Understanding System Concepts
Define the effect of using various man command options when viewing online manual pages
In this chapter, we're going to touch on all three in very general terms. The rest of the book will go into very specific details, but first we need to define some common terms. This chapter will cover the basic terminology in system administration and the use of the man command. It's a starting point designed to give you the foundation which the rest of the book builds on.
A process is an instance of a running program. So, while a daemon is a process, a process doesn't have to be a daemon. You can see all the processes which are running on your system by using the ps command. The ps command can be used to display all of the processes at once. This can be one big list even on a little-used system. Naturally, with the use of command options, you can use the ps command to display just the information you're looking for. We'll cover the ps command in more detail in later chapters, but for now, let's take a look at some of the daemons which are running on your system right now.
Exercise 1.1 - Viewing the daemons on a system.
Let's first take a look at what is going on behind the scenes on our Solaris system. For this exercise, our system's hostname is "sol".
Step 1. Log on to the system
[luna: ra]$ telnet sol
Trying 192.168.1.10...
Connected to sol.
Escape character is '^]'.
SunOS 5.8
login:ra
password: **********
Last login: Tue Apr 3 19:12:13 from :0
Sun Microsystems Inc. SunOS 5.8
Welcome to Sol - This system will be down for 4 hours this Sunday for upgrades. Call ext. 3649 if you have any questions.
[sol: ra] $
Step 2 - See the processes.
Now, we've logged in to sol as the user "ra" and seen a message from the very conscientious System Administrator regarding a planned outage. Next, let's take a look at the processes, including the daemons, which are currently running on sol by using the ps command.
[sol: ra] $ ps -ef | more
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 Mar 20 ? 0:03 sched
root 196 1 0 Mar 20 ? 0:16 /usr/sbin/nscd
root 206 1 0 Mar 20 ? 0:00 /usr/lib/lpsched
root 177 1 0 Mar 20 ? 0:01 /usr/sbin/syslogd
root 268 1 0 Mar 20 console 0:00 /usr/lib/saf/ttymon -g -h -p cc9972-b console login: -T sun-color -d /dev/cons
root 158 1 0 Mar 20 ? 0:01 /usr/sbin/inetd -s
root 157 1 0 Mar 20 ? 0:00 /usr/lib/nfs/lockd
daemon 160 1 0 Mar 20 ? 0:00 /usr/lib/nfs/statd
root 186 1 0 Mar 20 ? 0:01 /usr/sbin/cron
--More--
We used the ps command with the "e" and "f" options. This displayed every process and displayed a full listing. Since the list would easily cover more than one screen, we piped ( | ) the display into the "more" command. This way we can see on screen at a time, by pressing the space bar, we see "more" of the display. We'll cover the ps command in more detail later. For now, let's go daemon hunting!
The output of the ps command includes the following line, which is highlighted above:
root 206 1 0 Mar 20 ? 0:00 /usr/lib/lpsched
This is one of the daemons running on the system named sol. It's the printer spooling daemon, lpsched. This daemon waits for print requests, then sends the print job to the requested printer. It's always running, waiting for a print job to come in.
Exam Watch: Remember that most daemons end with the letter "d". Most are started by initialization scripts at boot time, but that this is configurable. Daemons can be stopped or restarted as needed. You will often have to restart a daemon after making a configuration change to it's service. Another instance would be to fixed a stuck print queue, you might have to stop/start the print spooler daemon.
The Bourne shell was written by SR Bourne and can be found on nearly all UNIX systems. While it lacks some of the bells and whistles of others, it remains one of the most prevalent shells in UNIX. The shell is located at /bin/sh and uses a "$" at the user prompt. Shell scripts are most often written to be run by the Bourne shell because of it's excellent input/output control and expression matching features. However, many people felt it lacked strong interactivity features.
To answer this need, the fine pioneers at UC Berkley developed the C-shell. This shell, located at /bin/csh and using a "%' at the user prompt, provides features not found in Bourne, such as job control, command history and aliasing. It's designed to use command syntax which resembles C, the programming language used to write UNIX. However, many people feel that it lacks strong control of input and output.
In an effort to combine the best of both, David Korn developed the Korn shell. The Korn shell can be found at /bin/ksh and uses a "$" at the command prompt. The Korn shell is a subset of the Bourne shell, but adds features such as aliasing, history and the popular command-line editing.
These three shells are provided as part of the Solaris Operating Environment. We will cover them in more detail later in the book, but for now let's take a look at how we can try a new shell.
Exercise 1.2 - Changing your shell.
When you create a user, the default shell assigned to that user is the Bourne shell. Let's walk through the steps you can use as the sysadmin to change a user's shell. Once again, we'll be using a Solaris 8 system named "sol" as our example.
Step 1. Login to the system and find out what shell you are using.
[luna: ra]$ telnet sol
Trying 192.168.1.10...
Connected to sol.
Escape character is '^]'.
SunOS 5.8
login:ra
password: **********
Last login: Tue Apr 4 17:22:10 from :0
Sun Microsystems Inc. SunOS 5.8
Welcome to Sol - Thanks for your cooperation during our upgrade process. This system now has two additional CPU's, 4 more gigs of RAM and a new UPS. Call ext. 3649 if you have any questions.
[sol: ra] $ echo $SHELL
/bin/sh
Here we see that we have logged in as the user named "ra". Using the echo command we can see that the SHELL variable is set to /bin/sh. This tells us that we are currently using the Bourne shell. Now, let's change it.
Step 2. Switch to the root account
[sol: ra] $ su -
password: **********
Sun Microsystems Inc. SunOS 5.8
ALL HAIL THE SUPERUSER!!!!!
[sol: root] #
Now, you are the superuser, or root, of sol. Notice how the command prompt has changed from the user prompt "$" to the root prompt "#".
Step 3 - Using the passwd -e command
Execute the command "passwd -e" to change the shell fro the user named ra.
[sol: root] # passwd -e ra
The current shell will be displayed and you will be prompted for the new shell.
Old shell:/bin/sh
New shell:/bin/csh
[sol: root] #
Now, the next time you log in as the user ra, you will be using the C-shell.
Randy: This is the end of the exercise? Thanks - Julie
Julie- Yes. - rrc
On the Job: By default, users can't use the "passwd -e" command to change their shells, only the root user can. A user can however use another shell by changing the SHELL variable. This can be done by editing their ".profile" file in their home directory or from the command-line.
S&S - Shells
How can I tell what
shell I'm using?
|
Use the command "echo
$SHELL" to see what your shell variable is set to.
|
---|---|
How can I find out more about my shell's capabilities | Use the man command. For example, "man csh" will give you a good overview of using the C-shell. |
Many people confuse a mount point such as /tmp or /export/home with a file system. A mount point is the location of a partition on the hard drive which has been segregated from other partitions. Since that partition must be mounted in order to be used, it must be given a mount point. For example, by default, Solaris 8 will create a separate space on the hard drive for user's home directories. This is so that a user would not be able to use up all of the available hard disk space by filling up their home directory. That space is located within the Solaris file system at "/export/home". Even though we express the location as being directly under the "/" root directory, it is not limited to the space of the root directory.
UNIX refers to a file by it's location. The "hosts" file is often referred to as "/etc/hosts". This is a necessary function of a command-line operating system. For example if you wanted to use the "cp" command to copy a file named "badda-bing.employee.list" to your home directory, you would have to tell the cp command exactly where the file is located and exactly where you want it to go.
For example,
[sol: root] # cp /export/home/silvio/badda-bing.employee.list /export/home/tony
Because of this, it often seems like UNIX SysAdmins are speaking another language.
On the Job: This is an actual conversation I had with a co-worker recently:
Me: Hey, find /1st_floor -name "Scott"
co-worker: cd /1st_floor/breakroom; ls | grep coffee
The kernel is loaded during the boot process and must be running in order for the system to operate. The kernel specific files can be found in the following directories:
/kernel - This directory contains all the common kernel components that are needed for booting the system.
/platform/<platform-name>/kernel - This directory contains the components which are needed for a specific type of platform. For example, on an Intel system, this directory would be, /platform/i86pc/kernel
/platform/<hardware-class-name>/kernel - This directory contains the kernel components specific to this hardware class.
/usr/kernel - This directory contains kernel components common to all platforms within a particular instruction set.
On the job - On occasion, you may have to reconfigure the parameters of a Solaris kernel in order to tweak it for optimal performance. The installation of a database application, for example. Make sure you have read the instructions carefully and tested the changes on a test system before you do it on a mission critical system! Without a bootable kernel, you don't have a bootable system, which could get you booted out the door.
shell
hardware
Exam Watch - The definition of a shell and an operating system are similar. Both are used to communicate instructions, but remember that a shell is a component of an operating system.
Sun Microsystems refers to Solaris 8 as an Operating Environment. So, what's the difference between an operating environment and an operating system? Consider the analogy that both are like a shelter in which we live. An operating system provides us with the bare essentials. It's like a tent which contains food, a sleeping bag and a T-1 connection to the Internet. Okay, if we're talking bare essentials, we could probably get by without the sleeping bag. In contrast, an operating environment would be a house with running water, electricity, home entertainment system, walk-in meat locker, hot-tub, and so on. An operating environment includes all of the bells and whistles which are included to make running the system easier and more fun. Solaris 8 is designed from the ground up as a server operating environment. You won't find games, cute sound effects or 3-D wallpapers here included with the installation. It does include some very handy administrative applications and features. These include:
Solaris Smart card - This allows a SysAdmin to add additional security by requiring users to be validated with a personal ID card.
PDA Synchronization - By using this feature, users can transfer contact, calendar and mail data between their Solaris 8 system and their PDA.
The Solaris Common Desktop Environment has been spiffed up to include better management tools and increased PC interoperability.
The X Server has been upgraded to allow for better mobility and ease-of-use, compatibility with EnergyStar, better power management and web-based access.
On the Job - Sun Microsystems recently announced they would be dropping the CDE and OpenWindows GUI's in favor of GNOME. There's also been talk of including KDE as well. While this might affect how users access their workstations, you shouldn't get bogged down trying to learn how to use one kind of GUI over another. You worth as a SysAdmin will be measured at the command-line, not among icons.
The man command, short for "manual", is the way we access information about the commands and configuration files on our system. It's not a difficult command to learn or use.
The syntax of the man command is:
man < command_name>
Let's look at how we use it to get information on another helpful command, the ls command:
Exercise 1.3 - Using the man command
Step 1 - Log on to the system
[luna: ra]$ telnet sol
Trying 192.168.1.10...
Connected to sol.
Escape character is '^]'.
SunOS 5.8
login:ra
password: **********
Last login: Tue Apr 8 11:44:12 from :0
Sun Microsystems Inc. SunOS 5.8
Welcome to Sol - Don't forget to log out when you're done. Call ext. 3649 if you have any questions.
[sol: ra] %
Step 2 - Use the man command to get information about the ls command
[sol: ra] % man ls
Reformatting page. Please Wait... done
User Commands ls(1)
NAME
ls - list contents of directory
SYNOPSIS
/usr/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file ... ]
/usr/xpg4/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file ... ]
DESCRIPTION
For each file that is a directory, ls lists the contents of
the directory; for each file that is an ordinary file, ls
repeats its name and any other information requested. The
output is sorted alphabetically by default. When no argument
is given, the current directory is listed. When several
arguments are given, the arguments are first sorted
appropriately, but file arguments appear before directories
and their contents.
--More--(10%)
The output of the man command is shown one screen at a time, the excerpt above shows the contents of the first screen. As you will see on your system, the man command shows you a brief description of the command, it's syntax and them more detailed information on it's use. The man command will also display the revision history of the command and in most cases the author.
Man pages are marked with either nroff tags or SGML (Standard Generalized Markup Language. Both of these methods are used to mark a document with tags to describe how to read the text. For now, let's just say they are similar to HTML being used to tell a web-browser how to display a web page. That's why when you start the man command, it says "Reformatting page. Please Wait... done" before displaying the page. The command is reading the documents tags in order to display it on your screen correctly. The man pages are usually kept in /usr/share/man. The man pages using SGML tags are found in /usr/share/man/sman* and the the man pages using nroff tags are kept in /usr/share/man/man*. The directories are searched in the order specified in the /usr/share/man/man.cf file.
The man command also includes some handy options you can use.
-k - The keyword switch
You use the -k switch to find information using a keyword search. The syntax for using this option is:
man -k <keyword>
For example, say you wanted to find information on viewing documents in the pdf format. You would type:
man -k PDF
Then, the man command would display all of the commands that dealt with PDF documents. Actually, it's going to display all of the commands which have "PDF" in their man pages.
-M - The path command
You would use this option if you wanted the man command to search for a command in a directory not specified in the /usr/share/man/man.cf file. The syntax for using this option is:
man -M <path_name>
For example, let's say you've loaded an application which has installed it's man pages into a directory not specified by the MANPATH variable or in the /usr/share/man/man.cf file., but into the directory /opt/app/man. To view information on a command from the man pages in that directory you would type:
man -M /opt/app/man <command_name>
This would force the man command to look only in the named path for the man page on that command.
-a - The "all" option.
Using the -a option will show you all of the man pages which match the name specified.
The syntax is
man -a <command_name>
The man pages will be searched in the order they are specified in the MANPATH variable or as specified in the /usr/share/man/man.cf file. For example, if you type:
man -a passwd
You will be able to scroll through first the man page for the passwd command, then the man page for the passwd file.
-f - Searching for files
This option will give you a brief summary of man pages which fit the name of the file you specify. The syntax is:
man -f <file_name>
For example, let's say you wanted to see what man pages exist for the passwd command. You would type,
man -f passwd
And you would see,
passwd passwd (1) - change login password and password attributes
passwd passwd (4) - password file
This tells you there is not only a passwd command but a man page on the passwd configuration file as well.
-s - The section search.
Now that we know there's more than one man page on passwd, how do we display the one we want? Commands sometimes have more than one version of a man page. These different versions are separated into sections. As we've seen, there are two versions of a man page for "passwd". By default, the man command displays the man page on the passwd command, not the man page on the /etc/passwd configuration file. The -s option allows us to specify a section of the available man pages for the specified command. For example,
man -s 4 passwd
This will display the man page which deals with the passwd file, not the command. We saw that the passwd file was in the (4) section of the manual when we used the -f option.
shell - The shell is the program used to communicate your commands, or the commands of an application or script to the kernel. There are 3 basic shells which are installed with Solaris 8: Bourne, Korn and C-shell.
file system - A file system is a collection of files and directories organized in a hierarchical structure.
kernel - A kernel is the master program which communicates the instructions of system applications to the system hardware. It also manages all devices, memory and processes.
operating system - The operating system is a set of programs which governs all operations and acts as a means for the user to communicate instructions to system resources.
Remember the available switches for the man command:
-k switch is for searching for keywords.
-M switch allows you specify a different path to a man page
-a switch allos you to view all of the available pages on a command
-f allows you to search and view brief summaries
-s allows you to view specified sections of available man pages for a command.
A. /etc/hosts
B. /usr/dt/bin/dtscreen -mode pyro
C. /sbin/sh
D. /usr/lib/nfs/lockd
The correct answer is D, /usr/lib/nfs/lockd. This is one of the daemons which is used to provide NFS service. Daemons are often recognized by having the letter "d" at the end.
Answer A is incorrect as this is the host file on the system, which you probably wouldn't see if you ran the ps -ef command. Answer B indicates that the screen saver is running on the system and it's that really cool fireworks one. Answer C indicates that the Bourne shell is running.
2. A new user logs into a system an sees a "$" at the command prompt. What shell is this user using?
A. The Money Shell
B. The C-shell
C The Korn shell
D. The Bourne shell
The correct answer is either C or D. While the user is new, the default system shell can be whatever the SysAdmin set it to be when the user account was created. Out of the box, the Bourne shell is the default system shell.
Answer B is incorrect since the C-shell uses the "%" at the user prompt. Answer A is incorrect since, as of right now, there is no UNIX shell called the Money Shell.
3. What features does the Korn shell have that the Bourne shell doesn't?
A. Command-line editing
B. Faster processing of shell script
C The ability to flood the coolant chamber with tachyon particles thereby avoiding a warp core breach.
D. spelling correction
The correct answer is A. The Korn shell allows you to use editing commands such as those in the VI editor to change commands from the command-line.
Answer B is incorrect since Korn is a variation of the Bourne shell
and has no effect on the speed of a scripts execution. Answer C is incorrect
since it is the dilithium matrix which regulates the flow of energy from
the warp core, through the plasma conduits to the coils in the warp nacelles
not the Korn shell or tachyon particles.
4. Where did the C-shell get it's name?
A. It's short for "Complete-shell"
B. It's short for "Complicated-shell"
C. It's syntax is based on the C programming language
D. It doesn't mean anything.
Answer C is correct. The wizards at Berkley wanted a shell which would work like programming in C, so they made one.
Answers B and A are incorrect. Also, the C-shell is neither complete or complicated. Answer D is also incorrect.
5. What is the correct way to for a user to change their shell of the choices below?
A. Using the "passwd -shell <username>" command
B. Using the "passwd -e <username>" command
C A user can't change their shell
D. By changing the SHELL variable
Answer D is correct. Answer A is incorrect since there is no "-shell
" option with the password command and a user won't have access to the
passwd command. Same for Answer B, while there is a "-e" option, only the
root user has access to the passwd command. Answer C is also incorrect.
6. What is the correct way to change a user's shell using the root account of the choices below?
A. Using the "passwd -shell" command
B. Using the "passwd -a" command
C A user can't change their shell
D. By changing the SHELL variable
Again, Answer D is correct. The root user has the ability to use the passwd command, but using "passwd -e <username>" is not one of the choices. Make sure you read each choice carefully on the actual tests before choosing an answer.
7. Which of the following is an example of a file's name?
A. /etc/default
B. /etc/hosts
C. hosts
D. /usr/man/man.cf
Answer B is the correct answer. It describes the complete pathname of a file, which is how UNIX names files. Answer A describes the location of a directory. Answer C could be a directory or a file name. Answer D could also be correct, if you moved or copied the man.cf file to this location, but the default location of the man.cf file is /usr.share/man/man.cf.
8. Which statement is true in regards to a kernel?
A. Once Solaris is installed, it's not required.
B. It's a good idea to delete it occasionally to make sure it doesn't get too big.
C. It is loaded during the booting of the system
D. It gets it's name since, like a military officer, it's in charge of everything.
Answer C is correct. Answers A and B are incorrect since the running of the kernel is what keeps the system running. Answer D is incorrect since the name "kernel" doesn't have anything to do with the military rank of "Colonel". Besides, everybody knows it's the Sergeants that really run things.
9. An operating system is best defined by which statement?
A. The complete package of files and applications which are included in the default installation of Solaris 8.
B. A collection of programs which manage all resources and provides the user with a means of communication with the system.
C Anything under 16, hit. Anything 16 or higher, stay.
D. A collection of files and directories.
The best answer is B. Answer A is describing an Operating Environment. Answer C is describing a system for winning at Blackjack. Answer D is describing the definition of a file system.
A. man login
B. man -a login
C man -k login
D. man -s login
The correct answer is Answer C. this will display the man pages which have the keyword "login" in their description. Answer A will display the man page for login. Answer B is incorrect since the -a option will display all pages on login. Answer d is incorrect since the -s option is used to display sections.
2. The man command can be used to display all the available man pages on a command? Which command will display all of the man pages on the name passwd?
A. man -all passwd
B. man | grep passwd
C man -a passwrd
D. man -a passwd
Answer D is correct. This command will display all of the man page manuals which cover the passwd command, one after another.
Answer A is incorrect since there is no "-all" option. Answer B is incorrect since this doesn't follow the man command syntax. Answer C is incorrect since "passwd" is misspelled.
3. The man command can be used to display specific sections of information of a man page? Given the following output of the command: man -f shutdown,
shutdown shutdown (1b) - close down the system at a given time
shutdown shutdown (1m) - shut down system, change system state
shutdown shutdown (3socket) - shut down part of a full-duplex connection
shutdown shutdown (3xnet) - shut down socket send and receive operations
Which command will display the section of a man page which relates to shutting down the system at a given time?
A. man -s 1b
B. man -s 1b shutdown
C. man shutdown
D. man shutdown -s 1b
Exercise 1.4 - Using the man command to find a command name.
Solaris has a way or three to do just about anything. But what if you are trying to do something and don't know what command to use? For example, how would you find out what command to use to display the name of the system you're logged into? Let's take a look at a way to use the man command to help you find the command you need.
Step 1. Use the man command to search for a keyword.
# man -k name
Did it show you the command you're looking for? Possibly, but it's 3 or 4 screens of commands. How can we narrow our search? We can't use more than one keyword. Let's try another keyword. Since we're trying to determine the host's name or hostname, let's try using that as a keyword.
Step 2 . Narrowing the search
# man -k hostname
Is that a more manageable list? It's considerably smaller than the first one.
check-hostname check-hostname (1m) - check if sendmail can determine the system's fully-qualified host name
ethers ethers (4) - Ethernet address to hostname database or domain
gethostname gethostname (3c) - get or set name of current host
gethostname gethostname (3xnet) - get name of current host
hostname hostname (1) - set or print name of current host system
sethostname gethostname (3c) - get or set name of current host
And, we can see that one of the choices is a command called "hostname". What were the odds? Now let's see how the hostname command works before we run it.
Step 3. Investigating a command
# man hostname
We can see from the output of the command that just by typing the command "hostname", we will see the name of the system displayed. It's a good thing we checked it out first, since the hostname command can also be used to change the hostname of the system.
This is an example of using the man command to help jog your memory
or to research your options among all the available commands on a system.
Naturally, it's not likely that you'd have root access to a system and
not know it's hostname or how to find it. This was just a simple exercise
to demonstrate the use of the keyword search capabilities of the man command.