Commands for Ubuntu

Verifying Installed Packages with debsums

There are times when you will question the behavior of a binary or package installed on the system. It may not perform correctly, or may not even start at all. Problems with corrupt packages from unstable network connections or power outages do happen. In addition, malicious users may attempt to replace powerful commands with their own versions to cause further harm. It becomes useful to check the files on the file system against the information stored in the package. The debsums program is a...

Burning Backup Images with cdrecord

The cdrecord command is the most popular Linux command line tool for burning CD and DVD images. After you have created an ISO image (as described earlier) or obtained one otherwise (such as downloading an install CD or live CD from the Internet), cdrecord makes it easy to put that image on a disc. NOTE In Ubuntu, cdrecord has been replaced with the wodim command. The wodim command was created from the cdrecord code base and still supports most of the same options. If you run cdrecord, you will...

Accessing Network Resources

In the time it takes to fire up a graphical FTP client, you could already have downloaded a few dozen files from a remote server using command line tools. Even when a GUI is available, commands for transferring files, web browsing, sharing directories, and reading mail can be quick and efficient to use. When no GUI is available, they can be lifesavers. This chapter covers commands for accessing resources (files, e-mail, shared directories, and online chats) over the network. Text-mode web...

Creating Backup Images with mkisofs

Most data CDs and DVDs can be accessed on both Windows and Linux systems because they are created using the IS09660 standard for formatting the information on those discs. Because most modern operating systems need to save more information about files and directories than the basic IS09660 standard includes, extensions to that standard were added to contain that information. Using the mkisofs command, you can back up the file and directory structure from any point in your Linux file system and...

Shell Special Characters and Variables

Ubuntu provides bash as the default shell. Chapter 3 helps you become comfortable working in the shell. This appendix provides a reference of the numerous characters and variables that have special meaning to the bash shell. Many of those elements are referenced in Table B-l (Shell Special Characters) and Table B-2 (Shell Variables). You can use special characters from the shell to match multiple files, save some keystrokes, or perform special operations. Table B-l shows some shell special...

Locking Down Security

Securing your Linux system means first restricting access to the user accounts and services on that system. After that, security means checking that no one has gotten around the defenses you have set up. Ubuntu, Debian, and other systems based on those Linux distributions are designed to be secure by default. That means that there are no user accounts with blank passwords, and that most network services (Web, FTP, and so on) are off by default (even if their software is installed). Although...

Using Dialup Modems

Although high-speed DSL, cable modem, and wireless LAN hardware have become widely available, there may still be times when a phone line and a modem are your only way to get on the Internet. Linux offers both graphical and command line tools for configuring and communicating with modems. As with other network connections in Ubuntu, dial-up modem connections can be configured using the Network Configuration window. Most external serial modems will work with Linux without any special...

Doing Remote System Administration

Most professional Linux administrators do not non a graphical interface on their Internet servers. As a result, when you need to access other computers for remote administration, you will almost surely need to work from the command line at some time. Luckily there are many feature-rich Linux commands to help you do so. Tools associated with the Secure Shell (SSH) service not only allow remote login and file transfer, but they also offer encrypted communication to keep your remote administration...

Searching for Text with grep

The grep command comes in handy when you need to perform more advanced string searches in a file. In fact, the phrase to grep has actually entered the computer jargon as a verb, just as to Google has entered the popular language. Here are examples of the grep command grep francois myfile.txt Show lines containing francois grep 404 var log httpd access_log Show lines containing 404 ps auwx grep init Show init lines from ps output ps auwx grep * n Show bracketed commands dmesg grep ata ata Show...

Terminal Windows and Shell Access

The most common way to access a shell from a Linux graphical interface is using a Terminal window. From a graphical interface, you can often access virtual terminals to get to a shell. With no graphical interface, with a text-based login you are typically dropped directly to a shell after login. To open a Terminal window from GNOME (the default Ubuntu desktop), select Applications < > Accessories O Terminal. This opens a gnome-terminal window, displaying a bash shell prompt. Figure 3-1...

Using Compression Tools

Compression is an important aspect of working with backup files. It takes less disk space on your backup medium (CD, DVD, tape, and so on) or server to store compressed files. It also takes less time to transfer the archives to the media or download the files over a network. While compression can save a lot of storage space and transfer times, it can significantly increase your CPU usage. You can consider using hardware compression on a tape drive (see www. amanda. org docs faq. html id346016)....

Matching Text with Regular Expressions

Many of the tools for working with text enable you to use regular expressions, sometimes referred to as regex, to identify the text you are looking for based on some pattern. You can use these strings to find text within a text editor or use them with search commands to scan multiple files for the strings of text you want. Matching text with regular expressions Editing text files with vi, JOE, or nano Listing text with cat, head, and tail Counting words, lines, and characters with wc Stream...

Backing Up with unison

Although the rsync command is good to back up one machine to another, it assumes that the machine being backed up is the only one where the data is being modified. What if you have two machines that both modify the same file and you want to sync those files Unison is a tool that will let you do that. It's common for people to want to work with the same documents on their laptop and desktop systems. Those machines might even run different operating systems. Because unison is a cross-platform...

Installing Packages with APT

You can now install, using sudo, any available software authored by Google for Ubuntu, using APT or another package tool. This shows Picasa being installed using APT Reading package lists Done Building dependency tree Reading state information Done The following NEW packages will be installed picasa 0 upgraded, 1 newly installed, 0 to remove and 115 not upgraded. Need to get 21.7MB of archives. After unpacking 82.3MB of additional disk space will be used. Get 1 http dl.google.com stable...

Using fuser to Find Processes

Another way to locate a particular process is by what the process is accessing. The fuser command can be used to find which processes have a file or a socket open at the moment. After the processes are found, fuser can be used to send signals to those processes. The fuser command is most useful for finding out if files are being held open by processes on mounted file systems (such as local hard disks or Samba shares). Finding those processes allows you to close them properly (or just kill them...

Formatting a File System

With your disk partitions in place, you can build a file system of your choice on each partition. Most Linux systems come with the commands needed to make and check file systems that are commonly used in Linux. Commands for formatting and checking file systems are mkf s and f sck, respectively. The mkf s command serves as the front end for many different commands aimed at formatting particular file system types, such as mkf s. ext2, mkf s. ext3, mkf s. cramf s, mkfs .msdos, mkfs . ntfs, and...

Cleaning Up Packages with APT

After your initial installation of an Ubuntu release, Ubuntu keeps downloaded packages cached in var cache apt to speed up downloading if you ever need them again. This can eventually use up a lot of disk space. You can remove this package cache, but you will need to download a removed package again at a later date if it is needed for dependencies. Clean up the cache by giving apt-get the clean option. We show how this works by first running the Linux find command on the var cache apt directory...

Using vi or Vim Editors

Although easy-to-use graphical text editors (such as gedit and kedit) are readily available with Linux, most power users still use vi or Emacs to edit text files. Besides the fact that vi and Emacs will work from any shell (no GUI required), they offer other advantages such as your hands never having to leave the keyboard and integration with useful utilities. And unlike GUI editors, text-based editors are usable over slow Internet connections such as dial-up or satellite. This appendix focuses...