If you are new to Linux/UNIX 2000, 2001 Alexander Kirillov Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. You may obtain a copy of the GNU Free Documentation License from the Free Software Foundation by visiting their Web site or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Many of the names used by companies to distinguish their products and services are claimed as trademarks. Where those names appear in any GNOME documentation, and those trademarks are made aware to the members of the GNOME Documentation Project, the names have been printed in caps or initial caps. This document was last updated on April 25, 2001. Introduction One of the goals of GNOME is to make your system easy to use, without requiring you to learn the technical details about your operating system. However, there are some basic UNIX notions that you have to be familiar with even while using the easy graphical interface provided by GNOME. For the convenience of new users, these basics are collected in this document. If you need further information on UNIX, you should read the documentation which came with your system; there are also a number of books and on-line guides available for all versions of UNIX. The following guide applies to all versions of UNIX and UNIX-like operating systems, including both the commercial Unices such as Solaris and open-source operating systems such as FreeBSD and Linux. Some of the material here is based on Linux Installation and Getting Started guide, by Matt Welsh, Phil Hughes, David Bandel, Boris Beletsky, Sean Dreilinger, Robert Kiesling, Evan Leibovitch, and Henry Pierce. The guide is available for download or online viewing from the Linux Documentation Project or from the Open Source Writers Group. Users UNIX is a multiuser operating system: it was designed to allow many users to work on the same computer, either simultaneously (using several terminals or network connections) or in turns. Under UNIX, to identify yourself to the system, you must log in, which entails entering your login name (the name the system uses to identify you) and your password, which is your personal key for logging in to your account. Because only you know your password, no one else can log in to the system under your user name. Usually people choose their first or last name or some variation of it as their login name, so that if your real name is Sasha Beilinson, your login might be sasha. Each user has a separate place to keep his files (called his home directory). UNIX has a system of permissions (see ), so that on a properly configured UNIX system a user can't change other users' or system files. This also allows every user to customize various aspects of the system — in particular, GNOME behavior — for himself, without affecting other users. On any UNIX system there is also a special user, called system administrator, with the login name root. He has full control over the system — including full access to all the system and users' files. He has the authority to change the passwords of existing users and add new users, install and uninstall software, and so on. The system administrator is usually the person responsible for proper functioning of the system, so if you have some problems, you should ask him. IMPORTANT Even if you are the only user on your computer (for example, if the computer is your personal workstation), so that you are also the system administrator, it is important that you create a user account and use it for daily work, logging in as root only when necessary for system maintenance. Because root can do anything, it is easy to make mistakes that have catastrophic consequences. Picture the root account as a magic hat that gives you lots of power, with which you can, by waving your hands, create or destroy entire cities. Because it is easy to wave your hands in a destructive manner, it is not a good idea to wear the magic hat when it is not needed, despite the wonderful feeling. Files and filenames Under most operating systems (including UNIX), there is the concept of a file, which is just a bundle of information given a name (called a filename). Examples of files might be your history term paper, an e-mail message, or an actual program that can be executed. Essentially, anything saved on disk is saved in an individual file. Filenames Files are identified by their filenames. For example, the file containing your conference talk might be saved with the filename talk.txt. There is no standard format for file names as there is under MS-DOS and some other operating systems; in general, a filename can contain any character (except the / character–see the discussion of path names below) and is limited to 256 characters in length. IMPORTANT Unlike MS-DOS, the filenames in UNIX are case-sensitive: myfile.txt and MyFile.txt are considered as two different files. You should also be aware of several UNIX conventions; while they are not mandatory, it is usually a good idea to follow them. It is customary to use the format filename.extension for filenames, where the extension indicates the file type; for example, the extension txt is usually used for plain text files, while the extension jpeg is used for graphics in JPEG format, and so on. In particular, the GNOME File Manager (Nautilus) uses extensions to determine file type. You can view or change file extensions recognized by GNOME by selecting the section Document Handlers MIME types in GNOME Control Center. Note that the standard convention in UNIX is that the executables (i.e., the program files) have no extension at all. Files and directories whose names begin with a dot (.) are usually configuration files, that is, files which keep settings and preferences for various applications. For example, GNOME keeps all its settings in various files in the directories .gnome and .gnome-desktop in the user's home directory. Since most of the time you do not need to edit these files manually, or even know their precise names and locations, Nautilus usually doesn't show these files. You can change this setting as described in Nautilus manual. Files with names ending with tilde (~) are usually backup files created by various applications. For example, when you edit a file myfile.txt with emacs, it saves the previous version in the file myfile.txt~. Wildcards When entering commands from the command line, you can use so-called wildcards instead of an exact filename. The most common wildcard is *, which matches any sequence of symbols (including an empty string). For example, the command ls *.txt will list all the files with the extension txt, and the command rm chapter* will remove all files with the names starting with chapter (ls and rm are UNIX commands for listing and removing files). Another useful wildcard is ?, which matches any single symbol: for example, rm chapter?.txt will remove files chapter1.txt, chapter2.txt , but not chapter10.txt Most new GNOME users prefer using the GNOME File Manager for operations with files, rather than working from the command line. Wildcards can also be used in Nautilus in the file selection and view filter dialogs. Using spaces, commas, etc. in file names As was mentioned above, a file name may contain not only letters and numbers, but also spaces, commas, etc. — any characters other than slash (/). However, if you are using commands typed on the command line, you should be careful when dealing with such files. To avoid problems, it is advised that you enclose filenames that contain anything other than letters, numbers, and dots, in single quotes: to delete file My File, you should type rm 'My File' rather than rm My File. Of course, if you are only using graphical tools such as GNOME File Manager, than you do not need to worry about this: to delete file My File, just drag it to the trash can. Directories and paths Directory structure Now, let's discuss the concept of directories. A directory is a collection of files. It can be thought of as a folder that contains many different files. Directories are given names, with which they can be identified. Furthermore, directories are maintained in a tree-like structure; that is, directories may contain other directories. The top level directory is called the root directory and denoted by /; it contains all the files in your system. Pathnames A pathname is a file's full name; it contains not only filename but also its location. It is made up of the filename, preceded by the name of the directory containing that file. This, in turn, is preceded by the name of directory containing that directory, and so on. A typical pathname may look like /home/sasha/talk.txt which refers to the file talk.txt in the directory sasha which in turn is a subdirectory in /home. As you can see, the directory and filename are separated by a single slash (/). For this reason, filenames themselves cannot contain the / character. MS-DOS users will find this convention familiar, although in the MS-DOS world the backslash (\) is used instead. The directory that contains a given subdirectory is known as the parent directory. Here, the directory home is the parent of the directory sasha. Each user has a home directory, which is the directory set aside for that user to store his or her files. Usually, user home directories are contained under /home, and are named for the user owning that directory, so that the home directory of user sasha would be /home/sasha. Relative directory names At any moment, commands that you enter are assumed to be relative to your current working directory. You can think of your working directory as the directory in which you are currently located. When you first log in, your working directory is set to your home directory — for user sasha, it would be /home/sasha. Whenever you refer to a file, you may refer to it in relationship to your current working directory, rather than specifying the full pathname of the file. For example, if your current directory is /home/sasha, and you have a file there called talk.txt, you can refer to it just by its file name: a command like emacs talk.txt issued from the directory /home/sasha is equivalent to emacs /home/sasha/talk.txt (emacs is an extremely powerful editor for text files; new users may prefer something simpler, such as gnotepad, but for power user, emacs is indispensable). Similarly, if, in /home/sasha you have a subdirectory called papers and, in that subdirectory, a file called fieldtheory.txt, you can refer to it as papers/fieldtheory.txt. If you begin a filename (like papers/fieldtheory.txt) with a character other than /, you're referring to the file in terms relative to your current working directory. This is known as a relative pathname. On the other hand, if you begin a filename with a /, the system interprets this as a full pathname — that is, a pathname that includes the entire path to the file, starting from the root directory, /. Use of the full pathname is known as an absolute pathname. Pathname conventions Here are some standard conventions you can use in paths: ~/ — user's home directory ./ — current working directory ../ — parent of the current directory For example, if sasha's current directory is /home/sasha/papers, he can refer to the file /home/sasha/talk.txt as ~/talk.txt or as ../talk.txt. Permissions Every file on your system has an owner — one of the users (usually the one who created this file), and a system of permissions, which regulate access to this file. For ordinary files, there are 3 types of access permissions: read, write, and execute (the latter only makes sense for executable files). They can be set independently for 3 categories of users: the file owner, the users in the group owning the file, and everyone else. Discussion of groups of users goes beyond the scope of this document; the other two categories are self-explanatory. So, if the permissions on a file /home/sasha/talk.txt are set to read and write for user sasha, who is the file owner, and read only for everyone else, only sasha will be able to modify this file. All newly created files carry some standard permissions, usually read/write for user and read only for everyone else. You can view the permissions using the GNOME File Manager, by right-clicking on the file, choosing Properties in the pop-up menu, and then the Permissions tab. Using this dialog, you can also change the permissions — just click on a square representing the permission to toggle it. Of course, only the file owner or the system administrator can change the permissions of a file. Advanced users can also change the default file permissions which are assigned to newly created files—see the manual pages for your default shell (usually bash, csh or tcsh) and look for the command umask. A file can also have some special permission properties such as UID, GID, and sticky bit. They are for advanced users only — do not change them unless you know what you are doing. (If you are curious: these permissions are typically used on executable files to allow the user to execute some commands which read or modify files to which the user himself doesn't have access.) Similar to files, the directories also have permissions. Again, there are 3 possible permissions: read, write, and execute. However, they have different meaning: namely, read permission for a directory means permission to list the contents of the directory or search for a file; write means permission to create and remove files in the directory, and execute means permission to access files in the directory. Note that the permissions granted to a file depend on the permissions of the directory in which the file is located: in order to be able to read a file, a user needs to have the read permission for the file itself and execute permission for the directory that contains it. So, if user sasha doesn't want anybody else to see his files, he can achieve this by removing the execute permission on his home directory for all other users. This way, no one but himself (and, of course, root) will be able to read any of his files, no matter what the permissions of individual files are. Detailed explanation of the permission system can be found, for example, in the info page for the GNU File Utilities package. Symbolic links In addition to regular files, UNIX also has special files called symbolic links (or symlinks for short). These files do not contain any data; instead, they are just pointers, or shortcuts to other files. For example, sasha can have a symlink named ft.txt pointing to the file papers/fieldtheory.txt; this way, when a program tries to access the file ft.txt, the file papers/fieldtheory.txt will be opened instead. As you can see from this example, the symlink and the target file can have different names and be located in different directories. Note that deleting, moving, or renaming the symlink file has no effect on the target file: if sasha tries to delete the file ft.txt, it is the symlink that will be deleted, and the file papers/fieldtheory.txt will remain unchanged. Also, the permissions of the symlink are meaningless: it is the permissions of the target file that determine whether a user has the access to it. Symlinks can also point to directories. For example, on the GNOME FTP server (ftp.gnome.org), there is a file /pub/GNOME/stable/releases/october-gnome, which is actually a symlink to directory /pub/GNOME/stable/releases/gnome-1.0.53 — as one would expect, since October GNOME is just another name for 1.0.53 release of GNOME. Mounting and unmounting drives As we mentioned earlier, the directories on a UNIX system are organized in a tree, with the top level directory being /. Unlike some other operating systems such as MS-DOS, there are no special names for files on your floppy disk or CD-ROM: all the files accessible to your system must appear in the main directory tree starting with /. Thus, before you can access files on a floppy diskette or a CD-ROM, you must give to your system a command to incorporate the contents of this diskette into the main directory tree, which is referred to as mounting the diskette. You can think of it as the software analog of connecting the drive to your system. Typically the contents of the CD-ROM will appear under the name /mnt/cdrom; the floppy diskette under /mnt/floppy (these are called the mount points and are defined in the special configuration file, /etc/fstab). Accessing a drive in this fashion doesn't mean that the system will copy all the files from the CD to the directory /mnt/cdrom. Instead, it means that the directory /mnt/cdrom represents the CD-ROM: When a program tries to access, say, a file called /mnt/cdrom/index.html, the system will look for file index.html on the CD-ROM. So, in short: before you can use files on a drive, you must mount it. Similarly, before removing the disk from the drive, you must unmount it. When using GNOME, you usually do not have to worry about mounting and unmounting: GNOME scans the appropriate configuration file and places the icons for all drives on your desktop. Double-clicking on any of these icons automatically mounts the corresponding drive (if it was not already mounted) and starts the file manager in the appropriate directory. Similarly, if you right-click on the drive icon and choose the command Eject device from the pop-up menu, GNOME automatically unmounts it before ejecting. You can also mount/unmount a drive by right-clicking on its icon on the desktop and choosing Mount device or Unmount device from the pop-up menu, or by using the disk mount applet. Note that you can't unmount a drive if it is being used by some program; for example, if you have a terminal windows open in a directory on the drive you're trying to unmount. So, if you get the error message Device busy while trying to unmount a drive, make sure that none of your open applications is accessing a file or directory on this drive. However, GNOME cannot prevent you from ejecting the disk using the physical eject button on the drive itself — in this case, it is your responsibility to unmount the drive before doing so. For CD and Zip drives, the system blocks the eject button on the drive while the drive is mounted; for floppy drives this is technically impossible. IMPORTANT If you eject a floppy disk using the eject button on the drive without first unmounting it, you may lose your data! Some systems are running special programs such as supermount or magicdev which automatically mount a drive when a disk is inserted and unmount a drive if it hasn't been used for a specified period of time. In this case, you will probably never need to worry about mounting/unmounting drives yourself; you don't even need to read this section. Allowing users to mount and unmount drives carries some security risks, so many multi-user systems are configured so that only root can mount or unmount drives. This is the most probable cause of error messages you may be getting while trying to mount a drive. In this case, discuss this matter with your system administrator. If the computer is your personal workstation or home computer and you are not worried about security, you can give mount permission to ordinary users. The easiest way to allow this is to use the application linuxconf (which can only be run by root). Just select the drive you want to access in the Access local drive section. In the Options tab select the User Mountable option. Your drive will now be mountable by users. If linuxconf is not available, then you must manually edit the file /etc/fstab to include user access. This is done by adding the user attribute to the drive. For example: If your fstab file contains a line like this: /dev/cdrom /mnt/cdrom iso9660 exec,dev,ro,noauto 0 0 add the word user to the fourth column: /dev/cdrom /mnt/cdrom iso9660 user,exec,dev,ro,noauto 0 0 Drives and devices Under UNIX, the word device is used for all peripheral devices connected to your computer; this includes hard drives, floppy and CD-ROM drives, audio and video cards, serial and parallel ports, and much more. Each device has a name, such as /dev/hda. The most common device names are listed below (for Linux; other varieties of UNIX may use slightly different device names). /dev/hd* (where *=a,b,c, …): these are IDE devices, such as hard drives, CD-ROM drives and ZIP drives. /dev/hda denotes the master drive on the first IDE controller (usually your first hard drive, C: under Windows), /dev/hdb is the slave drive on the first controller (this can be a second hard drive or a CD-ROM), and so on. See also the note below about ZIP drives. /dev/sd* (where *=a,b,c, …): these are SCSI devices, usually hard drives. NOTE If the acronyms IDE and SCSI are new to you, here is a brief explanation: there are two types of interfaces for hard drives and other similar devices: IDE (and its cousins such as EIDE, ATAPI, etc.) and SCSI. SCSI provides better performance, but is more expensive, so it is mostly used on servers. If you are not sure what kind of drives you have, most probably it is IDE. /dev/fd* (where *=0,1, etc) are floppy drives; /dev/fd0 is the first drive (it corresponds to A: under Windows), /dev/fd1 is the second (B:), etc. /dev/lp* (where *=0,1, etc) are parallel ports; most commonly, these ports are used to connect a printer to the computer. /dev/lp0 corresponds to LPT1 under Windows, /dev/lp1 to LPT2, etc. /dev/ttyS* (where *=0,1, etc) are serial ports; these ports are commonly used for connecting a mouse or a modem. /dev/ttyS0 corresponds to COM1 under Windows, /dev/ttyS1 to COM2, etc. /dev/audio and /dev/dsp — these two device names are used for your audio card (they are not equivalent, since they are used for different types of audio files). In addition, it is a common practice to have symlinks /dev/floppy, /dev/modem and /dev/cdrom pointing to the actual device name corresponding to your floppy drive, modem, and CD-ROM drive respectively. You rarely need to use these device names. In particular, if you want to access a file on a drive, you do not use the device name (such as /dev/fd0); instead, you first mount the device so that its contents shows as a subdirectory (for example, /mnt/floppy) in the main directory tree, and then use this directory for accessing files; see for more information. About the only time when you actually need to use the device names is when you are configuring some newly installed program. For example, a fax program can ask you for the device name for your modem (in which case you can either give it the actual device name, such as /dev/ttyS1, or just use the symlink /dev/modem). And just for fun: there is also a device /dev/null which acts as a black hole: you can send to it any information, and it never returns. So if you do not want to be bothered by error messages, re-direct them to /dev/null -:). Partitions Note that it is possible to subdivide a hard drive (or a similar device) into parts which for all practical purposes behave as independent disks, even though physically they reside on the same disk. These parts are called partitions (under Windows, the name logical disk is used). For example, you can partition your hard drive into several partitions, and install different operating systems in different partitions; you can reformat each partition independently of the others. This partitioning of the hard drive is usually done during the installation of the operating system; refer to your installation guide for more information. If your hard drive has been partitioned then each partition is considered as a separate device. For example, if your hard drive is /dev/hda, then the first partition on this drive would be referred to as /dev/hda1, the second as /dev/hda2, and so on. Partitioning of ZIP disks For reasons unknown to us, the pre-formatted ZIP disks sold in stores or formatted using Iomega's ZIP tools under Windows are partitioned in a strange way: they have only one partition (of Windows type, of course), but this partition has number 4. Thus, if your ZIP drive is /dev/hdc, the correct device name you should use for such disks is /dev/hdc4. Graphical user interface: X Window System, window managers, and desktop environments. UNIX is a modular system: it consists of many components so that a user (or system administrator) can choose those components he needs. In particular, there are several layers of software responsible for graphical user interface. These layers are: X Window System, window managers, and desktop environment. X Window System (also known as X, or X11) is the component of UNIX systems responsible for virtually all basic graphics — in particular, for drawing icons, backgrounds, and windows in which your applications work. Without X, you only have command line. X11 sets the screen resolution and color depth, moves the mouse cursor around the screen, etc. It serves as a foundation for other components of graphical user interface such as window managers and desktop environments. Window manager extends capabilities of X Window System by placing borders and buttons around windows, which allows the user to move, close, hide or resize the windows. X11 is virtually always used in combination with a window manager, since it would be pretty much unusable without one. There are many window managers available for X11; most popular are fvwm, mwm, kwm (used by KDE), Enlightenment, and Sawfish. Finally, a desktop environment goes one more step further than a window manager by adding a graphical file manager from which you can drag-and-drop items on your desktop, a panel which can be used to launch frequently used applications, and a set of applications and utilities. There are several desktop environments available for all versions of UNIX; the most popular ones are GNOME, KDE and CDE (soon to be replaced by GNOME). Most desktop environments contain a window manager as their integral part; for example, KDE contains its own window manager, kwm (it is possible to use KDE with another window manager, but few people do so). GNOME has no window manager of its own; it will allow you to choose any window manager you already have on your system. To make life easier for new users, usually the Sawfish window manager is distributed with GNOME and is used by default; you can switch to another window manager using GNOME Control Center. Note however that you will need a GNOME-compliant window manager to use such features of GNOME as session management, taskbar applet, etc.