User:Spoonbender/Temp/Utilities.doc

passwd: Changing your Password
From the previous module, you have learned how to change your own password. You already know the password restrictions but in this module we will study more on the rules in changing password and some common error messages that will appear when we restrict the password rules.

The following are examples of error messages:


 * UX:passwd: ERROR: Passwords must differ by at least 3 positions
 * passwd(SYSTEM): The first 6 characters of the password must contain at least two alphabetic characters and at least one numeric or special character.
 * passwd(SYSTEM): Password too short – must be at least 6 characters.
 * BAD PASSWORD: it does not contain enough DIFFERENT characters
 * BAD PASSWORD: it is based on a dictionary word
 * BAD PASSWORD: is too similar to the old one.

We need to consider the rules in handling password to avoid the above error messages. These include the following:


 * Don’t use a password similar to the first one.
 * Don’t choose commonly used names of relatives, friends, etc. The system will display an error message that the password is based on a dictionary word.
 * Password must be a combination of alphabetic and numeric characters.
 * Change your password regularly.

who and w: Knowing the Users
To know the users currently log on to a system, the who command is used. But there are options appended to this command to have a more detailed list of users. Common options used for this command are –H and –u. –H is used to have a header in output and –u to have a more detailed list.

Example:

$ who –Hu

NAME LINE TIME IDLE PID COMMENTS

''lecy tty01 Oct 2 10:09. 35''

owen tty02 Oct 2 11:10 0:40 36

If who –Hu provides a more detailed list than who, w provides much detailed output of users activities and additional details of the system.

Example:

$ w

2:40pm up 1:37 2 users load average: 0.00, 0:00, 0:00

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

lecy tty01 1:24pm 6:00s 11:20s 11:01s vi hi

owen tty02 2:20pm 6:35 0.68s 0.27s cat hello

Based on the example above the process vi hi of the user lecy consumed 11 minutes and 1 second to finish the process and the total CPU time consumed by all processes at terminal tty01 is 11 minutes and 20 seconds. The PCPU and JCPU are often different because the multitasking nature of UNIX permits a user to run more than one job at the same time.

lock: Locking your Terminal
Sometimes you may wish to leave your terminal unattended because you have something important to do but you don’t want to log out because there is a process running in the background. To prevent other user from viewing your hidden files and use your account at the same time, there is a command you can use to lock your terminal. This command is a lock command. This will prompt you to type a password to secure your terminal.

Syntax:

lock  [- time]

Example:

$ lock

Password: **********

Re-enter password: **********

terminal locked by lecy 0 minutes ago

Without the use of any option the terminal will be locked by the system for about 30 minutes and the $ prompt will disappear. After 30 minutes, the system will log you out automatically. If you want to unlock your terminal you need to type the password you provide to lock the terminal.

 ********** 

$ _

The lock command can be used to lock the terminal for a certain period which can be set by the user but not to exceed 60 minutes. To do this you need to specify the minutes as follows:

$ lock –55

Password: **********

Re-enter password: **********

terminal locked by owen 0 minutes ago

Note: Only the system administrator can change the default minutes.

date: Displaying the System Date
You already know the basic use of the command date. You can display the current system date without using any options, but this command can also be used to view only the month in numbers or in name, date, year, hour, minute, or seconds.

The following are format specifiers:


 * d — the day of the month
 * y — the last two digit of the current year
 * H — the hour
 * M — the minute
 * S — the second
 * m — equivalent month in numbers
 * h — month in name

Examples:
$ date

Wed Oct 22 05:10:24 EDT 2002

$ date +%m

10

$ date +%h

Oct

$ date +”%h (%m)”

Oct (10)

$ date +%H

05

cal: The calendar
Thecal is the command you need to view the calendar of a specific month or even a complete year. To view the calendar for the month of October (of the current year), you need to provide three-character month abbreviation as an argument.

Syntax:

cal  [month] [year] 

Example:

$ cal oct

October 2002

SuMoTuWeThFr Sa

1 2 3 4 5 6 7

8 91011 12 13 14

15 161718 19 20 21

22 232425 26 27 28


 * 1) 30

The cal can print the entire year by typing the following:

$ cal 2002

The output of a complete year is too long. To view the output you will need to pipe the command above with more command. To do this, type the following command.

$ cal 2002|more

calendar: The Reminder
The system provides a reminder for every user in the system. This reminder is stored in a file name called calendar. If you type calendar, this will give the reminders on the current date and reminders for the next day.

Syntax:

calendar  [year] 

Example:

$ calendar

October 2, 2002 the target for this month is $5.7 million

The meeting is scheduled for October 3

If you want to view the all reminders present in calendar, type the following command:

$ cat calendar

October 2, 2002 the target for this month is $5.7 million

The meeting is scheduled for October 7

November 1 – All Saints Day

December 25 – Christmas

If calendar is used with no specified year, by default this will display the reminders for the current year. The calendar will not list the reminders with the format 25th October and mm-dd-yy.

bc: The UNIX Calculator
The UNIX system provides two types of calculator—the graphical calculator and the character-based calculator. For graphical, the xcalc command is used and bc for the character-based calculator. But in this course we shall concentrate solely on the character-based calculator.

Syntax:

bc

To use the character-based calculator, type the following and you are now ready to evaluate arithmetic operations.

Example:

$ bc

12 + 5

17

You can evaluate two expressions by separating these expressions with semicolon.

4*4 ; 2^2          ^ is used to indicate power

16

4

9/5                 bc performs a truncated division

1

To view the decimal places you need to define the scale.

scale = 2

1/2

0.50

We can use the bc calculator to evaluate the values of variable name, provided that the variable name is a single character from a to z in lower case.

x=2 ; b=3 ; c=4

p = 4 –3 –2

p = -3