Monday, December 1, 2008

Linux Keyboard Shortcuts

Appendix E.

Keyboard Shortcuts

Here are a few keyboard shortcuts you can use to perform common tasks quickly. Many more are available in addition to what is listed here. 

 

For more command line and keyboard shortcuts, visit: http://sunsite.dk/linux-newbie/lnagficommands.html#shortcuts

 

Ø      [Ctrl] + [Alt] + [Backspace] = kill X. Kills your current X session and returns you to the login screen. Use this if the normal exit procedure does not work.

 

Ø      [Ctrl] + [Alt] + [Delete] = shutdown and reboot. Shuts down your current session and reboots the OS. Use only when the normal shutdown procedure does not work.

 

Ø      [Ctrl] + [Alt] + [Fn] = switches screens. [Ctrl]+[Alt] + one of the function keys displays a new screen. [F1] through [F6] are text (console) screens and [F7] is a graphical screen.

 

Ø      [Alt] + [Tab] = switch tasks. If you have more than one application open at a time, you can use [Alt] + [Tab] to switch among open tasks and applications.

 

Ø      [Ctrl] + [a] = move cursor to the beginning of a line. This works in most text editors and in the URL field in Mozilla.

 

Ø      [Ctrl] + [d] = logout of a terminal or console instead of having to type exit or logout.

 

Ø      [Ctrl] + [e] = move cursor to end of a line. This works in most text editors and in the URL field in Mozilla.

 

Ø      [Ctrl] + [l] = clear the terminal. This shortcut does the same thing as typing clear at a command line.

 

Ø      [Ctrl] + [u] = clear the current line. If you are working in a terminal, use this shortcut to clear the current line from the cursor all the way to the end of the line.

 

Ø      [Middle Mouse Button] = pastes highlighted text. Use the left mouse button to highlight the text. Point the cursor to the spot where you want it pasted. Click the middle mouse button to paste it.

 

Ø      [Tab] = command autocomplete. Use this command when working in a terminal. Type the first few characters of a command and then press the [Tab] key. It will automatically complete the command or show all the commands that match the characters you typed.

 

Ø      [Up] and [Down] Arrow = show command history. When working in a terminal, press the [up] or [down] arrow to scroll through a history of commands you have typed from the current directory. When you see the command you want to use, press [Enter].

 

Ø      clear = clear the terminal. Type this at a command line to clear all displayed data from the terminal window.

 

Ø      exit = logout. Type this at a command line to logout of the current user or root account.

 

Ø      history = show history of commands. Type this at a command line to see a numbered list of the previous 500 commands you typed. To display a shorter list of commands, by type history followed by a space and a number.           For example, history 20.

 

Ø      reset = refresh terminal screen. Type this at a command line to refresh the terminal screen if characters are unclear.

Linux System Directories

Appendix D.

System Directories

This is a list of the primary Red Hat Linux system directories. Each directory is described briefly. For additional directory information, refer to the Official Red Hat Linux Customization Guide and Official Red Hat Linux Reference Guide.

 

Ø      /bin -- Used to store user commands. The directory /usr/bin also stores user commands.

Ø      /sbin  -- Location of many system commands, such as shutdown. The directory /usr/bin also contains many system commands.

Ø      /root -- The home directory of root, the superuser.

Ø      /mnt --This directory typically contains the mount points for file systems mounted after the system is booted. For example, the default CD-ROM mount point is /mnt/cdrom.

Ø      /boot -- Contains the kernel and other files used during system startup.

Ø      /lost+found -- Used by fsck to place orphaned files (files without names).

Ø      /lib  -- Contains many library files used by programs in /bin and /sbin. The directory /usr/lib contains more library files.

Ø      /dev -- Stores device files.

Ø      /etc -- Contains many configuration files and directories.

Ø      /var -- For "variable" files, such as log files and the printer spool.

Ø      /usr -- Contains files and directories directly relating to users of the system.

Ø      /proc  -- A virtual file system (not actually stored on the disk) that contains system information used by certain programs.

Ø      /initrd -- A directory that is used to mount the initrd.img image file and load needed device modules during bootup.

 

Warning

Do not delete this directory. You will be unable to boot your computer if you delete it and reboot your Red Hat Linux machine.

 

Ø      /tmp -- A "scratch pad" for users and programs. /tmp has global read/write access.

Ø      /home -- Typical location of user home directories.

A Comparison of Common DOS and Linux Commands

