UNIX Tutorial


2. Logging in, logging out

Commands covered in this section:   whoami, passwd, logout

Since UNIX supports multiple users at one time, you must identify yourself to the system before you can begin using it. This process is called logging in. When you connect to a computer running UNIX (often called a UNIX host), you are asked to provide two pieces of information in order to log in: your username (also called a login name), which is your identity on the system, and your password, which proves (or at least improves the likelihood) that you are indeed who you say you are. Throughout the tutorial, we will assume your username is "natasha" and you are logging into a UNIX host called "peabody.wossamotta-u.edu."

Exercise 2.1

Connect to a UNIX host on which you have an account. If you are connecting from a machine running Mac OS X or Linux, you'll need to launch the Terminal application and use the ssh command to connect as shown in the example below. (If you're running Windows, you'll need to download and install an SSH client such as PuTTY.) Of course, you'll need to substitute your actual username and the hostname of the computer you want to connect to in place of "natasha" and "peabody.wossamotta-u.edu," respectively.

$ ssh natasha@peabody.wossamotta-u.edu
natasha@peabody.wossamotta-u.edu's password: <your_password_here>

Last login: Fri Feb 14 08:21:43 from bullwinkle.wossamotta-u.edu
Fedora Linux 3.6.11-4.fc16.x86_64 #1 SMP Tue Jan 8 20:57:42 UTC 2013

Welcome to peabody.wossamotta-u.edu!  Report any problems by sending e-mail
to help@wossamotta-u.edu.

** NOTE: peabody will be down from 10:00 am to 11:00 am
**       on Saturday, February 22 for a hardware upgrade.

$

When you log in, the system will print several lines of information on the screen. After you've logged in a few times and the novelty has worn off, you may be tempted to ignore this and start using the system. Don't! There are a couple of important pieces of information displayed here. The first line you see after typing your password tells you when you last logged in. If you see something like:

Last login: Fri Feb 14 03:52:12 from evil.hackers-r-us.org

and you've never heard of a machine called "evil," you might begin to suspect that your account has been compromised... The next several lines are from a file called motd (message of the day). This is where the system administrator places important announcements about the system. After this, you will see the shell prompt ("$" in our example). You are now ready to begin issuing commands to the UNIX system!

In order to ease ourselves into this business, let's begin with a very simple command, whoami. This command requires no options or arguments, and has the highly desirable side effect of reassuring the user by confirming his or her identity.

Exercise 2.2

Enter the whoami command at the shell prompt and see what happens.

$ whoami
natasha

That's it — all this command does is print the login name of the current user. Congratulations, you've just had your first taste of the power of UNIX!

Now before you get carried away with all that power, let's talk a bit more about passwords. Remember that UNIX uses your password to verify that it's you who is entering the system under your login name and not someone else. Therefore, only you should know your password. In order to be effective, the password must be extremely difficult for someone else to guess. Here are some simple guidelines:

Don't:

Do:

The easiest way to make up a password that follows these guidelines is to take the first letter of each word in a phrase that is easily remembered. Choose a phrase that allows you to use a number or punctuation mark. Table 2.1 shows some examples (no, you can't use these; make up your own!).

Table 2.1
Phrase Password
Four out of five dentists recommend Trident! 4oo5drT!
In every point twice done and then done double Ie.2datdd
The Adventure of the Three Garridebs and the Sign of the Four TAot3G&tSot4

Once an account is broken into, it can be used to stage further attacks on the same host or other hosts on the Internet. As a trusted member of a community of UNIX users, you have a civic duty to select a good password — anything less would be uncivilized! In fact, right now may be a good time to start. You can use the passwd command to change your password.

Exercise 2.3

Note: This exercrise is optional. If your current password meets the criteria listed above, you may wish to skip to the next exercise.

Enter the passwd command at the shell prompt. You will be prompted to enter your old password (to confirm that it's really you), and then your new password (twice, to ensure that you didn't make a typing error). In all cases, passwords are not displayed on the screen as you type them. Depending on which version of UNIX you are using, the wording in the prompts may vary slightly from that shown here.

$ passwd
passwd:  Changing password for natasha
Enter login password: your-old-password
New password: your-new-password
Re-enter new password: your-new-password

Once you've completed your work, you can end your UNIX session by logging out. This is accomplished via the logout command.

Exercise 2.4

Enter the logout command at the shell prompt.

$ logout
Connection closed by foreign host. 

Of course, you'll have to log back in to continue with the tutorial. Now that you know how to log in and log out, you have the option to stop working on the tutorial at any point and later resume where you left off. In the next section of the tutorial, we will begin to explore the UNIX environment in more detail.


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.