Ubuntu 101 - Starting Fast - Ubuntu Linux For Dummies (2007)

Ubuntu Linux For Dummies (2007)

Part I: Starting Fast

Chapter 5. Ubuntu 101

In This Chapter

· Introducing basic Linux concepts and systems

· Logging in to and out of Ubuntu

· Starting and stopping Ubuntu

The rest of this book shows how to use and master Ubuntu. Before proceeding, however, I'd like to introduce several essential Linux concepts and systems that will serve as an underpinning for the topics to come.

This chapter helps you get started with Ubuntu and the Linux operating system in general. I introduce the technologies underpinning Linux and Ubuntu; this information is essential to understanding how Ubuntu and computers in general work. I also describe the basics of using and operating your Ubuntu computer. This information gives you a working knowledge of fundamental Linux tools that will help you use the rest of this book.

Understanding the Linuxisms

The word Linux has different meanings, depending on the context in which it's referred to:

· Linux kernel: Linux is the operating system that controls everything you do on your Ubuntu computer; this is technically the Linux kernel. The Linux kernel controls who can use resources like memory, disk space, and time allocated on the central processing unit (CPU).

Linus Torvalds started writing the Linux kernel in 1991 because he wasn't satisfied with any of the operating systems he had access to. Early on, he released his work to the nascent Internet and immediately hit a nerve. The power of communication and the need for such an operating system resulted in many talented people helping to make the project a success. Linus also licensed his work under the GNU General Public License (GPL), which allowed people to use, modify, and distribute his work as long as they allowed others to do the same. Using the Internet and GPL, Linux quickly exploded into worldwide use and today is second only to Microsoft Windows in use.

· Linux distribution: Linux is also the overall system that consists of the Linux kernel and all the supporting systems. Ubuntu Linux is an example of this. Ubuntu is a Linux distribution that contains the Linux kernel, GNU applications, the Linux file system, a graphical environment, and many other subsystems.

· Multiuser: Linux is a multiuser operating system. People can share a Linux computer. You assign separate user accounts to each person, which limits one person from interfering with another.

· Multitasking: Linux is a multitasking operating system. You can run multiple programs at the same time.

Each program gets a slice of time to perform its task before being forced into the background, so that the next program in line can get its slice. Computers operate so quickly, however, that all processes appear to be running at once.

· GNU: GNU is a comprehensive and free operating system project that was started in 1983 by Richard Stallman. It consists of a kernel, system utilities, libraries, compilers, and system administration programs.

GNU is a recursive acronym for GNU's Not UNIX.

The kernel wasn't released until recently, but the other parts have been very widely used for decades. Linux wouldn't be a popular operating system today if not for GNU. Many people reasonably refer to GNU Linux when talking about Linux. That makes sense because Linux, as I just mentioned, originally was just the operating system kernel. When the Linux kernel was released in 1992, it was quickly combined with GNU software to create a usable operating system. However, the powerful forces of popular lexicon, branding, and pure inertia set using the single word Linux into place.

· GPL: The GNU General Public License (also referred to as the GNU Public License) was created by Richard Stallman. There are other similar licenses in use, but the GPL is their ancestor. GPL is the reason that Linux, Mozilla Firefox, and many other applications exist today.

Thinking about processes and programs

Processes are programs in motion, so to speak. A program is a sequence of instructions that perform some job or function. Everything you do on a computer is performed by a program.

Firefox, OpenOffice.org, and even Linux itself are all programs.

Programs are stored in files on the Linux file system (which is described in this chapter). When you run (or start) a program — for instance, click a program icon — Linux reads the contents of the program file into memory (RAM) and starts executing the instructions contained in the file.

Once the program is loaded and started, it's called a process and is controlled by the Linux kernel.

When you start a program, whether a complex one such as Mozilla Firefox or a relatively simple one such as GNOME calculator, the Linux kernel loads the contents of the corresponding program file into memory and starts running it. The program startup process — no pun intended, but I'll take it anyway — is more complicated than that, but that's the gist of it.

Getting to know the Linux file system

Everything that you use or save on a computer is stored as a file on disk drives of some sort. Programs are stored as files. Other types of information, such as word processing files, spreadsheets, and photographs, are stored as files, too. In fact, Linux organizes every resource (except network connections) as a file. All of these resources together are considered a file system.

Linux interacts with all devices as if they are files. For instance, your hard drive is viewed as the file /dev/hda or /dev/hdb. Each file is actually the IDE interface of the first and second hard drive, respectively.

Directory rules

Files are stored inside directories. Directories are actually files themselves whose sole purpose is to allow files to be logically organized.

