SunOS provides a wealth of commands for doing a number of system tasks on the command line. This chapter describes how to set a password, how to list the processes running on your machine, how to kill unwanted processes, and how to display the amount of space being used on your disk.
For the sake of your system's security, SunOS requires the use of a password for your system. Changing your password several times a year helps to ensure that you are the only user with easy access to your account. If you believe someone has used your account without your permission, change your password immediately.
When choosing a password, keep the following in mind:
Choose a password that you can remember without writing it down. A password that you can't remember is worse than one that is too easily guessed.
Choose a password that is at least six characters long and contains at least one number.
Don't use your own name or initials or the name or initials of your spouse.
Don't use the names of pets or objects common to your interests.
Don't use all capital letters.
If you have more than one account, don't use the same password for every account.
Although you can use any character in your password, some characters, such as Ctrl-C, Ctrl-Z, Ctrl-U, Ctrl-S, Esc, Tab, and in some cases # and @ can be interpreted by the terminal as signals. These characters should be avoided. The terminal may interpret these as signals rather than text characters, and this would preclude you from properly typing in your password.
To change your personal password, type the passwd command:
$ passwd Changing password for hankw on worker Old password: New password: Retype new password: $ |
When the system prompts you for Old Password:, type your current password.
(If no password is currently assigned to your account, the system will skip the Old Password: prompt.) Note that the system does not echo (display) your password on the screen. This prevents other users from discovering your password.
When the system prompts you for New Password:, type the password you've decided on.
Again, the password you type does not echo on the screen.
At the final prompt, Retype new password:, type your new password a second time.
This is to verify that you typed exactly what you intended to type.
If you don't enter your password precisely the way you did at the previous prompt, the system refuses to change your password and responds with Sorry. If this happens repeatedly, contact your system administrator to get a new password.
Passwords containing fewer than six characters are not allowed. Also, a new password must differ from the old password by at least three characters.
If your system is using password aging (implemented with options to the passwd command), your password may have either a maximum, or a maximum and minimum lifespan. The lifespan of your password is set by your system administrator.
When the maturity date (or maximum age) of your password is reached, you are prompted to change your password. This occurs when you log in. The following is displayed:
Your password has expired. Choose a new one. |
The system then automatically runs the passwd program and prompts you for a new password.
If, for example, the minimum age of your password has been set for two weeks, and you try to change your password before that time has elapsed, the following is displayed:
Sorry, less than 2 weeks since the last change. |
To view aging information for your password, use the -doption to the passwd command:
$ passwd -d username 2-14-92 14 60 |
The display shows, in order, the date the current password was created, the minimum age, and the maximum age. (This information appears only if password aging has been implemented.)
For more information on passwd(1) and password aging, refer to the man Pages(1): User Commands.
After each command is interpreted by the system, an independent process, with a unique process identification number (PID), is created to perform the command. The system uses the PID to track the current status of each process.
Use the ps command to see what processes are currently running. In addition to showing the process identification number (listed under PID) for each process you own (created as a result of a command you typed), ps also shows you the terminal from which it was started (TTY), the cpu time it has used so far (TIME), and the command it is performing (COMMAND).
Adding the -l option to the ps command displays a variety of other information about the processes currently running, including the state of each process (listed under S). The codes used to show this are as follows:
O - Process is running on a processor.
Z - Zombie state: Process terminated and parent not waiting.
T - Traced: Process stopped by a signal because parent is tracing it.
X - SXBRK state: Process is waiting for more primary memory.
Note that while ps is running, things can change. Since the ps command gives you only a snapshot of what's going on, it's only true for a split second after you type the command. The information may not be completely accurate by the time you see it.
The ps(1) command has more options than those covered here. Refer to the man Pages(1): User Commands.
The kill command provides you with a direct way to stop command processes that you no longer want. This is particularly useful when you make a mistake typing a command that takes a long time to run.
To terminate a process:
The following example illustrates this procedure:
$ ps PID TTY TIME COMMAND 1291 co 0:12 -bin/csh (csh) 3250 p0 0:00 ps 1286 p1 0:05 -bin/csh (csh) 3248 p1 0:05 vi commands $ kill 1291 [1} Terminated -bin/csh/ (csh) $ |
Note that a faster way of determining the right PID is to pipe ps output through grep as follows:
$ ps | grep commandname |
where commandname is the name of the command process you want to stop.
If you need to forcibly terminate a process, you can use the -9 option to the ps command as follows:
$ kill -9 PID# |
where PID# is the process identification number of the process you want to stop.
Since space on the disk is a limited resource, it is a very good idea to keep track of the space currently in use.
df -kshows you the amount of space currently in use on each disk that is mounted (directly accessible) to your system. Just type:
$ df -k |
to see the capacity of each disk mounted on your system, the amount available, and the percentage of space already in use.
File systems at or above 90 percent of capacity should be cleared of unnecessary files. You can do this either by moving them to a disk or tape that is less full, using cp to copy them and rm to remove them, or you can simply remove them outright. Of course, you should only perform these kinds of "housekeeping" chores on files that you own.
You can use du to display the usage of a directory and all its subdirectories in 512-byte blocks; that is, units of 512 bytes or characters.
du shows you the disk usage in each subdirectory. To get a list of subdirectories in a filesystem, cd to the pathname associated with that filesystem, and run the following pipeline:
$ du | sort -r -n |
This pipeline, which uses the reverse and numeric options of the sort command, pinpoints large directories. Use ls -l to examine the size (in bytes) and modification times of files within each directory. Old files, or text files over 100 Kbytes, often warrant storage offline.