Getting Started

  1. What is Linux and Why We Use It
  2. Purpose of this Guide
  3. SSH and LinuxLab
  4. Windows Subsystem for Linux
  5. Installing Linux with Virtualbox
  6. Do not fear the CLI

Chapter1.Getting started with Linux

Table of Contents

1.1. User interfaces in Linux: graphical and command line

1.2. Graphical user interfaces (GUIs) for Linux

1.3. Accessing the Linux CLI through a GUI's terminal window

1.4. Shells, the shell prompt, and your home directory

1.5. Key differences between Windows/Mac OS X and Linux

1.6. Understanding the tables of commands and options

This chapter provides some background information on user interfaces in Linux.

The most important information is the orientation to the command line in Section1.3, ā€œAccessing the Linux CLI through a GUI's terminal windowā€ and the sections that follow.

References to further reading on Linux can be found in SectionA.2, ā€œMore on Linuxā€.

1.1.User interfaces in Linux: graphical and command line

Tip

If you're using SSH,[2] you can skip to Section1.4, ā€œShells, the shell prompt, and your home directoryā€.

Recall that graphical applications are unavailable while you're using SSH, unless you're using X tunneling.[3]

Fundamentally, there are two different ways to work with the Linux operating system:

  • through a graphical user interface (GUI),[5] in which the user uses a mouse to manipulate windows.

  • through the command line interface (CLI),[6] in which the user types commands at a prompt.

As suggested by the title, this guide focuses on the use of the CLI.

Discussion of GUIs is restricted to Section1.2, ā€œGraphical user interfaces (GUIs) for Linuxā€, Section1.3, ā€œAccessing the Linux CLI through a GUI's terminal windowā€, and AppendixB, Graphical alternatives.

1.2.Graphical user interfaces (GUIs) for Linux[7]

If your primary use of Linux is not via an SSH connection,[2] your first experience with Linux will probably be with a graphical user interface called a desktop environment,[8] which is often used in place of the lower-level command line-based approach.

There are two particularly popular desktop environments for Linux:[9]

  • GNOME (in which the menus are located at the top of the screen)

  • KDE or the K Desktop Environment (in which the K menu is located in the lower-left corner of the screen)

As explained in the next section, even if you're using a GUI, you can still access the CLI.


[7] All of these GUIs use the X Window System (also called X) as their underlying windowing system. Wikipedia has an article that surveys the window managers that are compatible with X, as well as an article about X itself.

[8] Instead of a desktop environment, the GUI in use could be a window manager, such as Fluxbox or Enlightenment. A discussion of window managers is beyond the scope of this guide, although Wikipedia has an article about them. Note that one component of a desktop environment is a window manager, as Wikipedia's article on desktop environments explains.

[9] While the Xfce desktop environment is also commonly used, it's not as widespread as GNOME and KDE, so this guide doesn't cover it.

1.3.Accessing the Linux CLI through a GUI's terminal window

When you're using a GUI (in our case, a desktop environment), you can access the CLI through a terminal window, or terminal.

The procedure for bringing up a terminal varies depending on which desktop environment you are using.[10]

  • If you're using GNOME, select the Applications menu from the top of the screen, then the Accessories submenu, then the Terminal application.

    You can also press Alt-F2 and type gnome-terminal at the prompt.

  • If you're using KDE, select the K menu from the lower-left corner of the screen, then the System menu, then the Konsole application.

    You can also press Alt-F2 and type konsole at the prompt.

  • If you're using a desktop environment other than GNOME or KDE, you'll need to consult the documentation for that environment.


[10] Desktop environments, including GNOME and KDE, are discussed in Section1.2, ā€œGraphical user interfaces (GUIs) for Linuxā€.

1.4.Shells, the shell prompt, and your home directory

Once you open a terminal (or connect to a server via secure shell [SSH]),[2] you type in commands to interact with a program known as a shell.[11] Although GNU Bash (the Bourne Again Shell) is the most popular shell for Linux, some Linux servers and the computers in some Linux computer labs use tcsh as the default shell.[12] If you're interested in trying the Bash shell, see SectionA.3.2, ā€œChanging your shell temporarily to Bashā€.

