Originally Published: Tuesday, 12 June 2001 Author: Michael Stutz
Published to: learn_articles_firststep/General Page: 2/5 - [Printable]

The Linux Cookbook: Chapter 2, WHAT EVERY LINUX USER KNOWS

Today's Learn article derived from Chapter Two of the soon to be published Linux Cookbook contains a ton of useful information for the new user. Learn all kinds of useful commands and short-cuts for basic system operation, and then join author Michael Stutz as he answers your questions live in Linux.com Live! Linux.com would like to thank publisher Bill Polluck of No Starch Press for the free use of this material.

Logging Into the System  << Page 2 of 5  >>


To begin a session on a Linux system, you need to log in. Do this by entering your username at the login: prompt on your terminal, and then entering your password when asked.

The login: prompt appears on the terminal after the system boots. If your system is configured to start the X Window System at boot time, you'll be presented with an X login screen instead of the standard login prompt. If that happens, press "Ctrl"-"Alt"-"F1" to switch to the text login screen; this is explained further in Recipe 2.3 Console Basics, page 20.

A typical login: promt looks like this:

Debian GNU/Linux 2.2 bardo ttyl
bardo login:

Every Linux system has its own name, called the system's hostname; a Linux system is sometimes called a host, and it identifies itself with its hostname at the login: prompt. It's important to name your system--like a username for a user account, a hostname gives name to the system you are using (and it becomes especially important when putting the system on a network). The system administrator usually names the system when it is being initially configured (the hostname can always be changed later; its name is kept in the file /etc/hostname). Like usernames, hostnames are one word in all lowercase letters. People usually give their system a name they like, such as darkstar or shiva.

In this example, 'bardo' is the hostname of this particular Linux system.

The name of the terminal is 'ttyl', which means that this is the first terminal on this particular system. (Incidentally, 'tty' is short for "teletype," which historically was the kind of terminal hardware that most Unix-based systems used by default.)

To log in to the system, type your username (followed by "Ret") at the login: prompt, and then type your password when asked (also followed by "Ret"); for security purposes, your password is not displayed on the screen when you type it.

Debian GNU/Linux 2.2 bardo ttyl
bardo login: kurt "Ret"
Password: empathy "Ret"
Linux bardo 2.0.30 #1 Tue Jul 29 10:01:26 EDT 1997 i586 unknown

Copyright (C) 1993-1998 Software in the Public Interest, and others
Most of the programs included with the Debian Linux system are freely redistributable; the exact distribution terms for each program are described in the individual files in /usr/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
Last login: Tue Apr 5 12:03:47 on ttyl.
No Mail.
~ $

Once you've entered your username and password, you are "logged in" to the system. You can then use the system and run commands.

As soon as you log in, the system displays the contents of /etc/motd, the "Message of the Day" file. The system then displays the time and date of your last login, and reports whether or not you have electronic mail waiting for you (see Chapter 30 Email, page 315). Finally, the system puts you in a shell--the environment in which you interact with the system and give it commands. Use of the default shell on most Linux systems, bash, is discussed in Chapter 3 The Shell, page 35.

The dollar sign ('$') displayed to the left of the cursor is called the shell prompt; it means that the system is ready and waiting for input. (You can change this prompt to any text of your liking; to learn how, see Recipe 3.6.1 Changing the Shell Prompt, page 46.) By default, the shell prompt includes the name of the current directory, which it places to the left of the '$' character. The tilde charater ('~'), is a shell symbol that denotes the user's home directory--when you log in, you are in your home directory (these terms are defined in Chapter 5 [Files and Directories], page 65).


To end your session on the system, type logout at the shell prompt. This command logs you out of the system, and a new login: prompt appears on your terminal.

  • To log out of the system, type:
$ logout "Ret"

Debian GNU/Linux 2.2 bardo ttyl

bardo login:
What works equally well to typing the logout command is to just type C-d (hold down "Ctrl" and type a d). You don't even have to type "Ret" afterwards. Many users prefer this quick shortcut.

Logging out of the system frees the terminal you were using--and ensures that nobody can access your account from this terminal.

If you are the only person using your system and have just ended a session by logging out, you might want to power down the system. See Recipe 2.1.2 Shutting Down the System, page 17, earlier in this chapter.

Logging Into the System  << Page 2 of 5  >>