Appendix C.

A Comparison of Common DOS and Linux

Commands

Many Linux commands typed at a shell prompt are similar to the commands you would type in MSDOS.

In fact, some commands are identical. This appendix provides common commands used at the MS-DOS prompt in Windows and their counterparts in Linux. Basic examples of how the commands are used at the Linux shell prompt are also provided. Note that these commands usually have a number of options. To learn more about each command, read its associated man page (for example, type man ls at the shell prompt to read about the ls command).

 

Table C-1. Similar Commands

Applications

Appendix B.

Applications

The following table shows some of the Red Hat Linux applications that are available to perform many common tasks. This is not a complete list of all applications available. Applications in between (parentheses)denotes the formal name of the application.

 

 

Table B-1. Applications used in Linux

The KDE Desktop Environment-II

A.5. Using The Panel

The panel stretches across the bottom of the desktop. By default, it contains the main menu icon and quick-launch icons for logging out, opening a terminal window, and other common applications and utilities.

 

Figure A-4. The Panel

  

The panel is highly configurable. You can add and remove buttons that launch applications easily. Right-click on the panel and select Panel => Configuration to open the panel Settings. Other tabs in Settings contain options to further customize your panel. Click on Help for more information on these options.

 

Applications and utilities can be added easily to the panel. To add an application to the panel, rightclick on the panel and choose Panel => Add. Then select Button, Applet, Extension, or Special Button, and make your choice from the corresponding menus.

 

A.5.1. Using The Main Menu

The Main Menu is the central point for using KDE. Clicking on the Main Menu icon on the panel displays a large master menu from which you can perform tasks such as launch applications, find files, and configure your desktop. The main menu also contains several submenus that organize applications and tools into several categories, including Extras, Graphics, Internet, and Games. From the Main Menu, you can lock your screen, which will display a password-protected screensaver.

 

You can also run applications from a command line as well as logout of your KDE session.

 

A.5.2. Using Applets

Applets are small applications that run on the panel. There are several types of applets performing functions such as system/network monitoring, launching applications by typing commands in a text box, and even checking the local weather. There are some applets that run on the panel by default. This section covers them in detail.

 

A.5.2.1. Working with Multiple Desktops

By default, KDE provides four desktops that you can use to display multiple applications without having to crowd all of them onto one desktop. Each desktop can hold icons, open applications, and have individually customized backgrounds. For example, while you are writing a message in KMail on desktop one, you can have Konqueror browsing the Web on desktop two, the KWord word processor open on desktop three, and so on. You can change the number and names of desktops available in KDE by making these adjustments:

 

1. Right-click on the desktop; you will see a brief menu of actions you can take.

2. Select Configure Desktop; the KDE panel configuration tool will open.

3. Click the Number of Desktops tab (see Figure A-5).

 

Figure A-5. The Number of Desktops Tab in the Panel Configuration

 

You can change the names of your desktops (from Desktop 1, Desktop 2, etc.) by deleting the default names and typing a new name in each desktop's corresponding text box. You can also change the number of desktops available to you by adjusting the slider at the top of the Number of Desktops tab. For more desktops, drag the bar to the right; for fewer desktops, drag the bar to the left. The Desktop, Appearance, and Paths tabs are where you can make various desktop configuration selections, like icon arrangement and font size. After you make any adjustments to your desktop configuration, click Apply to save the changes and close the panel configuration tool. Buttons for your desktops appear on the panel in the Desktop Pager. Simply click on the tiles to move to a different desktop.

 

Tip

You can use the keyboard combination of the [Ctrl] and Function keys to switch desktops. For example, [Ctrl]-[F2] will switch you from desktop one to desktop two, [Ctrl]-[F3] will take you to desktop three, and so on.

 

A.5.2.2. Viewing The Taskbar

The taskbar displays all running applications  -- both minimized and on the desktop.

 

Figure A-6. Applications on the Taskbar

 

You can maximize running applications or bring them to the front of your working windows by clicking on the associated item on the taskbar.

 

Tip

Another way to bring minimized or background windows to the front is to use the [Alt] and [Tab] keys. To pick an item from the taskbar, hold down [Alt]-[Tab]. To scroll through the tasks, hold down the [Alt] key, while pressing the [Tab] key in succession. When you have found the task you want to maximize and bring to the front, release both keys.

 

A.5.3. Adding Icons and Applets to the Panel

To further customize the panel for your particular needs, you can include additional applets and icons (launchers).