Once the shell starts up, youā€™ll see the shell prompt, which indicates that the shell is ready for you to type a command.

Here is the prompt that I see when I log in to the CEC's grid server: [jg18@grid ~]$

Thus, the format being used is: [username@host_machine current_directory]$

In addition, your current directory will initially be your home directory,[13] as is indicated by the tilde (~) in the prompt above.[14]


[11] The shell is covered in depth in Chapter3, Basic shell commands and related utilities.

[12] For learning more about tcsh, Wikipedia's article might be informative. You can also learn more by typing man tcsh, using the manual (man) pages that you'll learn about in Section2.1, ā€œManual ("man") pagesā€.

[13] Like the C:\Documents and Settings\Your Username directory in Windows or the /Users/Your_Username directory in Mac OS X, your home directory in Linux stores your personal files and settings. If you're a student, your home directory is probably the top-level directory for the long-term disk space (that is, not your "roaming profile") that your school allocates for your use.

[14] The symbol ~ is listed in Table3.2, ā€œCommon symbols from the file systemā€.

1.5.Key differences between Windows/Mac OS X and Linux

Before you start working with the Linux CLI, you should be aware of some important differences between Linux and operating systems with which you're more familiar.

Unlike Windows or Mac OS X, Linux has a case-sensitive file system. This means that home, Home, and HOME would all be names for different directories. Similarly, as you will see in Section3.2, ā€œNavigating the file systemā€, you type cd to change directories: typing CD or Cd instead will not work.

When you're working with the CLI, youā€™ll soon discover what Eric Raymond calls the ā€œRule of Silence: When a program has nothing surprising to say, it should say nothing.ā€[15] When a command finishes running (say, if you create a directory foo using mkdir), there will be no confirmation message of something like

directory ā€˜fooā€™ created

Rather, there will only be a message if thereā€™s a problem, as in

mkdir: cannot create directory `foo': File exists

Although you might use spaces in file and directory names in Windows or Mac OS X (such as Paper due tomorrow.doc), don't use spaces in file or directory names in Linux. Use underscores (the _ character, usually on the same key as -) in a file or directory name (such as Paper_due_tomorrow.doc) instead of spaces. In fact, it's best if the only characters that you use in file and directory names are letters, numbers, hyphens (-), underscores (_), and periods (.), although you shouldn't start a file or directory name with a period, since, as noted in Section3.2, ā€œNavigating the file systemā€, doing so makes the file or directory hidden.

When you use a command that would make some permanent change in the file system (such as deleting files or renaming a file such that it would replace a pre-existing file), the system will not ask you

Are you sure?

You will only be prompted for confirmation if you explicitly ask for it, such as by using the -i command option that is mentioned in Table3.3, ā€œCommands for manipulating the file systemā€.

Similarly, the Linux CLI has no Trash or Recycle Bin for files that you decide to delete but might want to restore later. Deleted files are simply deleted.


[15] From Eric Raymond's The Art of Unix Programming (Boston: Addison-Wesley, 2003). Found online at http://www.catb.org/~esr/writings/taoup/html/ch01s06.html#id2878450.

1.6.Understanding the tables of commands and options

Throughout this guide are tables summarizing many of the most commonly used Linux commands and command options. Most table entries, like the one in the example below, follow a format similar to that used by Linux's built-in manual pages.[16] Some table entries, such as those found in Section5.2, ā€œGNU Emacsā€, use a different format, although the differences are explained where relevant.

Since most commands have many options available, only a few options will be listed. To view all options for a given command, check the command's manual page.[16] Square brackets (that is, []) around an item indicate that it's an optional argument for the command.


Example1.1.How to read a table entry

Given the command synopsis

ls [-a] [-l] [path]

ls is the command, -a and -l are some of the options available for ls, and path is an optional argument for ls.


[16] Manual pages are discussed in Section2.1, ā€œManual ("man") pagesā€.


[5] See the Wikipedia article on GUIs to learn more.

[6] See the Wikipedia article on the CLI to learn more.