19.1 Using the Bash Shell

For UNIX or Linux several shells are available which differ slightly in behavior and in the commands they accept. The default shell in openSUSE® is Bash (GNU Bourne-Again Shell).

If you are logged in to a graphical user interface, you can start a (login) shell parallel to the user interface or in a terminal window within the graphical user interface. Press Ctrl+Alt+F2 to leave the graphical user interface and access a login shell. After login, the prompt shows your login name followed by @ and the hostname of your computer. The hostname is followed by a colon and the path to the current directory. If you have logged in as system administrator, root, Bash indicates this with a hash symbol, #. Directly after login, the current directory is usually the home directory of the user account with which you have logged in, indicated by the tilde symbol, ~. When you are logged in on a remote computer the information provided by the prompt always shows you which system you are currently working on. You can now enter commands and execute tasks. To log out from the shell, enter exit and press Alt+F7 to switch back to the graphical user interface. You will find your desktop and the applications running on it unchanged.

To start a terminal window within the graphical user interface in KDE or GNOME press Alt+F2 and enter xterm (or click the Konsole or GNOME terminal icon in the panel). This opens a terminal window on your desktop. As you are already logged in to your desktop the prompt shows the usual login and path information. You can now enter commands and execute tasks just like in any shell which runs parallel to your desktop. To close the terminal window press Alt+F4 .

The Konsole or the GNOME Terminal window appears, displaying the prompt at the first line, see Figure 19-1. The prompt usually shows your login name (in this example, tux), the hostname of your computer (here, knox), and the current path (in this case, your home directory, indicated by the tilde symbol, ~). When you are logged in on a remote computer this information always shows you which system you are currently working on. When the cursor placed behind this prompt, you can send commands directly to your computer system.

Figure 19-1 Example of a Bash Terminal Window

Because the shell does not offer a graphical overview of directories and files like the tree view in a file manager, it is useful to have some basic knowledge of the default directory structure in Linux.

19.1.1 The Directory Structure

The following table provides a short overview of the most important higher-level directories you find on a Linux system. Find more detailed information about the directories and important subdirectories in the following list.

Table 19-1 Overview of a Standard Directory Tree

Directory

Contents

/

Root directory—the starting point of the directory tree.

/bin

Essential binary files, such as commands that are needed by both the system administrator and normal users. Usually also contains the shells, such as Bash.

/boot

Static files of the boot loader.

/dev

Files needed to access host-specific devices.

/etc

Host-specific system configuration files.

/home

Holds the home directories of all users who have an account on the system. Only root's home directory is not located in /home but in /root.

/lib

Essential shared libraries and kernel modules.

/media

Mount points for removable media.

/mnt

Mount point for temporarily mounting a file system.

/opt

Add-on application software packages.

/root

Home directory for the superuser root.

/sbin

Essential system binaries.

/srv

Data for services provided by the system.

/tmp

Temporary files.

/usr

Secondary hierarchy with read-only data.

/var

Variable data such as log files

/windows

Only available if you have both Microsoft Windows* and Linux installed on your system. Contains the Windows data.

The following list provides more detailed information and gives some examples which files and subdirectories can be found in the directories:

/bin

Contains the basic shell commands that may be used both by root and by other users. These commands include ls, mkdir, cp, mv, rm, and rmdir. /bin also contains Bash, the default shell in openSUSE.

/boot

Contains data required for booting, such as the boot loader, the kernel, and other data that is used before the kernel begins executing user mode programs.

/dev

Holds device files that represent hardware components.

/etc

Contains local configuration files that control the operation of programs like the X Window System. The /etc/init.d subdirectory contains scripts that are executed during the boot process.

/home/username

Holds the private data of every user who has an account on the system. The files located here can only be modified by their owner or by the system administrator. By default, your e-mail directory and personal desktop configuration are located here in form of hidden files and directories. KDE users find the personal configuration data for their desktop in .kde, GNOME users find it in .gconf. For information about hidden files, refer to Section 7.2.1, Key Features, (↑ Start-Up ).

NOTE: Home Directory in a Network Environment

If you are working in a network environment, your home directory may be mapped to a directory in the file system other than /home.

/lib

Contains essential shared libraries needed to boot the system and to run the commands in the root file system. The Windows equivalent for shared libraries are DLL files.

/media

Contains mount points for removable media, such as CD-ROMs, USB sticks, and digital cameras (if they use USB). /media generally holds any type of drive except the hard drive of your system. As soon as your removable medium has been inserted or connected to the system and has been mounted, you can access it from here.

/mnt

This directory provides a mount point for a temporarily mounted file system. root may mount file systems here.

/opt

Reserved for the installation of additional software. Optional software and larger add-on program packages can be found there. KDE3 is located there, whereas KDE4 and GNOME have moved to /usr now.

/root

Home directory for the root user. Personal data of root is located here.

/sbin

As the s indicates, this directory holds utilities for the superuser. /sbin contains binaries essential for booting, restoring, and recovering the system in addition to the binaries in /bin.

/srv

Holds data for services provided by the system, such as FTP and HTTP.

/tmp

This directory is used by programs that require temporary storage of files.

/usr

/usr has nothing to do with users, but is the acronym for UNIX system resources. The data in /usr is static, read-only data that can be shared among various hosts compliant to the Filesystem Hierarchy Standard (FHS). This directory contains all application programs and establishes a secondary hierarchy in the file system. /usr holds a number of subdirectories, such as /usr/bin, /usr/sbin, /usr/local, and /usr/share/doc.

/usr/bin

Contains generally accessible programs.

/usr/sbin

Contains programs reserved for the system administrator, such as repair functions.

/usr/local

In this directory, the system administrator can install local, distribution-independent extensions.

/usr/share/doc

Holds various documentation files and the release notes for your system. In the manual subdirectory, find an online version of this manual. If more than one language is installed, this directory may contain versions of the manuals for different languages.

Under packages, find the documentation included in the software packages installed on your system. For every package, a subdirectory /usr/share/doc/packages/packagename is created that often holds README files for the package and sometimes examples, configuration files, or additional scripts.

If HOWTOs are installed on your system /usr/share/doc also holds the howto subdirectory in which to find additional documentation on many tasks relating to the setup and operation of Linux software.

/var

Whereas /usr holds static, read-only data, /var is for data which is written during system operation and thus is variable data, such as log files or spooling data. For example, the log files of your system are in /var/log/messages (only accessible for root).

/windows

Only available if you have both Microsoft Windows and Linux installed on your system. Contains the Windows data available on the Windows partition of your system. Whether you can edit the data in this directory depends on the file system your Windows partition uses. If it is FAT32, you can open and edit the files in this directory. For an NTFS file system, however, you can only read your Windows files from Linux, but not modify them. Learn more in Section 11.3, Accessing Files on Different OS on the Same Computer, (↑ Start-Up ).