To add an applet to the panel, click Main Menu => Configure Panel => Add => Applet. Choose the applet you want from the menu and it will immediately appear on the panel. You can move the applet by right-clicking on the applet bar and choosing Move from the menu. To add a new launcher to the panel, click Main Menu => Configure Panel => Add => Button and choose the application or resource you wish to add to the panel. This will automatically add an icon on the panel.

 

A.5.4. Configuring the KDE Panel

You can hide the panel automatically or manually, place it on any edge of your desktop, change its size and color, and change the way it behaves. To alter the default panel settings, click Main Menu => Configure Panel => Preferences. The Settings window will appear, allowing you to adjust all panel settings, or any one of the specific properties (Position, Hiding, Look & Feel, Menus, and so on).

 

A.6. Managing Files

Konqueror is the file manager and Web browser for the KDE desktop. Konqueror allows you to configure your KDE desktop, configure your Red Hat Linux system, play multimedia files, browse digital images, surf the Web, and more from one interface. This section explains some of the ways Konqueror can help you work with and enjoy your Red Hat Linux experience.

 

To start Konqueror for file management, click on your home directory icon. Konqueror will open up in a window on your desktop, allowing you to navigate through your home directory and throughout your Red Hat Linux file system. After exploring, you can return to your home directory by clicking the Home button on the toolbar.

 

Figure A-7. The Konqueror File Manager

 

You can navigate through the file system by clicking on folders within the main window frame or through the hierarchical file system viewer on the navigation panel as shown in Figure A-7. Files and folders in the main window frame can be moved or copied to another folder or sent to the trash. You can also delete files and folders by right-clicking on the item and choosing Delete. Konqueror can also generate thumbnail icons for text, images, PostScript/PDF files, and Web files.

You can even generate preview sounds from digital music files. From the toolbar choose View => Preview and choose the file types for which you would like to see thumbnail icons generated. Thumbnails will be immediately generated for any associated files in the Konqueror window.

 

A.6.1. The Navigation Panel

Another useful feature of Konqueror is the navigation panel. This panel appears on the left side of the Konqueror window by default. The navigation panel makes many of your personalized resources available to you in convenient tabbed icons. Figure A-8 shows the navigation panel.

 

Figure A-8. Working with the Navigation Panel

 

The navigation panel lets you access your Web tutormarks, browsing history, network resources, file system, and has a built-in media player for playing multimedia files without having to open a separate application. The navigation panel makes Konqueror an effieient solution for users who wish to have fast and easy access to all of their information.

 

A.7. Customizing KDE

KDE allows you to configure the desktop and your system to suit your needs. The KDE Control Center, available by selecting Main Menu => Control Center, lets you customize the look and behavior of the desktop. The following list explains some of the configuration options in detail.

 

File Browsing

This section lets you configure the Konqueror file manager and customize certain file operations. You can also associate files to applications that you prefer (for example, assigning all digital music files to open in XMMS instead of the default player).

 

Look & Feel

This sections allows you to customize the visual aspect of your desktop environment. You can customize background images and configure fonts, themes, icons, panel elements, screensavers, and window header decorations. You can also customize mouse and keyboard events which makes working with the desktop as efficient for your needs as possible.

 

Note

KDE features support for smooth (anti-aliased) fonts. However, not all fonts are smooth by default. In order to have smooth fonts for your entire desktop (whether you are reading text files, webpages, or text in menus and icons) you must choose fonts that are designed to be antialiased, such as LucidaTypewriter or Courier).

 

Personalization

This section allows you to set country and language options to your particular locale. You can also configure accessibility features such as audible and visual cues and keyboard/mouse customization. You can also configure your shell prompt settings via the Konsole option. Privacy and encryption settings can be configured via the Crypto option.

 

System

This section is an advanced administration interface. You will need your root password to configure most of these options. This section allows you to configure system boot settings, Linux kernel configuration, printer settings, and install fonts system-wide. It is strongly recommended that you leave these settings at their default values unless you understand the consequences of changing them.

 

Web Browsing

This section allows you to configure the Konqueror Web browser. You can configure options such as cache sizes, website cookies, plugins, proxy settings (if available), and enhanced browsing using keyword shortcuts.

 

A.8. Logging Out of KDE

There are several easy ways to log out from your KDE session:

 

Ø      From the Main Menu, select Logout.

Ø      From the desktop, right-click on the desktop and select Logout from the menu.

 

