* Make a list of the programs you run as an ordinary user, including everything from a calculator applet to a major office suite. Look for equivalents at http://www.linuxrsp.ru/win-lin-soft/table-eng or http://www.linuxalt.com. Is there anything you can't find? If so, try a Web search to find an equivalent.
* Read more about two or three Linux distributions by perusing their Web pages. Which distribution would you select for running a major Web server? Which distribution sounds most appealing for use by office workers who do word processing and email?
## Review Questions
1. Which of the following is **not** a function of the Linux kernel?
* Read the Features Web page on FreeBSD, http://www.freebsd.org/features.html, a competitor to Linux. How would you say it differs from Linux?
* Research the features of two or three open source programs that interest you, such as Apache, LibreOffice, and Mozilla Firefox. Do the feature lists seem complete? Are there features missing that are present in commercial counterparts?
* Look up the GPLv2, GPLv3, and BSD 2-clause licenses. http://www.opensource.org/licenses/ is a good place to find them all.) Read them and compare them. Which would you use if you were to write an open source program?
* Read the OSI mission statement (three paragraphs at the top of its main Web page at http://www.opensource.org and the "Our Core Work" section of the FSF's "About" page http://www.fsf.org/about/.
## Review Questions
1. Which of the following is **not** required in order for software to be certified as open source?
4. True or false: Copyright law governs the distribution of software in most countries.
5. True or false: The FSF's free software definition and the OSI's ten principles of open source software both require that users have the ability to examine a program's workings---that is, its source code.
6. True or false: Because their hardware designs are proprietary, hardware vendors cannot release open source drivers for their products.
7. A license created by the FSF and often used for libraries is the `____________`.
8. An organization devoted to promoting open source-like principles in fields such as video and audio recordings is the `____________`.
9. The FSF's general principles are summarized by the term `____________` which refers to using copyright laws for purposes that are in some ways contrary to copyright's original intent.
* Try at least two different desktop environments. Use each desktop environment for your normal computing tasks for a day or two so that you can decide which you prefer.
* Try at least two different Linux Web browsers. Use each to visit your favorite Web sites. Do you notice differences in speed or how the elements on the page are laid out? Which do you prefer?
## Review Questions
1. Which of the following are Linux desktop environments? (Select all that apply.)
2. If you want to enable one Linux computer to access files stored on another Linux computer's hard disk, which of the following network protocols is the *best* choice?
* At a Linux shell prompt, type `uname -a`, `lscpu`, and `cat /proc/cpuinfo` [Compare the output and try to determine your CPU's capabilities. In particular, can it run 64-bit applications, and is your current distribution a 32-bit or 64-bit distribution?
* After you've logged into your preferred desktop environment, insert an optical disc, a USB flash drive, or some other removable disk. Does a file browser open up? If not, open one manually and try to find your removable disk. Once you've accessed the disk, unmount it so that you can safely remove it.
## Review Questions
1. Which of the following commands provides the most information about your motherboard's features?
* Read the `man` pages for the following commands: `man`, `less`, `cat`, `cd`, `ls`, `grep` and `su`.
* Launch a GUI program, such as `gedit`, with and without a trailing ampersand `&`. When you launch it without an ampersand, use Ctrl+Z to put it into the background and see how the program reacts to mouse clicks. Use `fg` to return it to the foreground, then repeat the process but use `bg` to run the program in the background. See what happens in your terminal when you exit from the GUI program.
* In a shell, type a single letter, such as `m`, and press the Tab key. What happens? What happens if you type a less common letter, such as `z`, and then press Tab?
* Experiment with the command history. Use it to search on strings that are part of both command names and filenames you've used.
## Review Questions
1. What keystroke moves the cursor to the start of the line when typing a command in Bash?
* Create a file with `touch` (or some other program) and then practice copying it with `cp`, renaming it with `mv`, moving it to another directory with `mv` and deleting it with `rm`.
* Create a directory with `mkdir` and then practice using `cp`, `mv` and `rm` on it, just as with files. Try copying files into it and then try deleting the directory with both `rmdir` and `rm`. Do both commands work?
## Review Questions
1. Which of the following commands would you type to rename `newfile.txt` to `file.txt`?
3. You type `mkdir one/two/three` and receive an error message that reads, in part, `No such file or directory`. What can you do to overcome this problem? (Select all that apply.)
4. True or false: You can create a symbolic link from one low-level filesystem to another.
5. True or false: You can easily damage your Linux installation by mistyping an `rm` command when you log into your regular account.
6. True or false: You can set a directory's time stamps with the `touch` command.
7. You want to copy a file `origfile.txt` to the `backups` directory, but if a file called `origfile.txt` exists in the `backups` directory, you want to go ahead with the copy only if the file in the source location is newer than the one in `backups`. The command to do this is `cp ____________ origfile.txt backups/`.
8. You've typed `rmdir junk` to delete the `junk` directory, but this command has failed because `junk` contains word processing files. What command might you type to do the job?
9. Which wildcard character matches any one symbol in a filename?
* Fully read at least three `man` pages for common Linux commands, such as `ls`, `cp`, `cat`, or `less`. What have you learned about these commands that goes beyond the descriptions in this book?
* Search `/usr/share/doc` for documentation on important programs you use frequently, such as the GIMP, Firefox, or GNOME.
* Check your distribution's Web site, or do a Web search, to find a Web forum supporting your distribution. Read some of the discussion threads to get a feel for some of the topics that come up.
## Review Questions
1. Which of the following commands is an improved version of `more`?
4. True or false: You can force `man` to display a `man` page in a specific section of the manual by preceding the search name with the section number, as in `man 5 passwd`.
5. True or false: `info` pages are a Web-based documentation format.
6. True or false: Linux documentation in the `/usr/share/doc` directory tree is almost always in OpenDocument Text format.
7. File formats are described in `man` section `____________`.
8. Each document in an `info` page is known as a(n) `____________`.
9. The `____________` command searches a database of filenames, enabling you to quickly identify files whose names match a term you specify.
* Is your distribution's software up to date? Locate the option in your desktop environment's menus to run a package manager and check that the system is up to date. A computer running out-of-date software can be vulnerable to bugs and security threats, so keeping your software updated is important!
* Type `ps ax | less` and browse through the process list. You might not recognize many of the processes, but some should be familiar. Try using `man` or a Web search to learn more about some of the processes you don't recognize.
## Review Questions
1. Which of the following tools is best suited to installing a software package and all its dependencies on a Debian computer?
4. True or false: When using suitable commands, you can normally install a program and be sure that all the software on which it depends will also be installed, provided you have an Internet connection.
5. True or false: By default, the first process listed in `top` is currently consuming the most CPU time.
6. True or false: The `dmesg` command may produce different output after a computer has been running for weeks than when it first started.
7. Most Linux distributions maintain information on what packages are installed in the `____________``____________`. (Two words.)
8. You're using `bash`, and you type `emacs` to launch the `emacs` editor. In this case, `emacs` is `bash`'s `____________`.
9. General system messages are likely to be found in `/var/log/messages` or `/var/log/____________` depending on your distribution.
# Chapter 10
*Searching, Extracting, and Archiving Data*
## Suggested Exercises
* Use `find` and `grep` to locate files in your own directory and on the Linux computer at large. For instance, try locating references to your own username in configuration files in `/etc`.
* Use `gzip`, `bzip2`, and `xz` to compress a couple instances of files of various types, such as text files and digital photos. What file types compress well? Which compression tool works best for each file type?
## Review Questions
1. Which of the following commands will print lines from the file `world.txt` that contain matches to `changes`and `changed`?
2. Which of the following redirection operators appends a program's standard output to an existing file, without overwriting that file's original contents?
3. You've received a tarball called `data79.tar` from a colleague, but you want to check the names of the files it contains before extracting them. Which of the following commands would you use to do this?
4. True or false: The regular expression `Linu[^x].*lds` matches the string `Linus Torvalds`.
5. True or false: The `find` command enables you to locate files based on their sizes.
6. True or false: To compress files archived with `zip`, you must use an external compression program such as `gzip` or `bzip2` in a pipeline with `zip`.
7. The character that represents the start of a line in a regular expression is `____________`.
8. Complete the following command to redirect both standard output and standard error from the `bigprog` program to the file `out.txt`. `$ bigprog ____________ out.txt`
9. The `gzip`, `bzip2`, and `xz` programs all perform `____________` compression, in which the decompressed data exactly match the original pre-compression data.
# Chapter 11
*Editing Files*
## Suggested Exercises
* Launch `nano` to create a new file and type in a complete paragraph from this chapter. Proofread the text and correct any typos you find. (If you found none, congratulations! Now create a few "errors" and correct them.)
* Type `Listing 11-2` into `vi` and save it. Point a Web browser at the file (for instance, by typing file:///home/yourusername/sample.html into a Web browser's address field, if you saved it as `~/sample.html`). Add a new paragraph by cutting and pasting the existing paragraph and changing the text. Reload the file to see how your Web browser renders it.
## Review Questions
1. Which type of file is `nano`*least* likely to be useful for examining or editing?
* A) In command mode, position the cursor on the first line and type `2dd`.
* B) In command mode, position the cursor on the last line and type `2yy`.
* C) In insert mode, position the cursor at the start of the first line, hold down the Shift key while pressing the Down arrow key twice, and press the Delete key on the keyboard.
* D) In insert mode, position the cursor at the start of the first line and press Ctrl+K twice.
* E) Select the text with the mouse and then select File ⇒ Delete from the menu.
4. True or false: Unicode is useful for encoding most European languages but not Asian languages.
5. True or false: GUI text editors for ASCII are superior to text-mode ASCII text editors because the GUI editors support underlining, italics, and multiple fonts.
6. True or false: Many (but not all) configuration files use a hash mark `#` to identify comment lines.
8. Three keystrokes that can initiate a search-and-replace operation in `nano` are F14, `____________` and `____________`.
9. While in Vi's command mode, you can type `____________` to undo a change.
# Chapter 12
*Creating Scripts*
## Suggested Exercises
* Write a script that copies a file by prompting the user to enter the source and destination filenames rather than by accepting them as arguments on the command line, as `cp` does.
* Some text editors leave backup files with filenames that end in tildes `~`. Write a script that, when you pass it a directory name as an argument, locates all such files in that directory. The script should then ask the user whether to delete each file individually and do so if and only if the user responds by typing `Y`.
## Review Questions
1. After using a text editor to create a shell script, what step should you take before trying to use the script by typing its name?
4. True or false: A user types `myscript laser.txt` to run a script called `myscript`. Within `myscript`, the `$0` variable holds the value `laser.txt`.
5. True or false: Valid looping statements in Bash include `for`, `while`, and `until`.
6. True or false: The following script launches three simultaneous instances of the `terminal` program.
7. You've written a simple shell script that does nothing but launch programs. In order to ensure that the script works with most user shells, what should its first line read?
8. What command can you use to display prompts for a user in a shell script?
9. What Bash scripting command can you use to control the program flow based on a variable that can take many values (such as all the letters of the alphabet)?
# Chapter 13
*Understanding Users and Groups*
## Suggested Exercises
* Type `whoami` followed by `id` to review your ordinary user account status. Chances are the `id` command will reveal that you're a member of a number of groups. Perform a Web search to learn what each one does.
* Read the `/etc/passwd` file to review what accounts are defined on the computer. Are there ordinary user accounts (those with UIDs above 500 or 1000, depending on your distribution) other than your own? Try performing a Web search to learn the purpose of a few of the system accounts (those with UIDs below 500 or 1,000, depending on your distribution).
## Review Questions
1. What is the purpose of the system account with a UID of 0?
3. You want to run the command `iptables -L` as `root` but you're logged in as an ordinary user. Which of the following commands will do the job, assuming the system is configured to give you `root` access via the appropriate command?
4. True or false: `whoami` provides more information than `id`.
5. True or false: Linux stores information on its groups in the `/etc/groups` file.
6. True or false: As a general rule, you should employ extra care when running programs as `root`.
7. The file that associates usernames with UID numbers in Linux is `____________` (Provide the complete path to the file.)
8. To learn who is currently logged into the computer and what programs they're currently running, you can type `____________`.
9. UIDs below 500 or 1,000 (depending on the distribution) are reserved for use by `____________` accounts.
# Chapter 14
*Creating Users and Groups*
## Suggested Exercises
* Create a test account using User Manager (or another GUI tool provided by your distribution) and then log into the account you've created to verify that it's working as you expected.
* Do the same using `useradd`, but do *not* use `passwd` to set its password. Were you able to log in? Use `passwd` and try logging in again.
## Review Questions
1. What would a Linux system administrator type to remove the `nemo` account and its home directory
4. True or false: User accounts have higher UID numbers than do system accounts.
5. True or false: Command-line users should normally use `usermod` to change their passwords.
6. True or false: After deleting an account, files formerly owned by the deleted account may remain on the computer.
7. You want to create an account for a new user, using the username `theo` and giving the user a UID of 1926. The command to do this is `useradd ____________`.
8. You want to change the username of a user from `e1211` to `emilyn`, without altering anything else about the account. To do so, you would type `____________`.
9. To create a system account, you must pass the `____________` option to `groupadd`.
# Chapter 15
*Setting Ownership and Permissions*
## Suggested Exercises
* As `root`, copy a file that you created as an ordinary user, placing the copy in your ordinary user home directory. Using your normal account, try to edit the file with a text editor and save your changes. What happens? Try to delete that file with the `rm` command. What happens?
* Create a scratch file as an ordinary user. As `root`, use `chown` and `chmod` to experiment with different types of ownership and permissions to discover when you can read and write the file using your normal login account.
* Use the `ls -l` command to view the ownership and permissions of files in your home directory, in `/usr/bin` (where many program files reside), and in `/etc` (where most system configuration files reside). What are the implications of the different ownership and permissions you see for who can read, write, and execute these files?
## Review Questions
1. What command would you type (as `root`) to change the ownership of `somefile.txt` from `ralph` to `tony`?
4. True or false: A file with permissions of 755 can be read by any user on the computer, assuming all users can read the directory in which it resides.
5. True or false: Only `root` may use the `chmod` command.
6. True or false: Only `root` may change a file's ownership with `chown`.
7. What option causes `chown` to change ownership on an entire directory tree?
8. What three-character symbolic string represents read and execute permission but no write permission?
9. What symbolic representation can you pass to `chmod` to give all users execute access to a file, without affecting other permissions?
# Chapter 16
*Navigating the LinuxFilesystem*
## Suggested Exercises
* Examine the names of configuration files in `/etc` and try to find matching program files in `/bin`, `/sbin`, `/usr/bin`, and `/usr/sbin`. Examine the configuration files with `less` or a text editor and read their `man` pages. (Don't do this for *all* the configuration files in `/etc`, though, that would take forever! A couple will suffice.)
* Experiment with the sticky bit on a "scratch" directory. Using your regular account and either another regular account or the `root` account, set the ownership and sticky bit on the scratch directory in different ways and test whether you can delete and modify files in the directory.
## Review Questions
1. What types of files are you likely to find in `/usr/lib`, according to the FHS?
4. True or false: Print spool files are stored in a subdirectory of `/var`.
5. True or false: On a properly configured Linux system, any user can delete any file from `/tmp`.
6. True or false: If you hide a file in Linux by making it a dot file, you must change any existing references to that file in configuration files if those references are to continue working.
7. Typically, optical discs and USB flash drives are mounted in subdirectories of `/mnt` or `____________`.
8. Temporary files that are guaranteed to *not* be deleted during a reboot reside in `____________`.
9. You want to set the sticky bit on an existing directory, `subdir`, without otherwise altering its permissions. To do so, you should type `chmod ____________ subdir`.
# Chapter 17
*Managing Network Connections*
## Suggested Exercises
* On a small private network that you control or in a lab environment under the supervision of an instructor, reconfigure a computer that normally uses DHCP to use its assigned IP address in a static fashion. Test the connection, and then switch back to DHCP.
* *Do not perform this test on a work or school network that's used for normal purposes*; misconfiguration of a computer's IP address can cause problems for other computers.
* Back up your `/etc/resolv.conf` file and then edit the original so that its `nameserver` lines point to computers that don't run DNS servers. Test your network configuration by attempting to access remote servers using `ping`, a Web browser, and other utilities. Observe the types of failures that result. When you're done, restore the original file.
## Review Questions
1. You want to set up a computer on a local network via a static TCP/IP configuration, but you lack a gateway address. Which of the following is true?
3. The `ping` utility responds normally when you use it with an IP address but not when you use it with a hostname that you're positive corresponds to this IP address. What might cause this problem? (Select all that apply.)
4. True or false: IPv4 addresses are four bytes in length.
5. True or false: The `/etc/resolv.conf` file tells the computer whether to use DHCP for its network configuration.
6. True or false: You can check the current status of your routing table by typing `route` at a shell prompt.
7. The `____________` program serves as a multi-purpose network tool; it can do many of the same things as `ifconfig`, `route`, and several others.
8. The traditional name for the first Ethernet interface in Linux (but not in recent versions of Fedora) is `____________`.
9. A `____________` is a program or system configuration that blocks or enables network access to, from, or through a computer based on criteria you specify.