This page is provided as a convenient way to download. It should also be helpful for people on dial-up to have one big page to read. A list of the other “AllOfs” can be found at http://linuxbasics.org/course/book/allallofs.
Please take into considerations that once you save this page, it cannot keep up with the dynamics of the wiki. If you find something to be corrected or improved, you need to check or edit the actual current wiki-page.
The current version of this document can be found at http://linuxbasics.org/course/book/index.
This book is licensed and may be distributed under the terms of the GNU Free Documentation License. A copy of the license can be found at http://linuxbasics.org/course/book/allof_appendix
Usually, these snapshots are updated daily between 05:00 and 05:15 UTC
This snapshot was created: Sun Jul 20 06:08:07 CEST 2008
In order to get the most out of this guide, we will immediately start with a practical chapter on connecting to the Linux system and doing some basic things.
We will discuss:
Prev: Exercises
Home
Next: Logging in, activating the user interface and logging out
In order to work on a Linux system directly, you will need to provide a user name and password. You always need to authenticate to the system. As we already mentioned in the exercise from Chapter 1, most PC-based Linux systems have two basic modes for a system to run in: either quick and sober in text console mode, which looks like DOS with mouse, multitasking and multi-user features, or in graphical mode, which looks better but eats more system resources. But modern computers should be able to handle a GUI easily.
This is the default nowadays on most desktop computers. You know you will connect to the system using graphical mode when you are first asked for your user name, and then, in a new window, to type your password.
To log in, make sure the mouse pointer is in the login window, provide your user name and password to the system and click OK or press Enter.
The time it takes for your system to come up after you have entered your user name and password will depend on the speed of your processor, the window manager and personal settings.
To continue, you will need to open a terminal window or xterm for short (X being the name for the underlying software supporting the graphical environment). This program can be found in the Applications→Utilities, System Tools or Internet menu, depending on what window manager you are using. There might be icons that you can use as a shortcut to get an xterm window as well, and clicking the right mouse button on the desktop background will usually present you with a menu containing a terminal window application.
While browsing the menus, you will notice that a lot of things can be done without entering commands via the keyboard. For most users, the good old point-’n’-click method of dealing with the computer will do. But we want to learn the basics of Linux, and be able to meddle with the heart of the system. That is why we need a stronger tool than a mouse to handle all the tasks we will face. This tool is the shell, and when in graphical mode, we activate our shell by opening a terminal window.
The terminal window is your control panel for the system. Almost everything that follows is done using this simple but powerful text tool. A terminal window should always show a command prompt when you open one. This terminal shows a standard prompt, which displays the user’s login name, and the current working directory. In this case, it is the user’s home directory which is represented in most of the distributions by the twiddle or tilde (~):
Another common form for a prompt is this one:
[user@host dir]
In the above example, user will be your login name, host the name of the machine you are working on, and dir an indication of your current location in the file system.
Later we will discuss prompts and their behavior in detail. For now, it suffices to know that prompts can display all kinds of information, but that they are not part of the commands you are giving to your system.
To disconnect from the system in graphical mode, you need to close all terminal windows and other applications. After that, hit the logout icon or find Log Out in the menu. Closing everything is not really necessary, and the system can do this for you, but session management might put all currently open applications back on your screen when you connect again, which takes longer and is not always the desired effect. However, this behavior is configurable.
When you see the login screen again, asking to enter user name and password, logout was successful.
You know you’re in text mode when the whole screen is black, showing (in most cases) white characters. A text mode login screen typically shows some information about the machine you are working on, the name of the machine and a prompt waiting for you to log in:
RedHat Linux Release 8.0 (Psyche) blast login: _
The login is different from a graphical login, in that you have to hit the Enter key after providing your user name, because there are no buttons on the screen that you can click with the mouse. Then you should type your password, followed by another Enter. You won’t see any indication that you are entering something, not even an asterisk, and you won’t see the cursor move. But this is normal on Linux and is done for security reasons.
When the system has accepted you as a valid user, you may get some more information, called the message of the day (motd), which can be anything. Additionally, it is popular on UNIX systems to display a fortune cookie, which contains some general wise or unwise (this is up to you) thoughts. After that, you will be given a shell, indicated with the same prompt that you would get in graphical mode.
Logging out is done by entering the logout command, followed by Enter. You are successfully disconnected from the system when you see the login screen again.
Now that we know how to connect to and disconnect from the system, we’re ready for our first commands.
Prev: Quickstart
Home
Next: Absolute basics
These are the quickies, which we need to get started; we will discuss them later in more detail.
Table 2-1. Quickstart commands
| Command | Meaning |
|---|---|
| ls | Displays a list of files in the current working directory, like the dir command in DOS |
cd directory |
change directories |
| passwd | change the password for the current user |
file filename |
display file type of file with name filename |
cat textfile |
throws content of textfile on the screen |
| pwd | display present working directory |
| exit or logout | leave this session |
man command |
read man pages on command |
info command |
read Info pages on command |
apropos string |
search the whatis database for strings |
You type these commands after the prompt, in a terminal window in graphical mode or in text mode, followed by Enter.
Commands can be issued by themselves, such as ls. A command behaves differently when you specify an option, usually preceded with a dash (-), as in ls -a. The same option character may have a different meaning for another command. GNU programs take long options, preceded by two dashes (--), like ls --all. Some commands have no options.
The argument(s) to a command are specifications for the object(s) on which you want the command to take effect. An example is ls /etc, where the directory /etc is the argument to the ls command. This indicates you want to display the content of the /etc directory rather than the default, which is the content of the current directory, obtained by just typing ls followed by Enter. Some commands require arguments, sometimes arguments are optional.
You can find out whether a command takes options and arguments, and which ones are valid, by checking the online help for that command, see Section 2.3.
In Linux, like in UNIX, directories are separated using forward slashes, like the ones used in web addresses (URLs). We will discuss directory structure in-depth later.
The symbols . and .. have special meaning when directories are concerned. We will try to find out about those during the exercises, and more in the next chapter.
Try to avoid logging in with or using the system administrator’s account, root. Besides doing your normal work, most tasks, including checking the system, collecting information etc., can be executed using a normal user account with no special permissions at all. If needed, for instance when creating a new user or installing new software, the preferred way of obtaining root access is by switching user IDs, see Section 3.2.1 for an example.
Almost all commands in this book can be executed without system administrator privileges. In most cases, when issuing a command or starting a program as a non-privileged user, the system will warn you or prompt you for the root password when root access is required. Once you’re done, leave the application or session, in which you used your root privileges, immediately.
Reading documentation should become your second nature. Especially in the beginning, it is important to read system documentation, manuals for basic commands, HOWTOs and so on. Since the amount of documentation is so enormous, it is impossible to include all related documentation. This book will try to guide you to the most appropriate documentation on every subject discussed, in order to stimulate the habit of reading the man pages.
Several special key combinations allow you to do things easier and faster with the GNU shell, Bash, which is the default on almost any Linux system, see Section 3.2.3.2. Below is a list of the most commonly used features; it is strongly suggested that you make a habit out of using them, so as to get the most out of your Linux experience from the very beginning.
Table 2-2. Key combinations in Bash
| Key or key combination | Function |
|---|---|
| Ctrl+A or Home | Move cursor to the beginning of the command line. |
| Ctrl+C | End a running program and return the prompt, see Chapter 4. |
| Ctrl+D | Log out of the current shell session, equal to typing exit or logout. |
| Ctrl+E or End | Move cursor to the end of the command line. |
| Ctrl+H | Generate backspace character. |
| Ctrl+L | Clear this terminal. |
| Ctrl+R | Search command history, see Section 3.3.3.4. |
| Ctrl+Z | Suspend a program, see Chapter 4. |
| ArrowLeft and ArrowRight | Move the cursor one place to the left or right on the command line, so that you can insert characters at other places than just at the beginning and the end. |
| Ctrl+ArrowLeft and Ctrl+ArrowRight | Move the cursor one word to the left or right on the command line, so that you can insert characters at other places than just at the beginning and the end. |
| ArrowUp and ArrowDown | Browse history. Go to the line that you want to repeat, edit details if necessary, and press Enter to save time. |
| Shift+PageUp and Shift+PageDown | Browse terminal buffer (to see text that has scrolled off the screen). |
| Tab | Command or filename completion; when multiple choices are possible, the system will either signal with an audio or visual bell, or, if too many choices are possible, ask you if you want to see them all. |
| Tab Tab | Shows file or command completion possibilities. |
The last two items in the above table may need some extra explanations. For instance, if you want to change into the directory directory_with_a_very_long_name, you are not going to type that very long name. You just type on the command line cd dir, then you press Tab and the shell completes the name for you, if no other files are starting with the same three characters. Of course, if there are no other items starting with d, then you might just as well type cd d and then Tab. If more than one file starts with the same characters, the shell will signal this to you, upon which you can hit Tab again, and the shell presents the choices you have:
your_prompt> cd st starthere stuff stuffit
In the above example, if you type “a” after the first two characters and hit Tab again, no other possibilities are left, and the shell completes the directory name, without you having to type the string rthere:
your_prompt> cd starthere
Of course, you’ll still have to hit Enter to accept this choice.
In the same example, if you type “u”, and then hit Tab, the shell will add the “ff” for you, but then it protests again, because multiple choices are possible. If you type Tab Tab again, you’ll see the choices; if you type one or more characters that make the choice unambiguous to the system, and Tab again, or Enter when you’ve reach the end of the file name that you want to choose, the shell completes the file name and changes you into that directory - if indeed it is a directory name.
This works for all file names that are valid arguments to commands. For instance, if you have a text file stuff.txt, it will not affect completion for a cd command, since it is not a directory.
The same goes for command name completion. Typing ls and then hitting the Tab key twice, lists all the commands in your PATH (see Section 3.2.1) that start with these two characters:
your_prompt> ls ls lsdev lspci lsraid lsw lsattr lsmod lspgpot lss16toppm lsb_release lsof lspnp lsusb
Prev: Logging in, activating the user interface and logging out
Home
Next: Getting help====== 2.3. Getting help ======
GNU/Linux is all about becoming more self-reliant. And as usual with this system, there are several ways to achieve the goal. A common way of getting help is finding someone who knows, and however patient and peace-loving the Linux-using community will be, almost everybody will expect you to have tried one or more of the methods in this section before asking them, and the ways in which this viewpoint is expressed may be rather harsh if you prove not to have followed this basic rule.
A lot of beginning users fear the man (manual) pages, because they are an overwhelming source of documentation. They are, however, very structured, as you will see from the example below on: man man.
Reading man pages is usually done in a terminal window when in graphical mode, or just in text mode if you prefer it. Type the command like this at the prompt, followed by Enter:
yourname@yourcomp~> man man |
The documentation for man will be displayed on your screen after you press Enter:
man(1) man(1) NAME man - format and display the on-line manual pages manpath - determine user's search path for man pages SYNOPSIS man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-S section_list] [section] name ... DESCRIPTION man formats and displays the on-line manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the manual page files. OPTIONS -C config_file lines 1-27
Browse to the next page using the space bar. You can go back to the previous page using the b-key. When you reach the end, man will usually quit and you get the prompt back. Type q if you want to leave the man page before reaching the end, or if the viewer does not quit automatically at the end of the page.
Each man page usually contains a couple of standard sections, as we can see from the man man example:
[ and ] to indicate that they can be left out.SEE ALSO section. In between parentheses is the number of the man page section in which to find this command. Experienced users often switch to the SEE ALSO part using the / command followed by the search string SEE and press Enter.Some commands have multiple man pages. For instance, the passwd command has a man page in section 1 and another in section 5. By default, the man page with the lowest number is shown. If you want to see another section than the default, specify it after the man command:
man 5 passwd
If you want to see all man pages about a command, one after the other, use the -a to man:
man -a passwd
This way, when you reach the end of the first man page and press SPACE again, the man page from the next section will be displayed.
In addition to the man pages, you can read the info pages about a command, using the info command. These usually contain more recent information and are somewhat easier to use. The man pages for some commands refer to the info pages.
Get started by typing info info in a terminal window:
File: info.info, Node: Top, Next: Getting Started, Up: (dir) Info: An Introduction ********************* Info is a program, which you are using now, for reading documentation of computer programs. The GNU Project distributes most of its on-line manuals in the Info format, so you need a program called "Info reader" to read the manuals. One of such programs you are using now. If you are new to Info and want to learn how to use it, type the command `h' now. It brings you to a programmed instruction sequence. To learn advanced Info commands, type `n' twice. This brings you to `Info for Experts', skipping over the `Getting Started' chapter. * Menu: * Getting Started:: Getting started using an Info reader. * Advanced Info:: Advanced commands within Info. * Creating an Info File:: How to make your own Info file. --zz-Info: (info.info.gz)Top, 24 lines --Top------------------------------- Welcome to Info version 4.2. Type C-h for help, m for menu item.
Use the arrow keys to browse through the text and move the cursor on a line starting with an asterisk, containing the keyword about which you want info, then hit Enter. Use the P and N keys to go to the previous or next subject. The space bar will move you one page further, no matter whether this starts a new subject or an info page for another command. Use Q to quit. The info program has more information.
A short index of explanations for commands is available using the whatis command, like in the examples below:
[your_prompt] whatis ls |
ls (1) - list directory contents
This displays short information about a command, and the first section in the collection of man pages that contains an appropriate page.
If you don’t know where to get started and which man page to read, apropos gives more information. Say that you don’t know how to start a browser, then you could enter the following command:
another prompt> apropos browser |
Galeon [galeon](1) - gecko-based GNOME web browser lynx (1) - a general purpose distributed information browser for the World Wide Web ncftp (1) - Browser program for the File Transfer Protocol opera (1) - a graphical web browser pilot (1) - simple file system browser in the style of the Pine Composer pinfo (1) - curses based lynx-style info browser pinfo [pman] (1) - curses based lynx-style info browser viewres (1x) - graphical class browser for Xt
After pressing Enter you will see that a lot of browser related stuff is on your machine: not only web browsers, but also file and FTP browsers, and browsers for documentation. If you have development packages installed, you may also have the accompanying man pages dealing with writing programs having to do with browsers. Generally, a command with a man page in section one, so one marked with (1), is suitable for trying out as a user. The user who issued the above apropos might consequently try to start the commands galeon, lynx or opera, since these clearly have to do with browsing the world wide web.
Most GNU commands support the --help, which gives a short explanation about how to use the command and a list of available options. Below is the output of this option with the cat command:
userprompt@host: cat --help |
Usage: cat [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation,
except for LFD and TAB
--help display this help and exit
--version output version information and exit
With no FILE, or when FILE is -, read standard input.
Report bugs to <bug-textutils@gnu.org>.
Don’t despair if you prefer a graphical user interface. Konqueror, the default KDE file manager, provides painless and colourful access to the man and Info pages. You may want to try info:info in the Location address bar, and you will get a browsable Info page about the info command. Similarly, man:ls will present you with the man page for the ls command. You even get command name completion: you will see the man pages for all the commands starting with ls in a scroll-down menu. Entering info:/dir in the address location toolbar displays all the Info pages, arranged in utility categories. Excellent Help content, including the Konqueror Handbook. Start up from the menu or by typing the command konqueror in a terminal window, followed by Enter; see the screenshot below.
Figure 2-2. Konqueror as help browser
The Gnome Help Browser is very user friendly as well. You can start it selecting Applications→Help from the Gnome menu, by clicking the lifeguard icon on your desktop or by entering the command gnome-help in a terminal window. The system documentation and man pages are easily browsable with a plain interface.
The big advantage of GUIs for system documentation is that all information is completely interlinked, so you can click through in the SEE ALSO sections and wherever links to other man pages appear, and thus browse and acquire knowledge without interruption for hours at the time.
Some commands don’t have separate documentation, because they are part of another command. cd, exit, logout and pwd are such exceptions. They are part of your shell program and are called shell built-in commands. For information about these, refer to the man or info page of your shell. Most beginning Linux users have a Bash shell. See Section 3.2.3.2 for more about shells.
If you have been changing your original system configuration, it might also be possible that man pages are still there, but not visible because your shell environment has changed. In that case, you will need to check the MANPATH variable. How to do this is explained in Section 7.2.1.2.
Some programs or packages only have a set of instructions or references in the directory /usr/share/doc. See Section 3.3.4 to display.
In the worst case, you may have removed the documentation from your system by accident (hopefully by accident, because it is a very bad idea to do this on purpose). In that case, first try to make sure that there is really nothing appropriate left using a search tool, read on in Section 3.3.3. If so, you may have to re-install the package that contains the command to which the documentation applied, see Section 7.5.
Prev: Absolute basics
Home
Next: Summary
Linux traditionally operates in text mode or in graphical mode. Since CPU power and RAM are not as expensive as they used to be, every Linux user can afford to work in graphical mode and will usually do so. This does not mean that you don’t have to know about text mode: we will work in the text environment throughout this course, using a terminal window.
Linux encourages its users to acquire knowledge and to become independent. Inevitably, you will have to read a lot of documentation to achieve that goal; that is why, as you will notice, we refer to extra documentation for almost every command, tool and problem listed in this book. The more docs you read, the easier it will become and the faster you will leaf through manuals. Make reading documentation a habit as soon as possible. When you don’t know the answer to a problem, refering to the documentation should become a second nature.
Prev: Getting help
Home
Next: Exercises
Most of what we learn is by making mistakes and by seeing how things can go wrong. These exercises are made to get you to read some error messages. The order in which you do these exercises is important.
Don’t forget to use the Bash features on the command line: try to do the exercises typing as few characters as possible!
Log in again with your user name and password.
P6p3.aa!. Change your password after this exercise! Note that some systems might not allow to recycle passwords, i.e. restore the original one within a certain amount of time or a certain amount of password changes, or both.
These are some exercises to help you get the feel.
blah .. cd and ..! Use the pwd command. /
/ and then to etc. Type ls; if the output is longer than your screen, make the window longer, or try Shift+PageUp and Shift+PageDown. inittab contains the answer to the first question in this list. Try the file command on it. inittab is …..inittab and read the file. . .?. using the cat command?--help option. Use the option for numbering of output lines to count how many users are listed in the file /etc/passwd.
introlspasswdpwd command.--help and try it out.
Answer Key
Prev: Summary
Home
Next: About files and the file system
Copyright (c) by the authors.
This section of the wiki is licensed under the terms of the GNU Free Documentation License.
See the LBook-licensing page for details.
Linux® is a registered trademark of Linus Torvalds.