Linux directories are like Windows folders.

There's no requirement that any particular files have to be located in any particular directories. However, all Linux computers adhere to conventions that provide these general organization rules:

· Directories can contain directories. There is no practical limit to the number of directories within directories.

· A directory that contains another directory is called the parent.

· The directory inside a directory is the child of the parent.

· The slash (/) character separates directories.

Microsoft Windows uses backslashes (\), rather than forward slashes (/), to separate directories.

· The root directory is the home location of all other directories.

· Root is designated by the first slash in any directory list. For instance, if you want to see the contents of the etcetera directory, where configuration files are stored, you type the command ls /etc at the command prompt. (See the "Using the Shell" section in this chapter for information about typing commands.) Using the slash character tells the command to look in the root directory for the etc directory. (Linux's root directory is equivalent to the Windows C:\ drive.)

· A path is a list of one or more directories. You specify a path when describing where to find a file or directory. For instance, the path to the file containing this chapter on my computer is /home/paul/doc/ulfd. Each directory — home, paul, doc, ulfd — is part of the path; the first slash (/) is the root directory.

You can see an example of a directory path by clicking the Places menu in the GNOME menu bar — towards the top-left side of the screen — and selecting the Desktop option. A window opens, showing the contents of your home folder (directory). You see the name of your home directory below the Up button, near the top-left side of the window. Click the left-facing arrow button immediately to the left of your home directory name. The window shows a series of buttons representing the directory path to your Desktop directory. The example shown in Figure 5-1 shows the directories leading to my Desktop directory: home, paul, Desktop.

Figure 5-1: The Desktop folder directory path.

Common directories

In the future, if and when you start to perform more Linux administration, it's useful to know what and where some of the common Linux directories are. The following list introduces the location and purpose of some of the common Linux directories; all of the directories are created and populated by default when you install Ubuntu (or run Ubuntu from a live CD-ROM):

· /boot Linux kernels and their supporting files. After you install Linux, you'll find the Linux kernel saved in /boot.

· /dev Device files. Physical devices are represented as files by the Linux kernel. The kernel reads and writes to devices through files contained in this directory. So is your hard drive, and if you have a printer or a USB memory disk connected to your computer, for example, you'll find a corresponding device file in this directory.

· /etc System configuration files. Files in this directory allow your computer to automatically use networking, printers, and other devices when they've been configured.

· /home User account directories. Your user account home directory, created during the installation process described in Chapter 4, lives here. For instance, if you created a user account called heidi during the Ubuntu installation, that account will have a home directory /home/heidi created for it.

· /proc A pseudo directory. This directory is not physically located on any disk drive but is a view into the Linux kernel itself. Linux allows you to view certain internal data structures, and in some cases, control them via files found here.

It isn't necessary to use the /proc file system unless you're performing very advanced system administration tasks. Ubuntu makes the everyday management of Ubuntu very easy by providing utilities that make it unnecessary to use the /proc file system.

· /tmp Temporary files that can be deleted after you've used them. For instance, there are many files that Linux creates to manage or facilitate running utilities and applications that are stored temporarily in this directory.

· /usr Additional directories that store system and application programs, libraries, and supporting files.

Libraries are small pieces of software — called subroutines or functions in programming speak — that perform simple, common tasks and are shared by multiple programs and applications. Programmers use libraries when writing an application so they don't have to "reinvent the wheel" every time they need to perform some common task; for instance, a Web browser and e-mail client application and word processor all use the same library function to read and write files on a Linux file system.

· /usr/bin User applications and utility programs. /usr/bin contains applications like the Firefox Web browser and Evolution e-mail/calendar, and utilities like the ls command. Most applications and utilities are stored here by default.

· /usr/sbin System applications and utility programs. /usr/sbin is similar to /usr/bin/, but it stores applications and utilities used for system administration. /usr/sbin is not accessible by users unless they use sudo to gain superuser privilege.

· /usr/local Third-party or user-supplied applications, utility programs, configuration files, databases, and so on. You typically use this directory structure to store applications and utilities that aren't part of the Ubuntu installation. For instance, if you download a beta version of Firefox, you should install it in /usr/local/bin so as not to overwrite the production version found in /usr/bin — and also to reduce confusion about what version resides where.

· /var Files that vary with time. This directory contains files that the operating system creates, deletes, reads, and writes to. For instance, when you print a document, a temporary file holding the formatted text gets written to the /var/spool directory. It's deleted when the print job finishes.

For instance, when you print a document, Linux creates an output file to send to the printer — but first it stores, temporarily, the output in /var/spool/lp. After the document is printed, Linux deletes the temporary file.

Differences between Linux and Windows

Linux files and directories are similar to Windows files and folders, but there are a few differences:

· Linux uses different names — forward slashes, backward ones, — but the concept is the same.

· The Linux root directory / is replaced by a drive symbol, such as the common C:\ drive.

· You also have to explicitly mount a file system to use it in Linux. Linux must mount a file system before it can start using the file system.

Linux has gotten very good at hiding such processes. For instance, plug your USB flash memory device into your Ubuntu computer, and you'll see a window showing its contents in a few seconds. Ubuntu detected and mounted the device without intervention.

Using the shell

Ubuntu provides a powerful and useful graphical interface. You can perform every type of task, such as finding and opening files and setting up network interfaces, using Ubuntu's graphics. (Chapters 6 through 21 describe using the Ubuntu graphical utilities and GNOME graphical interfaces.) However, Linux also provides a non-graphical and very powerful interface where you type commands at the keyboard instead of clicking a mouse. Microsoft Windows, as a matter of fact, is trying very hard to catch up with Linux and provide non-graphical commands.

Linux computers make extensive use of shells. Shells are programs that provide text-based user interfaces to the Linux operating system. When working in a shell, the user enters a command plus optional arguments, and the shell parses (separates the various parts of a command into usable parts) and then executes the command. Because shells are used to launch commands (programs), they're often referred to as the command line interface (CLI).

Shells provide both the platform to launch programs and a powerful programming environment. Any program that you interactively launch from a shell, you can also launch from a script — you create scripts to automate commands that you would normally manually type at the command line. Shells provide many of the functions you find in programming languages. You can put those functions into a file and you can execute that file like a program. This capability is so powerful that Microsoft has made a goal to make at least 90 percent of its GUI-based applications and utilities scriptable.

bash is the dominant shell in use today within the Linux world. Ubuntu uses bash as its default shell.

bash is a derivative of the Bourne shell and gets its acronym from that heritage — born again shell.

You open a shell using a Terminal Emulator in Ubuntu. A Terminal Emulator provides a window in which you type commands to a shell and receive output from the shell. Use the following steps to open a Terminal Emulator:

1. Click the Applications menu option at the top-left side of the screen.

2. Choose AccessoriesTerminal.

A window containing the bash shell opens, like the one shown in Figure 5-1 .

Figure 5-1: Tweak nervously opens the bash shell on his computer, ubby.

The shell is configured to create a prompt of the following:

· Your username.

· The computer name: The username and computer name are separated by an at (@) character.

· The directory you're working from: The computer name and directory are separated by a colon (:) character. (Your home directory is represented by the tilda (tilde) character.

The prompt is terminated with a dollar ($) character.

Anything you type at the prompt is interpreted as a command. Any results from executing the command are displayed on subsequent lines. For instance, type ls to get a directory listing, and you'll see any files that exist within your current working directory.

The bash shell and the MS-DOS window are similar in function. Both are interactive user interfaces from which you can execute commands. Here's the key technical difference:

· The bash shell (and Linux shells in general) only interprets your input. The shell feeds your input to the Linux kernel, which then executes the program and its arguments.

· MS-DOS contains the commands and does all the work itself.

Linux security

Linux was born into security. Unlike other operating systems that had to be dragged kicking and screaming into that world — and doing back-flips to get there — Linux inherited the UNIX operating system model where user and system address space. This model separates each user account from all others.

In the UNIX/Linux world, processes exist in either kernel space or user space:

· Kernel space processes can do anything. They can access and control all aspects of the computer.

· User space processes are limited by the kernel in what they can do and access.

By keeping user space separate from kernel space, Linux greatly limits the ability of viruses and malware from affecting your computer; other operating systems are still working hard to obtain the same level of security that Linux has always had.

Linux user accounts

Linux user accounts separate people's files and work from one another, ensuring a reasonable level of privacy to all people who use a computer.

Chapter 4 shows how to create a user account while installing Ubuntu.

Individual user accounts have two kinds of identifiers:

· UID: A unique identifier for a particular user account.

· GID: Group identifiers allow multiple users to share information.

All files created by a user inherit a unique UID and GID by default. Other users can't read or write to the files without changing access. However, you can add UID (or UIDs) to a group to allow the user or users specified by the UID (or UIDs) access to files and directories owned by the GID.

Log in, log out

As a user, you need to know how to enter and exit Ubuntu.

To start working from a user account, you must first log in to it. Logging in to a computer requires you to authenticate to the computer by entering your

· User account name (username, for short)

· Password

Logging in to Ubuntu is straightforward:

1. Type your username at the log in prompt.

2. Type your password when prompted.

The Ubuntu desktop, shown in Figure 5-1 , opens.

Figure 5-1: The Ubuntu desktop.

At this point, you can start and use any program.

sudo

The sudo (pronounced SUE-do) utility allows users to perform tasks as the superuser, who can read any file and perform almost any action. The Linux superuser is equivalent to the Microsoft Administrator.

Actions performed as the superuser (also called root) are also referred to as system-level tasks.

UID values

Linux processes with a UID of 0 are all powerful. UID 0 processes can read any file and perform almost any action. User accounts are given nonzero UIDs to limit invasion of other users' privacy and limit the damage users can intentionally or unintentionally wreak.

Ubuntu user accounts have UIDs of 1,000 or above by default.

The root user (also known as the superuser) has a UID of 0. root is all-powerful and should be limited to experienced system administrators.

Unlike most Linux distributions, Ubuntu doesn't configure a superuser; it exists but doesn't have a password, and can't be directly logged in to. Users are given access to root-level privileges on a case-by-case basis, so to speak.

You can find out what your UID is by typing the id command in a Terminal Emulator window. (Click the GNOME menu bar and select ApplicationsAccessoriesTerminal to open a Terminal Emulator window.)

A user can perform a system-level task only if sudo is configured appropriately. For example, if sudo is configured to allow you to add a user account, you'd type the following command to create the new user account named tweak:

sudo useradd tweak

sudo prompts you for your password and then performs the task for you.

Using sudo has several advantages:

· You can configure access to system-level tasks in a very precise way.

· It enforces good administrative hygiene by forcing you to think a little about every system-level task you perform.

· It records what every user does, which makes it easy to assign blame!

The traditional way of performing system-level tasks is to log in as root (superuser) and go to town. However, this makes it easy to make mistakes that can have disastrous effects — such as erasing files you don't want to erase. For instance, typing rm -rf / as root erases your entire disk. It's much more difficult to perform such a task when you have to use sudo — typing sudo rm -rf / makes you think more about what you're doing because you first have to type sudo before typing rm -rf /. By encouraging the use of sudo, and discouraging operating as root, Ubuntu reduces the possibility of making mistakes.

Chapter 5. Ubuntu 101

In This Chapter

· Introducing basic Linux concepts and systems

· Logging in to and out of Ubuntu

· Starting and stopping Ubuntu

The rest of this book shows how to use and master Ubuntu. Before proceeding, however, I'd like to introduce several essential Linux concepts and systems that will serve as an underpinning for the topics to come.

This chapter helps you get started with Ubuntu and the Linux operating system in general. I introduce the technologies underpinning Linux and Ubuntu; this information is essential to understanding how Ubuntu and computers in general work. I also describe the basics of using and operating your Ubuntu computer. This information gives you a working knowledge of fundamental Linux tools that will help you use the rest of this book.

Understanding the Linuxisms

The word Linux has different meanings, depending on the context in which it's referred to:

· Linux kernel: Linux is the operating system that controls everything you do on your Ubuntu computer; this is technically the Linux kernel. The Linux kernel controls who can use resources like memory, disk space, and time allocated on the central processing unit (CPU).

Linus Torvalds started writing the Linux kernel in 1991 because he wasn't satisfied with any of the operating systems he had access to. Early on, he released his work to the nascent Internet and immediately hit a nerve. The power of communication and the need for such an operating system resulted in many talented people helping to make the project a success. Linus also licensed his work under the GNU General Public License (GPL), which allowed people to use, modify, and distribute his work as long as they allowed others to do the same. Using the Internet and GPL, Linux quickly exploded into worldwide use and today is second only to Microsoft Windows in use.

· Linux distribution: Linux is also the overall system that consists of the Linux kernel and all the supporting systems. Ubuntu Linux is an example of this. Ubuntu is a Linux distribution that contains the Linux kernel, GNU applications, the Linux file system, a graphical environment, and many other subsystems.

· Multiuser: Linux is a multiuser operating system. People can share a Linux computer. You assign separate user accounts to each person, which limits one person from interfering with another.

· Multitasking: Linux is a multitasking operating system. You can run multiple programs at the same time.

Each program gets a slice of time to perform its task before being forced into the background, so that the next program in line can get its slice. Computers operate so quickly, however, that all processes appear to be running at once.

· GNU: GNU is a comprehensive and free operating system project that was started in 1983 by Richard Stallman. It consists of a kernel, system utilities, libraries, compilers, and system administration programs.

GNU is a recursive acronym for GNU's Not UNIX.

The kernel wasn't released until recently, but the other parts have been very widely used for decades. Linux wouldn't be a popular operating system today if not for GNU. Many people reasonably refer to GNU Linux when talking about Linux. That makes sense because Linux, as I just mentioned, originally was just the operating system kernel. When the Linux kernel was released in 1992, it was quickly combined with GNU software to create a usable operating system. However, the powerful forces of popular lexicon, branding, and pure inertia set using the single word Linux into place.

· GPL: The GNU General Public License (also referred to as the GNU Public License) was created by Richard Stallman. There are other similar licenses in use, but the GPL is their ancestor. GPL is the reason that Linux, Mozilla Firefox, and many other applications exist today.

Thinking about processes and programs

Processes are programs in motion, so to speak. A program is a sequence of instructions that perform some job or function. Everything you do on a computer is performed by a program.

Firefox, OpenOffice.org, and even Linux itself are all programs.

Programs are stored in files on the Linux file system (which is described in this chapter). When you run (or start) a program — for instance, click a program icon — Linux reads the contents of the program file into memory (RAM) and starts executing the instructions contained in the file.

Once the program is loaded and started, it's called a process and is controlled by the Linux kernel.

When you start a program, whether a complex one such as Mozilla Firefox or a relatively simple one such as GNOME calculator, the Linux kernel loads the contents of the corresponding program file into memory and starts running it. The program startup process — no pun intended, but I'll take it anyway — is more complicated than that, but that's the gist of it.

Getting to know the Linux file system

Everything that you use or save on a computer is stored as a file on disk drives of some sort. Programs are stored as files. Other types of information, such as word processing files, spreadsheets, and photographs, are stored as files, too. In fact, Linux organizes every resource (except network connections) as a file. All of these resources together are considered a file system.

Linux interacts with all devices as if they are files. For instance, your hard drive is viewed as the file /dev/hda or /dev/hdb. Each file is actually the IDE interface of the first and second hard drive, respectively.

Directory rules

Files are stored inside directories. Directories are actually files themselves whose sole purpose is to allow files to be logically organized.

Linux directories are like Windows folders.

There's no requirement that any particular files have to be located in any particular directories. However, all Linux computers adhere to conventions that provide these general organization rules:

· Directories can contain directories. There is no practical limit to the number of directories within directories.

· A directory that contains another directory is called the parent.

· The directory inside a directory is the child of the parent.

· The slash (/) character separates directories.

Microsoft Windows uses backslashes (\), rather than forward slashes (/), to separate directories.

· The root directory is the home location of all other directories.

· Root is designated by the first slash in any directory list. For instance, if you want to see the contents of the etcetera directory, where configuration files are stored, you type the command ls /etc at the command prompt. (See the "Using the Shell" section in this chapter for information about typing commands.) Using the slash character tells the command to look in the root directory for the etc directory. (Linux's root directory is equivalent to the Windows C:\ drive.)

· A path is a list of one or more directories. You specify a path when describing where to find a file or directory. For instance, the path to the file containing this chapter on my computer is /home/paul/doc/ulfd. Each directory — home, paul, doc, ulfd — is part of the path; the first slash (/) is the root directory.

You can see an example of a directory path by clicking the Places menu in the GNOME menu bar — towards the top-left side of the screen — and selecting the Desktop option. A window opens, showing the contents of your home folder (directory). You see the name of your home directory below the Up button, near the top-left side of the window. Click the left-facing arrow button immediately to the left of your home directory name. The window shows a series of buttons representing the directory path to your Desktop directory. The example shown in Figure 5-1 shows the directories leading to my Desktop directory: home, paul, Desktop.

Figure 5-1: The Desktop folder directory path.

Common directories

In the future, if and when you start to perform more Linux administration, it's useful to know what and where some of the common Linux directories are. The following list introduces the location and purpose of some of the common Linux directories; all of the directories are created and populated by default when you install Ubuntu (or run Ubuntu from a live CD-ROM):

· /boot Linux kernels and their supporting files. After you install Linux, you'll find the Linux kernel saved in /boot.

· /dev Device files. Physical devices are represented as files by the Linux kernel. The kernel reads and writes to devices through files contained in this directory. So is your hard drive, and if you have a printer or a USB memory disk connected to your computer, for example, you'll find a corresponding device file in this directory.

· /etc System configuration files. Files in this directory allow your computer to automatically use networking, printers, and other devices when they've been configured.

· /home User account directories. Your user account home directory, created during the installation process described in Chapter 4, lives here. For instance, if you created a user account called heidi during the Ubuntu installation, that account will have a home directory /home/heidi created for it.

· /proc A pseudo directory. This directory is not physically located on any disk drive but is a view into the Linux kernel itself. Linux allows you to view certain internal data structures, and in some cases, control them via files found here.

It isn't necessary to use the /proc file system unless you're performing very advanced system administration tasks. Ubuntu makes the everyday management of Ubuntu very easy by providing utilities that make it unnecessary to use the /proc file system.

· /tmp Temporary files that can be deleted after you've used them. For instance, there are many files that Linux creates to manage or facilitate running utilities and applications that are stored temporarily in this directory.

· /usr Additional directories that store system and application programs, libraries, and supporting files.

Libraries are small pieces of software — called subroutines or functions in programming speak — that perform simple, common tasks and are shared by multiple programs and applications. Programmers use libraries when writing an application so they don't have to "reinvent the wheel" every time they need to perform some common task; for instance, a Web browser and e-mail client application and word processor all use the same library function to read and write files on a Linux file system.

· /usr/bin User applications and utility programs. /usr/bin contains applications like the Firefox Web browser and Evolution e-mail/calendar, and utilities like the ls command. Most applications and utilities are stored here by default.

· /usr/sbin System applications and utility programs. /usr/sbin is similar to /usr/bin/, but it stores applications and utilities used for system administration. /usr/sbin is not accessible by users unless they use sudo to gain superuser privilege.

· /usr/local Third-party or user-supplied applications, utility programs, configuration files, databases, and so on. You typically use this directory structure to store applications and utilities that aren't part of the Ubuntu installation. For instance, if you download a beta version of Firefox, you should install it in /usr/local/bin so as not to overwrite the production version found in /usr/bin — and also to reduce confusion about what version resides where.

· /var Files that vary with time. This directory contains files that the operating system creates, deletes, reads, and writes to. For instance, when you print a document, a temporary file holding the formatted text gets written to the /var/spool directory. It's deleted when the print job finishes.

For instance, when you print a document, Linux creates an output file to send to the printer — but first it stores, temporarily, the output in /var/spool/lp. After the document is printed, Linux deletes the temporary file.

Differences between Linux and Windows

Linux files and directories are similar to Windows files and folders, but there are a few differences:

· Linux uses different names — forward slashes, backward ones, — but the concept is the same.

· The Linux root directory / is replaced by a drive symbol, such as the common C:\ drive.

· You also have to explicitly mount a file system to use it in Linux. Linux must mount a file system before it can start using the file system.

Linux has gotten very good at hiding such processes. For instance, plug your USB flash memory device into your Ubuntu computer, and you'll see a window showing its contents in a few seconds. Ubuntu detected and mounted the device without intervention.

Using the shell

Ubuntu provides a powerful and useful graphical interface. You can perform every type of task, such as finding and opening files and setting up network interfaces, using Ubuntu's graphics. (Chapters 6 through 21 describe using the Ubuntu graphical utilities and GNOME graphical interfaces.) However, Linux also provides a non-graphical and very powerful interface where you type commands at the keyboard instead of clicking a mouse. Microsoft Windows, as a matter of fact, is trying very hard to catch up with Linux and provide non-graphical commands.

Linux computers make extensive use of shells. Shells are programs that provide text-based user interfaces to the Linux operating system. When working in a shell, the user enters a command plus optional arguments, and the shell parses (separates the various parts of a command into usable parts) and then executes the command. Because shells are used to launch commands (programs), they're often referred to as the command line interface (CLI).

Shells provide both the platform to launch programs and a powerful programming environment. Any program that you interactively launch from a shell, you can also launch from a script — you create scripts to automate commands that you would normally manually type at the command line. Shells provide many of the functions you find in programming languages. You can put those functions into a file and you can execute that file like a program. This capability is so powerful that Microsoft has made a goal to make at least 90 percent of its GUI-based applications and utilities scriptable.

bash is the dominant shell in use today within the Linux world. Ubuntu uses bash as its default shell.

bash is a derivative of the Bourne shell and gets its acronym from that heritage — born again shell.

You open a shell using a Terminal Emulator in Ubuntu. A Terminal Emulator provides a window in which you type commands to a shell and receive output from the shell. Use the following steps to open a Terminal Emulator:

1. Click the Applications menu option at the top-left side of the screen.

2. Choose AccessoriesTerminal.

A window containing the bash shell opens, like the one shown in Figure 5-1 .

Figure 5-1: Tweak nervously opens the bash shell on his computer, ubby.

The shell is configured to create a prompt of the following:

· Your username.

· The computer name: The username and computer name are separated by an at (@) character.

· The directory you're working from: The computer name and directory are separated by a colon (:) character. (Your home directory is represented by the tilda (tilde) character.

The prompt is terminated with a dollar ($) character.

Anything you type at the prompt is interpreted as a command. Any results from executing the command are displayed on subsequent lines. For instance, type ls to get a directory listing, and you'll see any files that exist within your current working directory.

The bash shell and the MS-DOS window are similar in function. Both are interactive user interfaces from which you can execute commands. Here's the key technical difference:

· The bash shell (and Linux shells in general) only interprets your input. The shell feeds your input to the Linux kernel, which then executes the program and its arguments.

· MS-DOS contains the commands and does all the work itself.

Linux security

Linux was born into security. Unlike other operating systems that had to be dragged kicking and screaming into that world — and doing back-flips to get there — Linux inherited the UNIX operating system model where user and system address space. This model separates each user account from all others.

In the UNIX/Linux world, processes exist in either kernel space or user space:

· Kernel space processes can do anything. They can access and control all aspects of the computer.

· User space processes are limited by the kernel in what they can do and access.

By keeping user space separate from kernel space, Linux greatly limits the ability of viruses and malware from affecting your computer; other operating systems are still working hard to obtain the same level of security that Linux has always had.

Linux user accounts

Linux user accounts separate people's files and work from one another, ensuring a reasonable level of privacy to all people who use a computer.

Chapter 4 shows how to create a user account while installing Ubuntu.

Individual user accounts have two kinds of identifiers:

· UID: A unique identifier for a particular user account.

· GID: Group identifiers allow multiple users to share information.

All files created by a user inherit a unique UID and GID by default. Other users can't read or write to the files without changing access. However, you can add UID (or UIDs) to a group to allow the user or users specified by the UID (or UIDs) access to files and directories owned by the GID.

Log in, log out

As a user, you need to know how to enter and exit Ubuntu.

To start working from a user account, you must first log in to it. Logging in to a computer requires you to authenticate to the computer by entering your

· User account name (username, for short)

· Password

Logging in to Ubuntu is straightforward:

1. Type your username at the log in prompt.

2. Type your password when prompted.

The Ubuntu desktop, shown in Figure 5-1 , opens.

Figure 5-1: The Ubuntu desktop.

At this point, you can start and use any program.

sudo

The sudo (pronounced SUE-do) utility allows users to perform tasks as the superuser, who can read any file and perform almost any action. The Linux superuser is equivalent to the Microsoft Administrator.

Actions performed as the superuser (also called root) are also referred to as system-level tasks.

UID values

Linux processes with a UID of 0 are all powerful. UID 0 processes can read any file and perform almost any action. User accounts are given nonzero UIDs to limit invasion of other users' privacy and limit the damage users can intentionally or unintentionally wreak.

Ubuntu user accounts have UIDs of 1,000 or above by default.

The root user (also known as the superuser) has a UID of 0. root is all-powerful and should be limited to experienced system administrators.

Unlike most Linux distributions, Ubuntu doesn't configure a superuser; it exists but doesn't have a password, and can't be directly logged in to. Users are given access to root-level privileges on a case-by-case basis, so to speak.

You can find out what your UID is by typing the id command in a Terminal Emulator window. (Click the GNOME menu bar and select ApplicationsAccessoriesTerminal to open a Terminal Emulator window.)

A user can perform a system-level task only if sudo is configured appropriately. For example, if sudo is configured to allow you to add a user account, you'd type the following command to create the new user account named tweak:

sudo useradd tweak

sudo prompts you for your password and then performs the task for you.

Using sudo has several advantages:

· You can configure access to system-level tasks in a very precise way.

· It enforces good administrative hygiene by forcing you to think a little about every system-level task you perform.

· It records what every user does, which makes it easy to assign blame!

The traditional way of performing system-level tasks is to log in as root (superuser) and go to town. However, this makes it easy to make mistakes that can have disastrous effects — such as erasing files you don't want to erase. For instance, typing rm -rf / as root erases your entire disk. It's much more difficult to perform such a task when you have to use sudo — typing sudo rm -rf / makes you think more about what you're doing because you first have to type sudo before typing rm -rf /. By encouraging the use of sudo, and discouraging operating as root, Ubuntu reduces the possibility of making mistakes.

Starting and Stopping Ubuntu

Starting and stopping a computer is a simple process. However, there are good ways to do so and bad ways, too. This section describes the correct startup and shutdown methods.

Booting

Booting a computer refers to the process of starting it by turning on the power. Rebooting means to restart the computer by telling the operating system to first gracefully stop, and then restart itself.

Generally, you shouldn't reboot a computer by turning the power off and then on.

Choosing from the options that stop your computer

There comes a time when all good things must come to an end — even if for a short time. When you stop using your computer, Ubuntu provides several options to save power and protect your data. To access these options, choose SystemQuit from the GNOME menu bar. Or you can simply click the red Quit button in the upper-right corner of the screen.

Let Ubuntu do it

These are not good ideas, but you could just push and hold the power button until the power is cut off. Or you could just pull the power cord to turn a computer off. The reason you don't want to use those ways to turn your computer off is that suddenly shutting off power stops everything that's going on in your computer instantaneously:

· Applications and processes stop in mid-read or mid-write and possibly lose information.

· The file system also is stopped in mid-read or mid-write and loses its internal organization. (Sometimes you can fix this while rebooting, but sometimes you can't.)

Either way, the Quit dialog opens, with these options:

· Shut Down: Gracefully ends all activity and turns the power off. Good night, Irene.

Your graphical desktop disappears, and Ubuntu lists the systems that it's shutting down. After Ubuntu finishes shutting down its systems, you're prompted to press the Enter key to finish the process. Press the Enter key, and your computer shuts down and turns itself off.

· Restart: Gracefully ends all activity and then restarts your computer processor and memory and loads Ubuntu. You can use the computer with a clean slate.

Your computer shuts itself down — stopping all programs, applications, and services, and unmounting (making the file partitions unavailable to Ubuntu) all devices — and then starts itself up.

· Log Out: Closes your desktop and all programs running from it.

After logging out, Ubuntu continues to run, but you have to log in again to start using it.

· Lock Screen: Prevents anyone who doesn't have your password from unlocking the screen.

· Switch User: You log in as another user using this option but continue to run the applications you were running as the original user. You can log in — switch back — to the previous user login and pick up where you left off.

· Suspend: Remembers your computer's current state, but uses almost no power. Your screen goes blank and you hear your hard drive and fans turn off. The power button on your computer box and monitor flash periodically so you know you're in suspend mode. Pressing a key or moving the mouse wakes the computer in a few seconds.

You can save time and money by making use of the Suspend feature. Suspending puts your computer into a state that requires very little energy; the side benefit is that it's also very quiet.

If your computer loses power while it's suspended, it's just like when you lose power while you're working. The computer reboots, and you lose any work that wasn't saved. If you don't want to risk losing your work while suspended, use the Hibernate option instead.

· Hibernate: Remembers your computer's current state and gracefully shuts down. Your computer doesn't use any power. This option works whether you're running from a live Ubuntu disc or from Ubuntu installed on your hard drive.

When the computer hibernates, it first saves its state (the contents of its memory and the CPU) to its hard drive. Then, unlike suspension, it completely shuts itself off. The CPU doesn't continue to operate in any fashion, nor does the monitor or computer power switch flash periodically; they can't — the computer is off.

Hibernation will survive a power outage.

To wake the slumbering beast, you must press the power button. The computer initially looks like it's doing a normal startup: You see the BIOS access instructions display, and then Ubuntu shows its startup sequence.

However, rather than continue through the entire startup process, Ubuntu sees the hibernation state file on the hard drive and reloads it. This process short-circuits and speeds the rest of the boot sequence.

You can program your computer to suspend itself automatically.

To automatically suspend your computer whenever it's unused for a period of time, follow these steps:

1. Click the GNOME Main Menu and choose SystemPreferencesPower Management.

The Power Management Preferences dialog opens, with the Put Computer to Sleep when It Is Inactive For slider set to the default, Never.

2. Click the slider and move it to the time after which the computer will go to sleep.

The time can be between one minute and one hour.

3. Click OK.

It's easy to wake up Ubuntu when it's suspended. Follow these steps:

1. Press a key or move the mouse.

You'll hear your computer start to wake up. It should take only 10 to 15 seconds to be back up and running.

Many laptops wake up when you open them.

2. Enter your password when prompted.

You're prompted for the password of the user account last in use when the computer was suspended. After you correctly enter the password, you see everything as it was before suspension.





All materials on the site are licensed Creative Commons Attribution-Sharealike 3.0 Unported CC BY-SA 3.0 & GNU Free Documentation License (GFDL)

If you are the copyright holder of any material contained on our site and intend to remove it, please contact our site administrator for approval.

© 2016-2024 All site design rights belong to S.Y.A.