|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Tuesday, 12 June 2001||Author: Michael Stutz|
|Published to: learn_articles_firststep/General||Page: 3/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.
|Console Basics||<< Page 3 of 5 >>|
2.3 CONSOLE BASICS
A Linux terminal is a place to put input and get output from the system, and usually has at least a keyboard and monitor.
When you access a Linux system by the keyboard and monitor that are directly connected to it, you are said to be using the console terminal. (Linux systems can be accessed in other ways, such as through a network or via another terminal connected to a serial line; see Chapter 29 Communications, page 307.
Linux systems feature virtual consoles, which act as separate console displays that can run separate login session, but are accessed from the same physical console terminal. Linux systems are configured to have seven virtual consoles by default. When you are at the console terminal, you can switch between virtual consoles at any time, and you can log in and use the system from several virtual consoles at once.
The following recipes explain the basic things you will need to do with virtual consoles.
2.3.1 SWITCHING BETWEEN CONSOLES
To switch to a different virutal console, press "Alt"-"Fn", where n is the number of the console to switch to.
This command switches to the fourth virtual console, denoted by 'tty4':
You can also cycle through the different virtual consoles with the left and right arrow keys. To switch to the next-lowest virtual console (or wrap around to the highest virtual console, if you're at the first virtual console), press "Alt"-"<-". To switch to the next-highest virtual console, press "Alt"-"->".
This keystroke switches to the third virtual console, 'tty3':
The seventh virtual console is reserved for the X Window System. If X is installed, this virtual terminal will never show a login: prompt, but when you are using X, this is where your X session appears. If your system is configured to start X immediately, this virtual console will show an X login screen.
You can switch to a virtual console from the X Window System using "Ctrl" in conjunction with the usual "Alt" and function keys. This is the only console manipulation keystroke that works in X.
2.3.2 SCROLLING THE CONSOLE TEXT
When you are logged in at a virtual console, new lines of text appear at the bottom of the console screen, while older lines of text scroll off the top of the screen.
The amount of text you can scroll back through depends on system memory.
NOTE: This technique is for scrolling through text displayed in your shell session (see Chapter 3 The Shell, page 35). It does not work for scrolling through text in a tool or application in the console--in other words, you can't use this technique to scroll through text that is displayed by a tool for perusing text files. To scroll through text in an application, use its own facilities for scrolling, if it has any.
2.3.3 KEYS FOR CONSOLE MANIPULATION
Some Keystrokes for manipulation the console display, including those for switching between virtual consoles, are described below. It's a good idea to experiment with these commands until you are comfortable with them, because knowing how to use virtual consoles is basic to using Linux.
2.4 RUNNING A COMMAND
A tool is a software program that performs a certain function-- usually a specialized, simple task. For example, the hostname tool outputs the system's hostname, and the who tool outputs a listing of the users who are currently logged in. An application is the name given to larger, usually interactive, programs for completing broader kinds of tasks--such as programs for image editing or for word processing.
A tool or application may take any number of options (sometimes called "flags"), which specify a change in its default behavior. It may also take arguments, which specify a file or some other text to operate on. Arguments are usually specified after any options.
A command is the name of a tool or application along with the options and arguments you want to use, if any. Since typing the name of a tool itself is often sufficient to accomplish a desired task, tools alone are often called commands.
Commands are case sensitive; the names of tools and applications are usually in all lowercase letters.
To run (or "execute") a tool or application without giving any options or arguments, type its name at a shell prompt follwed by "Ret".
The hostname of the system in the example is 'bardo'.
Options always begin with a hyphen character, '-', which is usually followed by one alphanumeric character. To include an option in a command, follow the name of the tool or application with the option. Always separate the tool name, each option, and each argument with a space character.
Long-style options (sometimes called "GNU-style" options) begin with the hyphen characters ('--') and are usually one English word.
For example, many tools have an option, '--version', to output the version number of the tool. (Many tools also have a '--help' option, which outputs a list of options the tool takes; see Recipe 2.8.3 Listing the Usage of a Tool, page 29.)
This command outputs the text 'hostname 2.10', indicating that this is version 2.10 of the hostname tool.
Sometimes, an option itself may take an argument. For example, hostname has an option for specifying a file name to use to read the hostname from, '-F'; it takes as an argument the name of the file that hostname should read from.
2.5 CHANGING YOUR PASSWORD
To change your password, use the passwd tool. It prompts you for your current password and a new password to replace it with. For security purposes, neither the old nor the new password is echoed to the screen as you type it. To make sure that you type the new password correctly, passwd prompts you for your new password twice. You must type it exactly the same way both times, or passwd will not change your password.
NOTE: Passwords can contain uppercase and lowercase letters, the digits 0 through 9, and punctuation marks; they should be between fie and eight characters long. See Recipe 2.2 Accounts and Privileges, page 18, for suggestions on choosing a good password.
2.6 LISTING YOUR ACTIVITY
The recipes in this section describe some of the simple commands for finding out who you are currently sharing the system with and what they are doing.
2.6.1 LISTING YOUR USERNAME
Use whoami to output the username of the user that is logged in at your terminal. This is not as futile a command as one might first think--if you're at a shared terminal, it's useful to determine whether or not it is your account that you're messing in, and for those with multiple accounts on a system, it's useful to see which of them you're currently logged in with.
In this example, the username of the user logged in at this terminal is 'kurt'.
2.6.2 LISTING WHO IS ON THE SYSTEM
Use who to output a list of all the users currently logged in to the system. It outputs a minimum of three columns, listing the username, terminal location, and time of login for all users on the system. A fourth column is displayed if a user is using the X Window System; it lists the window location of the user's session (see Chapter 4 The X Window system, page 51).
To see who is currently logged in, type:
The output in this example shows that the user murky is logged in on tty1 (the first virtual console on the system), and has been on since 20:09 on 20 October. The user dave is logged in on tty2 (the second virtual console), and has been on since 14:37 on 21 October . The user kurt is logged in twice--on tty3 (the third virtual console), and ttyp1, which is an X session with a window location of '(:0.0)'.
NOTE: This command is for listing the users on the local system; to list the users connected to a different system on the network, or to see more detailed information that a user may have made public about himself, see Recipe 32.4.2 Checking Whether a User is Online, page 351.
2.6.3 LISTING WHO IS ON AND WHAT THEY'RE DOING
The w tool is similar to who, but it displays more detail. It outputs a header line that contains information about the current system status, including the current time, the amount of time the system has been up and running, and the number of users on the system. It then outputs a list of users currently logged in to the system, giving either columns of information for each. These columns include username, terminal location, X session (if any), the time of login, the amount of time the user has been idle, and what command the user is running. (it also gives two columns showing the amount of time the system's CPU has spent on all of the user's current jobs ("JCPU") and foreground process ("PCPU"); processes are discussed in Recipe 2.7 Listing System Activity, page 26, and jobs in Recipe 3.3 Managing Jobs, page 40).
In this example, the command's output shows that the current system time is 5:27 p.m., the system has bee up for 17 hours and 53 minutes, and there are four users currently logged in: murky is logged in at tty1, has been idle for 17 hours and 22 minutes, and is at a bash shell prompt; dave is logged in at tty2, has been idle for 13 seconds, and is using less to peruse a file called 'foo' (see Recipe 9.1 Perusing Text, page 111); and kurt is logged in at two terminals--tty3 and ttyp1, which is an X session. He ran the startx command on tty3 to start his X session, and within his X session, he is currently using Emacs.
2.6.4 LISTING THE LAST TIMES A USER LOGGED IN
Use last to find out who has recently used the system, which terminals they used, and when they logged in and out.
To find out when a particular user last logged in to the system, give his username as an argument.
NOTE: The last tool gets its data from the
|Console Basics||<< Page 3 of 5 >>|