Figure A-9. KDE Logout Screen

 

At the logout screen, KDE offers you the chance to save your current settings, which will preserve your panel configuration and start any applications that you left open in your session. If you are working in an application and you have not saved your work when you log out, a dialog will inform you that you will lose your unsaved material when you log out. When you see this dialog, you can simply select the Cancel button, save your work, then log out again. If you continue without saving your work, you will lose the unsaved data.

The KDE Desktop Environment-I

Appendix A.

The KDE Desktop Environment

 

A.1. Introducing KDE

KDE is a graphical desktop environment that allows you to access your Red Hat Linux system and applications using your mouse and keyboard.

This chapter covers the fundamental apsects of using the KDE desktop environment including system navigation, working with files and applications, and customizing the desktop to suit your needs. If you would like to learn more about KDE, visit the official website at http://www.kde.org.

 

A.2. Setting Up KDE

The first time you log into KDE (refer to Chapter 1 for more information about logging into your Red Hat Linux machine), a setup wizard will appear that allows you to set up your language and locale settings. Figure A-1 shows the welcome screen of the KDE setup wizard.

 

Figure A-1. The KDE Setup Wizard

 

A.3. Finding Help

You can access a comprehensive set of documentation about KDE through the KDE HelpCenter.

 

Figure A-2. The KDE HelpCenter

 

You can access the HelpCenter from the Main Menu by selecting Help. To access HelpCenter from the desktop, right-click on the desktop and select the Help on desktop. The opening screen of the KDE HelpCenter browser will appear like Figure A-2. From this main page, you can view help documentation on topics such as using and configuring the desktop, working with the many applications included with KDE, and working with the Konquerer file manager. The HelpCenter allows you to perform searches based on keyword entries and Web queries. To do this, click on the search tab and type in a keyword, subject, or significant phrase in the Keywords field. Click on Search or press [Enter] to begin searching the Internet for your subject.

 

A.4. Using The Desktop

After setting up KDE using the wizard, your default desktop will look similar to Figure A-3.

 

Figure A-3. A Typical KDE Desktop

 

The KDE desktop displays application launchers, document windows, file folders, and so on. You can also access the main menu and configure the desktop to suit your needs. The long bar across the bottom of the desktop is the panel. The panel contains application launchers, status indicators, and the desktop manager. You can have up to 16 desktops running at the same time in KDE. The panel taskbar shows your currently running applications. Icons located on the desktop can be files, folders, device links, or application launchers. Click on an icon to open the associated resource.

 

The KDE desktop works similarly to other graphical desktop environments. You can drag and drop files and application icons to any location on the desktop. You can also add new icons for all types of applications and resources to the desktop, panel, or file manager. The desktop itself is also highly customizable. You can change the appearance of buttons, window and frame decorations, and backgrounds easily. Configuration tools are also available which allow you to customize the way the desktop behaves at events such as single- and double-clicking mouse buttons and combining (also called chording) keystrokes to create time-saving shortcuts.

 

The default KDE desktop displays icons for the trash can, your home directory, the KDE Control Panel, and a link to the Red Hat website. You can access any one of these resources by clicking on the associated icon.

When you right-click on these icons, you will see several options for working with these resources, such as Delete Rename Move to Trash, and Copy. You can drag and drop unwanted items such as files you no longer need to the Trash icon. Right-click on the trashcan and select Empty Trash Bin to delete the items from your system permanently.

Finding Commands Quickly

14.5. Finding Commands Quickly

I was looking at a man page yesterday, but I can't remember the name of the command I was reading about, and I didn't write it down. How do I get the man page back?

 

The command you used will most likely be stored in a file called .bash_history. By default, this file records the last 500 commands you typed at the shell prompt. You can glimpse the history of your commands by typing history at the shell prompt, but the results will speed by too quickly for your to read ever line.

 

Another way to view .bash_history is with a utility such as less. Type less .bash_history at the shell prompt and the results will display one page at a time. To move forward a screen, press the [Space] bar; to move back a screen, press the [b] key, and to quit, press [q]. Paging through .bash_history to find a command can be tedious. Alternatively, you can search through the file for keywords using grep, a powerful search utility. Say you were reading the man page the day before, but cannot recall its name. To search for the command, type:

 

history | grep man

 

You will see a list of all the commands you typed which have the word man in them. There are plenty of ways to your command history. For other tips and tricks, see Section 14.6.

 

14.6. Tips on Using Command History

