Linux : lesson1-1 : The basics of logging-in October 29, 2010Posted by Tournas Dimitrios in Linux course.
The Unix operating system, which was originally developed in the early 1970s, predates the days of personal computers.Originally, many users would imultaneously use Unix running on a mainframe computer. Rather than each user having a personal computer, they would use what is (these days) commonly called a “dumb terminal” – really just a keyboard and text monitor, connected to the mainframe computer with a serial line connection. In order to identify oneself to the Unix operating system, a user would first have to “log on” by providing a userid and password.
Although Linux (and other versions of Unix) has grown to take advantage of affordable personal computers, it has not lost the core concepts of users, passwords, logging on, and text based terminals. This lesson will describe various ways to start an interactive session with a Linux system.
Linux provides six “virtual consoles” that are available to users physically at the computer. The virtual consoles act like “dumb terminals”. The virtual consoles are accessed using the CTRL–ALT–F1 through CTRL–ALT–F6 key sequences, with one virtual console mapped to each of the first 6 function keys. (If you are in a graphical environment, you should know that CTRL–ALT–F7 will return you to it before trying to switch to a virtual console.)
When starting a session on a Linux machine using a virtual console, the screen will look something like the following:
Red Hat Enterprise Linux ES release 4 (Nahant) Kernel 2.6.9-5.EL on an i686 station login:
To login, a user types their username, with no spaces, and hits the RETURN key. Next, the user is prompted for their password, which is not echoed to the screen as the user types it, again followed by RETURN. Once successfully logged in, the user is greeted with a shell prompt.
Red Hat Enterprise Linux ES release 4 (Nahant) Kernel 2.6.9-5.EL on an i686 station login: elvis Password: [elvis@station elvis]$
The rest of this course is about what can be done from the shell prompt. For now, we are simply going to learn how to end a session, by typing “exit“, and hitting RETURN. The virtual console should return to the original login screen.
Why would users want to use a virtual console instead of the graphical environment? First, the machine might not have enough memory or hardware to support the graphical environment, and the virtual consoles might be all that are available. Even on modern machines, however, the virtual consoles are often a much quicker and more efficient interface for experienced users. Because they are implemented by the Linux kernel directly, they are also useful in debugging systems where the graphics might not be working. Lastly, for network servers that usually spend their lives in locked closets, administrators often want to avoid the complexity that the graphical interface adds to the system.
When running on modern personal computers, Linux uses a low level program known as the “X server” to provide the graphics environment. As a user of the system, you don’t interact with the X server directly, but it provides the canvas for all of the graphical programs that you run.
When the X server starts, usually as part of the system’s startup sequence, it looks for the “first available” virtual console. Because there are generally 6 virtual consoles used for text terminals, the X server usually grabs the 7th. If you are on a virtual console, and think that an X server is running on the machine, you can usually switch to it using the CTRL–ALT–F7 key sequence.
If a system is configured to boot to the graphical environment, a user will be presented with the Login Manager, which looks like the following.
Again, a user logs on by typing their username, followed by RETURN, and their password, again followed by RETURN.
The Applications menu in the graphical environment is found in the upper left-hand corner and serves as your gateway to a wide variety of graphical applications, including web browsers, text editors, image editors, games, and much more. While you are encouraged to explore these applications, we begin this course by focusing on the fundamentals of operating within the Linux environment, such as managing files and processes. For now, the most important application in the graphical environment for you is the terminal.
In Linux, the most commonly used terminal application is called gnome-terminal. A new gnome-terminal window can be opened by right-clicking on the desktop background, and choosing the top menu item in the pop-up menu, “Open Terminal”.Experienced Linux users often prefer the versatility and power of the command line interface over graphical applications. Akin to a virtual console, the terminal provides a shell command line interface. Because the user has already logged in to start the graphical session, he does not need to login again when opening new terminal.
When finished, the gnome-terminal can be closed by typing the exit command (followed by RETURN), or left clicking in the “go away box” found in the upper right-hand corner of the terminal.
When a user is finished with the graphical environment, they can logout selecting the last item from the Actions menu, found just to the right of the Applications menu. This will close all open windows, and return the graphics environment back to its original login screen, ready for the next user.
Users can use the who command to determine who is on the system, and how they logged on. From any terminal, users can type who and hit the RETURN key. They should see output similar to the following.
[elvis@station elvis]$ who elvis tty2 May 5 15:07 root tty1 May 3 07:50 blondie :0 May 5 08:48 blondie pts/0 May 5 09:03 (:0.0)
The first column lists the users who have logged on, and the last few columns the time that they logged on. With a little experience, the second column tells where the user logged on. For the first two users, elvis, and root, tty1 and tty2 refers to virtual consoles number 1 and 2, respectively. The first entry for blondie, :0, refers to the X server itself, and pts/0 refers to the first terminal opened within the X server. Without getting too bogged down in the details, we can see that elvis is logged on the second virtual console, root on the first, and blondie has logged in using the graphical environment.
Using the ssh (“secure shell”) utility, users can easily log in to remote machines, either in the same room, or halfway across the world. Assuming the remote machine is configured to allow remote logins, and the user has an account on the machine, logging in to a remote machine can be as easy as logging in on a virtual console. In the following example, elvis will login to a virtual console on the local machine, called station.redhat.com. He will then use ssh to login to the remote machine nimbus.example.com, potentially halfway around the world.
Pay careful attention to the shell prompt in the following example. Because Linux users are often “hopping” from machine to machine using remote shells, the prompt has been designed to help the user keep straight what machine the shell is running on.
Red Hat Enterprise Linux ES release 4 (Nahant) (Taroon) Kernel 2.4.21-4.0.1-EL on an i686 station login: elvis Password: Last login: Thu Apr 3 13:03:06 from hedwig [elvis@station elvis]$ who elvis tty2 May 3 07:48 [elvis@station elvis]$ ssh firstname.lastname@example.org email@example.com's password: Last login: Thu May 1 17:38:43 2003 from station.redhat.com [elvis@nimbus elvis]$ who elvis pts/1 May 3 11:59 (station.redhat.com) [elvis@nimbus elvis]$ exit Connection to nimbus.example.com closed. [elvis@station elvis]$ exit
Note that when elvis ran the who command on the remote machine, it reported the machine that he logged in from, namely station.redhat.com.
There are ssh clients for operating systems other than Linux. For example, the Open Source PuTTY application can be installed on almost any windows machine, and used to open a shell into a remote Linux server.