Logging On
When a terminal linked to a Linux system is switched on, a login prompt should appear on the screen.
If the login prompt does not appear
- Press the Return key once
The prompt that appears depends on the version of Linux and the system setup. However, it will contain the following prompt as part of the display and the cursor will remain at the prompt, waiting for user entry:
login:
- The user must then type in the correct user identification name, followed by pressing the Return key
If the user has a security password associated with the username, the password will now be prompted for:
password:
- The user must then type in the password correctly, followed by pressing the Return key. The password will not be written to the screen, for security reasons.
If the password is entered correctly - or if there is no password for that user - the following will then appear:
Last successful login for user1: Tue May 14 10:56:40 BST 1991 on tty01
Last unsuccessful login for user1: NEVER
.
.
.
$
The $ is the prompt that will appear for ordinary users to show that the system is now awaiting commands. For the super-user (root) the prompt will be the # (or pound Sterling sign, depending on the terminal's setup). These prompts may be altered to suit the user.
Notes
1. If the username is entered incorrectly, you will be prompted for the password. Press the Return key - once - and wait for the login prompt to appear again.
2. Although most systems allow you to type ahead, do not do so for the password. Those characters entered before the password prompt appears will be written to the screen and will not be recorded as part of the password.
The Login Process
The process of logging on to a Linux system is a complex affair. The operating system stores a list of what terminals are attached. Once the system is running, it constantly monitors each terminal to see if it is switched on and if there is any response to it. Once it senses such a response, it starts the login procedure described in the section on Logging On. This is achieved by running a program called login on the terminal.
Once the program receives the user's identification name (the username), it looks through a file called /etc/passwd to find the name. Each line in /etc/passwd has the following syntax:
username:password:userid:groupid:comments:home directory:shell
For example, for user jon:
jon:*:201:50:Login for Jon Harvey:/home/jon:/usr/bin/ksh
The asterisk in the second field informs the system that there is a password. The password is held in a hidden (shadow) file, for security reasons. On older systems, if there is a password, the second field will contain a 13-character string that is an encryption of the password.
201 is the user's identification number. It is used to find out what files are owned by the user.
50 is the user's group identification number. It refers to a file called /etc/group to find the group's name.
The fifth field is just a comment field. Anything may be placed in it.
/home/jon identifies the name of the user's Home directory and will move to that directory when the login process is completed.
/usr/bin/ksh informs the login process what type of shell the user will be given, once the process is completed - in this instance, it is a Korn shell.
If the user enters the username and password (if there is one) correctly, the process then runs a series of commands stored in a file called /etc/profile. This is a Shell Script. The profile commands set up a number of parameters for all users on the system. This may include things such as the timezone, terminal type, the search-path for commands, default access permissions, etc. These form part of the user's environment - that is, the user's setup and abilities on the system.
The system then moves to the user's Home directory and searches for a file called .profile. It is very much like /etc/profile, except that it contains information for this specific user's environment. It may contain extra search-paths and a customised command-line prompt, for example. If the .profile exists, its commands are run, before the $ prompt is displayed.
Exiting from the System
To log off from a Linux system
At a $ prompt, either:
- Type the command exit and then press the Return key
OR
- Hold down the Ctrl key and press D
If successful, a login prompt will be displayed on the screen. You may then switch off the terminal.
Note: It is good practise to log off the system before leaving the terminal unattended. This is not only for security reasons, but also for the safety of any files that may have been in use.
Warning: Never switch off a terminal before logging off.