What are some other ways I can use command history?

If you type history, you will see a numbered list scroll by very quickly, showing you the previous 500 commands you have used. You probably do not need to see all of the last 500 commands, so the command history 20 might be useful. This way, only the previous 20 commands you typed will display (you can use any quantity as an argument of the history command).

 

14.6.1. Other Shortcuts

Here are other command history shortcuts which may be useful to you:

 

Ø      "Bang, bang": Typing !! (called "bang bang") executes the last command in the history.

Ø      "Bang number": Typing !number (as in !302) will execute the command which is numbered 302 in the history file.

Ø      "Bang string": Typing !string (as in !rpm) will execute a command with the most recent matching string from the history file.

Ø      [Up arrow] and[ down arrow]: At the shell or GUI terminal prompt, you can simply press the up arrow to move back through previous commands in your history list (the down arrow will move you forward through the commands) until you find the command you want. Press [Enter] to execute the command, just as if you had typed it on the command line.

 

14.7. Keep ls Output from Scrolling

Whenever I type ls I can barely see the output of the directory because it scrolls by too quickly. How can I actually read the output?

To prevent the output of ls from scrolling by too quickly, pipe the output to a utility such as less or more. You will then be able to see the output one screen, or "page" at at time.

 

To read the contents of /etc with less, type the following command at the shell prompt:

ls -al /etc | less

 

To move forward a screen, press [Space] bar; to move back a screen, press the [b] key; to quit, press [q].

 

You can achieve the same results with more, another paging utility.

 

14.7.1. Printing ls Output

You can also print directory listings by piping the output to a printer in the same way that you piped

the output to your screen. If you have configured a printer, type the following to pipe the output of a

command to the printer:

 

ls -al /etc | lpr

 

14.8. Forgotten Password

Help! I forgot my root password. How do I log in now?

You can log in using single-user mode and create a new root password. To enter single-user mode, reboot your computer. If you use the default bootloader, GRUB, you can enter single user mode by performing the following:

 

1. At the bootloader menu, type [e] to enter into editing mode.

2. You will be presented with a boot entry listing. Look for the line that looks similar to the following:

        kernel /vmlinuz-2.4.18-0.4 ro root=/dev/hda2

        Press the arrow key until this line is highlighted and press [e].

3. You can now add the word single once space after the end of the text to tell GRUB to boot into single-user Linux mode. Press [Enter] to make the editing change take effect.

4. You will be brought back to the edit mode screen. From here, press [b] and GRUB will boot single-user Linux mode. After it finishes loading, you will be presented with a shell prompt similar to the following:        sh-2.05#

5. You can now change the root password by typing:         bash# passwd root

You will be asked to re-type the password for verification. Once you are finished, the password will be changed. You can then reboot by typing reboot at the prompt; then you can log in to root as you normally would.

 

14.9. Password Maintenance

I forgot or want to change my user account password.

Open a shell prompt and type the following:

passwd username

 

Replace username with your normal user name.

The passwd will then ask for the new password, which you will need to enter twice. You can now use the new password to log in to your user account.

 

14.10. Changing Login from Console to X at Startup

How do I change my login from the console to the graphical screen?

Instead of logging in to your system at the console and typing the startx command to start the X Window System, you can configure your system so that you can log in directly to X. You must edit one file, /etc/inittab, by changing just one number in the runlevel section. When you are finished, reboot the computer. The next time you log in, you will have a graphical login prompt.

Open a shell prompt. If you're in your user account, su to root by typing

su

Password: yourrootpassword

Now, type pico /etc/inittab to edit the file with Pico. The file /etc/inittab will open.Within the first screen, you will see a section of the file which looks like this:

 

# Default runlevel. The runlevels used by RHS are:

# 0 - halt (Do NOT set initdefault to this)

# 1 - Single user mode

# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)

# 3 - Full multiuser mode

# 4 - unused

# 5 - X11

# 6 - reboot (Do NOT set initdefault to this)

#

id:3:initdefault:

 

To change from a console to a graphical login, you should change the number in the line id:3:initdefault: from a 3 to a 5.

 

Warning

Change only the number of the default runlevel from 3 to 5.

Your changed line should look like the following:

id:5:initdefault:

When you are satisfied with your change, save and exit the file using the [Ctrl]-[x] keys. You will see a message telling you that the file has been modified, and asking you to confirm your change. Type [Y] for yes. Now, your next login after reboot will be from the graphical screen.