Beginning Your Session

Before you can start interacting with the UNIX command shell of your choice, you'll need to learn how to log in to your account. The good news is that it's easy! Let's have a look.

Task 2.1: Logging In and Out of the System

Because UNIX is a multiuser system, you need to start by finding a terminal, a computer, or some other way to access the system. I use a Macintosh and a modem to dial up various systems by telephone. You might have a similar approach, or you might have a terminal directly connected to the UNIX computer on your desk or in your office, or you might have the UNIX system itself on your desk. Regardless of how you connect to your UNIX system, the first thing you'll see on the screen will look something like this:


4.3BSD DYNIX (mentor.utech.edu) 5:38pm on Fri, 7 Feb 1997
login:

No matter how you access UNIX, you will need to go through the login process. The first line indicates what variant of UNIX the system is running (DYNIX is UNIX on Sequent computers), the actual name of the computer system, and the current time and date. The second line is asking for your login, your account name. If what you see varies from this, you'll still end up with the “login:” prompt where you need to type in your account name.

  1. Connect your terminal or PC to the UNIX system until the point where you see a login prompt (login:) on your screen similar to that in the preceding example, using the phone and modem to dial up the computer if you need to.

    It would be nice if computers could keep track of us users by simply using our full names so that I could enter Dave Taylor at the login prompt. Alas, like the Internal Revenue Service, the Department of Motor Vehicles, and many other agencies, UNIX—rather than using names—assigns each user a unique identifier. This identifier is called an account name, has eight characters or fewer, and is usually based on the first or last name, although it can be any combination of letters and numbers. I have two account names, or logins, on the systems I use: taylor and, on another machine where someone already had that account name, dataylor.

  2. You should know your account name on the UNIX system. Perhaps your account name is on a paper with your initial password, both assigned by the UNIX system administrator. If you do not have this information, you need to track it down before you can go further. Some accounts might not have an initial password; that means that you won't have to enter one the first time you log in to the system. In a few minutes, you will learn how you can give yourself the password of your choice by using a UNIX command called passwd.

  3. At the login prompt, enter your account name. Be particularly careful to use all lowercase letters unless specified otherwise by your administrator (for example, the accounts taylor, Taylor, and TAYLOR are all different to UNIX).

    login: taylor
    Password:
    

    Once you've entered your account name, the system moves the cursor to the next line and prompts you for your password. When you enter your password, the system won't echo it (that is, won't display it) on the screen. That's okay. Lack of an echo doesn't mean anything is broken; instead, this is a security measure to ensure that even if people are looking over your shoulder, they can't learn your secret password by watching your screen. Be certain to type your password correctly, because you won't see what you've typed to correct it.

  4. If you enter either your login or your password incorrectly, the system complains with an error message:

    login: taylor
    Password:
    Login incorrect
    login:
    

Most systems give you three or four attempts to get both your login and your password correct, so try again. Don't forget to enter your account name at the login prompt each time.


  1. Once you've successfully entered your account name and password, you are shown some information about the system, some news for users, and an indication of whether you have electronic mail. The specifics will vary, but here's an example of what I see when I log in to my account:

    login: taylor
    Password:
    Last login: Fri Feb 7 17:00:23 on ttyAe
    You have mail.
    %
    

    Your system might be configured so that you have some slightly different prompt here. The possibilities include a $ for the Korn or Bourne shells, your current location in the file system, the current time, the command-index number (which you'll learn about when you learn how to teach the UNIX command-line interpreter to adapt to your work style, rather than vice versa), and the name of the computer system itself. Here are some examples:

    [/users/taylor] :
    (mentor) 33 :
    taylor@mentor %
    

    Your prompt might not look exactly like any of these, but it has one unique characteristic: It is at the beginning of the line that your cursor sits, and it reappears each time you've completed working with any UNIX program.

The percent sign is UNIX's way of telling you that it's ready for you to enter some commands. The percent sign is the equivalent of an enlisted soldier saluting and saying, “Ready for duty!” or an employee saying, “What shall I do now, boss?”


  1. At this point, you're ready to enter your first UNIX command—exit—to sign off from the computer system. Try it. On my system, entering exit shuts down all my programs and hangs up the telephone connection. On other systems, it returns the login prompt. Many UNIX systems offer a pithy quote as you leave, too.

    % exit
    He who hesitates is lost.
    4.3BSD DYNIX (mentor.utech.edu) 5:38pm on Fri, 7 Feb 1993
    login:
    

You might be able to end your session by pressing Ctrl-D. Some shells will catch this and prompt you to determine whether you want to end your session; others will exit. The Ctrl-D character is actually an end-of-file character; it may be different on your system.


  1. If you have a direct connection to the computer, odds are very good that logging out causes the system to prompt for another account name, enabling the next person to use the system. If you dialed up the system with a modem, you probably will see something more like the following example. After being disconnected, you'll be able to shut down your computer.

    % exit
    Did you lose your keys again?
    
    DISCONNECTED
    

UNIX is case-sensitive, so the exit command is not the same as EXIT. If you enter a command all in uppercase, the system won't find it and instead will respond with the complaint command not found.


At this point, you've overcome the toughest part of UNIX. You have an account, know the password, logged in to the system, and entered a simple command telling the computer what you want to do, and the computer has done it!


Task 2.2: Changing Passwords with passwd

Having logged in to a UNIX system, you can clearly see that there are many differences between UNIX and a PC or Macintosh personal computer. Certainly the style of interaction is different. With UNIX command lines, the keyboard becomes the exclusive method of instructing the computer what to do, and the mouse sits idle, waiting for something to happen.


One of the greatest differences is that UNIX is a multiuser system, as you learned in the preceding hour. As you learn more about UNIX, you'll find that this characteristic has an impact on various tasks and commands. The next UNIX command you learn is one that exists because of the multiuser nature of UNIX: passwd.

With the passwd command, you can change the password associated with your individual account name. As with the personal identification number (PIN) for your automated-teller machine, the value of your password is directly related to how secret it remains.

UNIX is careful about the whole process of changing passwords. It requires you to enter your current password to prove you're really you. Imagine that you are at a computer center and have to leave the room to make a quick phone call. Without much effort, a prankster could lean over and quickly change your environment or even delete some critical files! That's why you should log out if you're not going to be near your system, and that's also why passwords are never echoed in UNIX.


  1. Consider what happens when I use the passwd command to change the password associated with my account:

    % passwd
    Changing password for taylor.
    Old password:
    New passwd:
    Retype new passwd:
    %
    
  2. Notice that I never received any visual confirmation that the password I actually entered was the same as the password I thought I entered. This is not as dangerous as it seems, though, because if I had made any typographical errors, the password I entered the second time (when the system said Retype new passwd:) wouldn't have matched the first. In a no-match situation, the system would have warned me that the information I supplied was inconsistent:

    % passwd
    Changing password for taylor.
    Old password:
    New passwd:
    Retype new passwd:
    Mismatch - password unchanged.
    %
    

Once you change the password, don't forget it. To reset it to a known value if you don't know the current password requires the assistance of a system administrator or other operator. Renumbering your password can be a catch-22, though: you don't want to write down the password because that reduces its secrecy, but you don't want to forget it, either. You want to be sure that you pick a good password, too, as described in Task 2.3.


Task 2.3: Picking a Secure Password

If you're an aficionado of old movies, you are familiar with the thrillers in which the hoods break into an office and spin the dial on the safe a few times, snigger a bit about how the boss shouldn't have chosen his daughter's birthday as the combination, and crank open the safe. (If you're really familiar with the genre, you recall films in which the criminals rifle the desk drawers and find the combination of the safe taped to the underside of a drawer as a fail-safe—or a failed safe, as the case may be.) The moral is that you always should choose good secret passwords or combinations and keep them secure.


For computers, security is tougher because, in less than an hour, a fast computer system can test all the words in an English dictionary against your account password. If your password is kitten or, worse yet, your account name, any semi-competent bad guy could be in your account and messing with your files in no time.

Many of the more modern UNIX systems have some heuristics, or smarts, built in to the passwd command; the heuristics check to determine whether what you've entered is reasonably secure.

The tests performed typically answer these questions:

  • Is the proposed password at least six characters long? (A longer password is more secure.)

  • Does it have both digits and letters? (A mix of both is better.)

  • Does it mix upper- and lowercase letters? (A mix is better.)

  • Is it in the online dictionary? (You should avoid common words.)

  • Is it a name or word associated with the account? (Dave would be a bad password for my account taylor because my full name on the system is Dave Taylor).

Some versions of the passwd program are more sophisticated, and some less, but generally these questions offer a good guideline for picking a secure password.

  1. An easy way to chose memorable and secure passwords is to think of them as small sentences rather than as a single word with some characters surrounding it. If you're a fan of Alexander Dumas and The Three Musketeers, then “All for one and one for all!” is a familiar cry, but it's also the basis for a couple of great passwords. Easily remembered derivations might be all4one or one4all.

  2. If you've been in the service, you might have the U.S. Army jingle stuck in your head: “Be All You Can Be” would make a great password, ballucanb. You might have a self-referential password: account4me or MySekrit would work. If you're ex-Vice President Dan Quayle, 1Potatoe could be a memorable choice (potatoe by itself wouldn't be particularly secure because it lacks digits and lacks uppercase letters, and because it's a simple variation on a word in the online dictionary).

  3. Another way to choose passwords is to find acronyms that have special meaning to you. Don't choose simple ones—remember, short ones aren't going to be secure. But, if you have always heard that “Real programmers don't each quiche!” then Rpdeq! could be a complex password that you'll easily remember.

  4. Many systems you use every day require numeric passwords to verify your identity, including the automated-teller machine (with its PIN), government agencies (with the Social Security number), and the Department of Motor Vehicles (your driver's license number or vehicle license). Each of these actually is a poor UNIX password: It's too easy for someone to find out your license number or Social Security number.

The important thing is that you come up with a strategy of your own for choosing a password that is both memorable and secure. Then, keep the password in your head rather than write it down.


Why be so paranoid? For a small UNIX system that will sit on your desk in your office and won't have any other users, a high level of concern for security is, to be honest, unnecessary. As with driving a car, though, it's never too early to learn good habits. Any system that has dial-up access or direct-computer-network access—you might need to use such a system—is a likely target for delinquents who relish the intellectual challenge of breaking into an account and altering and destroying files and programs purely for amusement.


The best way to avoid trouble is to develop good security habits now when you're first learning about UNIX—learn how to recognize what makes a good, secure password; pick one for your account; and keep it a secret.

If you ever need to let someone else use your account for a short time, remember that you can use the passwd command to change your secure password to something less secure. Then, you can let that person use the account, and, when he or she is done, you can change the password back to your original password.

With that in mind, log in again to your UNIX system now, and try changing your password. First, change it to easy and see whether the program warns you that easy is too short or otherwise a poor choice. Then, try entering two different secret passwords to see whether the program notices the difference. Finally, pick a good password, using the preceding guidelines and suggestions, and change your account password to be more secure.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset