PrintNumber ErrorLocation Error Correction DateAdded
1 p ii First Printing: January 2012 Second Printing: April 2012 2/2/2012
1 p 9 EdUbuntu Edubuntu 4/12/2012
1 p 20 matthew@seymour:~$ dmesg > dmesg.txt
This takes the output from the dmesg command and stores it in a new text file called dmesg.txt. You can then browse it at your leisure using your choice of text editor, such as vi or emacs. You can even use the less command, like so:
matthew@seymour:~$ less dmesg.txt
The messages are generated by the kernel, by other software run by /etc/init.d, and by Ubuntu’s runlevel scripts. You might find what appear to be errors at first glance, but some errors are not really problems (for example, if a piece of hardware is configured but not present on your system).
Thanks to Google, troubleshooting is no longer the slow process it used to be. You can copy and paste error messages into Google’s search bar to bring up a whole selection of results similar to the problem you face. Remember, Google is your friend, especially www.google.com/linux, which provides a specialized search engine for Linux. You can also try http://marc.info, which browses newsgroup and mailing list archives. Either way, you are likely to come across people who have had the same problem as you.
It is important to work on finding and testing only one solution to one problem at a time; otherwise, you might end up getting no work done whatsoever. You should also get into the habit of making backup copies of all files that you modify, just in case you make a bad situation worse. Use the copy (cp) command like this:
matthew@seymour:~$ cp file file.backup20101010
You should not use a .bak extension on your backup file because this could get overwritten by another automatic process and leave you frustrated when you try to restore the original file. I like to use backupYYYYMMDD, as in the preceding code where I used the release date for Ubuntu 10.10: 2010(year)10(month)10(day).
If something breaks as a result of your changing the original file, you can always copy the original back into place using the command like this:
matthew@seymour:~$ cp file.backup20101010 file
matthew@seymour:~$ dmesg > dmesg.txt
This takes the output from the dmesg command and stores it in a new text file called dmesg.txt. You can then browse it at your leisure using your choice of text editor, such as vi or emacs. You can even use the less command, like so:
matthew@seymour:~$ less dmesg.txt
The messages are generated by the kernel, by other software run by /etc/init.d, and by Ubuntu’s runlevel scripts. You might find what appear to be errors at first glance, but some errors are not really problems (for example, if a piece of hardware is configured but not present on your system).
Thanks to Google, troubleshooting is no longer the slow process it used to be. You can copy and paste error messages into Google’s search bar to bring up a whole selection of results similar to the problem you face. Remember, Google is your friend, especially www.google.com/linux, which provides a specialized search engine for Linux. You can also try http://marc.info, which browses newsgroup and mailing list archives. Either way, you are likely to come across people who have had the same problem as you.
It is important to work on finding and testing only one solution to one problem at a time; otherwise, you might end up getting no work done whatsoever. You should also get into the habit of making backup copies of all files that you modify, just in case you make a bad situation worse. Use the copy (cp) command like this:
matthew@seymour:~$ cp file file.backup20101010
You should not use a .bak extension on your backup file because this could get overwritten by another automatic process and leave you frustrated when you try to restore the original file. I like to use backupYYYYMMDD, as in the preceding code where I used the release date for Ubuntu 10.10: 2010(year)10(month)10(day).
If something breaks as a result of your changing the original file, you can always copy the original back into place using the command like this:
matthew@seymour:~$ cp file.backup20101010 file
4/12/2012
1 p 21 matthew@seymour:~$ sudo command commandoptions
Just replace the word command with the command that you want to run, along with any options. For example, the following command opens your xorg.conf file in vi and enables you to make any changes as the super user before being able to save it:
matthew@seymour:~$ sudo vi /etc/X11/xorg.conf
matthew@seymour:~$ sudo command commandoptions
Just replace the word command with the command that you want to run, along with any options. For example, the following command opens your xorg.conf file in vi and enables you to make any changes as the super user before being able to save it:
matthew@seymour:~$ sudo vi /etc/X11/xorg.conf
4/12/2012
1 p 23 matthew@seymour:~$ sudo apt-get update
This command tells the package management utility apt-get to check the Ubuntu repositories and look for any updates to your installed software. In a matter of seconds, Ubuntu completes all of this, and your screen should look something like this:
matthew@seymour:~$ sudo apt-get update
matthew@seymour:~$ sudo apt-get update
This command tells the package management utility apt-get to check the Ubuntu repositories and look for any updates to your installed software. In a matter of seconds, Ubuntu completes all of this, and your screen should look something like this:
matthew@seymour:~$ sudo apt-get update
4/12/2012
1 p 25 matthew@seymour:~$ apt-get dist-upgrade matthew@seymour:~$ apt-get dist-upgrade 4/12/2012
1 p 31 matthew@seymour:~$ date
Sat Sep 4 10:20:51 MST 2010
To adjust your system’s time (for example, to September 4, 2010 at 10:33 a.m.), use a command line with the month, day, hour, minute, and year, like so:
matthew@seymour:~$ sudo date 090410332010
Sat Sep 4 10:33:00 MST 2010
matthew@seymour:~$ date
Sat Sep 4 10:20:51 MST 2010
To adjust your system’s time (for example, to September 4, 2010 at 10:33 a.m.), use a command line with the month, day, hour, minute, and year, like so:
matthew@seymour:~$ sudo date 090410332010
Sat Sep 4 10:33:00 MST 2010:
4/12/2012
1 p 32 matthew@seymour:~$ sudo hwclock --show
Sat 04 Sep 2010 05:25:17 PM MST -0.806770 seconds
Use hwclock with its —set and —date options to manually set the hardware clock, as follows:
matthew@seymour:~$ sudo hwclock --set --date “09/04/10 10:33:00”
matthew@seymour:~$ hwclock --show
Sat 04 Sep 2010 10:33:09 AM MST -0.904668 seconds
In these examples, the hardware clock has been set using hwclock, which is then used again to verify the new hardware date and time. You can also use hwclock to set the Linux system date and time using your hardware clock’s values with the Linux system date and time.
For example, to set the system time from your PC’s hardware clock, use the --hctosys option, like so:
matthew@seymour:~$ sudo hwclock --hctosys
To set your hardware clock using the system time, use the --sytohc option, like so:
matthew@seymour:~$ sudo hwclock --systohc
matthew@seymour:~$ sudo hwclock --show
Sat 04 Sep 2010 05:25:17 PM MST -0.806770 seconds
Use hwclock with its —set and —date options to manually set the hardware clock, as follows:
matthew@seymour:~$ sudo hwclock --set --date “09/04/10 10:33:00”
matthew@seymour:~$ hwclock --show
Sat 04 Sep 2010 10:33:09 AM MST -0.904668 seconds
In these examples, the hardware clock has been set using hwclock, which is then used again to verify the new hardware date and time. You can also use hwclock to set the Linux system date and time using your hardware clock’s values with the Linux system date and time.
For example, to set the system time from your PC’s hardware clock, use the --hctosys option, like so:
matthew@seymour:~$ sudo hwclock --hctosys
To set your hardware clock using the system time, use the --sytohc option, like so:
matthew@seymour:~$ sudo hwclock --systohc
4/12/2012
1 p 88 matthew@seymour:~$ convert image.gif image.png matthew@seymour:~$ convert image.gif image.png 4/12/2012
1 p 92 matthew@seymour:~$ mkisofs -r -v -J -l -o /tmp/our_special_cd.iso /source_directory matthew@seymour:~$ mkisofs -r -v -J -l -o /tmp/our_special_cd.iso /source_directory 4/12/2012
1 p 93 matthew@seymour:~$ cdrecord -eject -v speed=12 dev=0,0,0 /tmp/our_special_cd.iso matthew@seymour:~$ cdrecord -eject -v speed=12 dev=0,0,0 /tmp/our_special_cd.iso 4/12/2012
1 p 95 matthew@seymour:~$ sudo your_application | growisofs -Z /dev/scd0=/dev/fd/0
It is also possible to burn from an existing image (or file, named pipe, or device):
matthew@seymour:~$ sudo growisofs -Z /dev/scd0=image
matthew@seymour:~$ sudo your_application | growisofs -Z /dev/scd0=/dev/fd/0
It is also possible to burn from an existing image (or file, named pipe, or device):
matthew@seymour:~$ sudo growisofs -Z /dev/scd0=image
4/12/2012
1 p 129 matthew@seymour:~$ apt-get source foo
Install the build dependencies for the package:
matthew@seymour:~$ sudo apt-get build-dep foo
matthew@seymour:~$ apt-get source foo
Install the build dependencies for the package:
matthew@seymour:~$ sudo apt-get build-dep foo
4/12/2012
1 p 130 matthew@seymour:~$ dch -i
Build the source package. This creates all the files necessary for uploading a package:
matthew@seymour:~$ debuild -S
Finally, you are left with a foo-4.5.2-1ubuntu1custom.deb package (using whatever version number or suffix you created earlier) that you can install, and later uninstall as well, using your package manager. In some instances, multiple DEB files may be created, in which case you would replace the individual package name in the following example with *.deb:
matthew@seymour:~$ sudo dpkg -Oi foo-4.5.2-1ubuntu1custom.deb
matthew@seymour:~$ dch -i
Build the source package. This creates all the files necessary for uploading a package:
matthew@seymour:~$ debuild -S
Finally, you are left with a foo-4.5.2-1ubuntu1custom.deb package (using whatever version number or suffix you created earlier) that you can install, and later uninstall as well, using your package manager. In some instances, multiple DEB files may be created, in which case you would replace the individual package name in the following example with *.deb:
matthew@seymour:~$ sudo dpkg -Oi foo-4.5.2-1ubuntu1custom.deb
4/12/2012
1 p 145 matthew@seymour:~$ ls
Documents Music file.txt Pictures Music
matthew@seymour:~$ ls
Documents Music file.txt Pictures Music
4/12/2012
1 p 145 matthew@seymour:~$ ls -a
. .bash_logout Documents Music
.. .bashrc file.txt Pictures
.bash_history .config .local .profile
matthew@seymour:~$ ls -a
. .bash_logout Documents Music
.. .bashrc file.txt Pictures
.bash_history .config .local .profile
4/12/2012
1 p 147 matthew@seymour:~$ cd somedir
That looks in the current directory for the somedir subdirectory, then moves you into it. You can also specify an exact location for a directory, like this:
matthew@seymour:~$ cd /home/matthew/stuff/somedir
matthew@seymour:~$ cd somedir
That looks in the current directory for the somedir subdirectory, then moves you into it. You can also specify an exact location for a directory, like this:
matthew@seymour:~$ cd /home/matthew/stuff/somedir
4/12/2012
1 p 148 matthew@seymour:~$ touch file
matthew@seymour:~$ ls -l file
-rw-r--r-- 1 matthew matthew 0 2010-06-30 13:06 file
matthew@seymour:~$ touch file
matthew@seymour:~$ ls -l file
-rw-r--r-- 1 matthew matthew 0 2010-06-30 13:06 file
4/12/2012
1 p 150 matthew@seymour:~$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 2010-06-30 08:13 /dev/ttyS0
matthew@seymour:~$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 2010-06-30 08:13 /dev/ttyS0
4/12/2012
1 p 151 matthew@seymour:~$ chmod u+rw readme.txt
matthew@seymour:~$ ls -l readme.txt
-rw-r--r-- 1 matthew matthew 0 2010-06-30 13:33 readme.txt
You can also use the octal form of the chmod command (for example, to modify a file’s permissions so that only you, the owner, can read and write a file). Use the chmod command and a file permission of 600, like this:
matthew@seymour:~$ chmod 600 readme.txt
matthew@seymour:~$ ls -l readme.txt
-rw------- 1 matthew matthew 0 2010-06-30 13:33 readme.txt
matthew@seymour:~$ chmod u+rw readme.txt
matthew@seymour:~$ ls -l readme.txt
-rw-r--r-- 1 matthew matthew 0 2010-06-30 13:33 readme.txt
You can also use the octal form of the chmod command (for example, to modify a file’s permissions so that only you, the owner, can read and write a file). Use the chmod command and a file permission of 600, like this:
matthew@seymour:~$ chmod 600 readme.txt
matthew@seymour:~$ ls -l readme.txt
-rw------- 1 matthew matthew 0 2010-06-30 13:33 readme.txt
4/12/2012
1 p 153 matthew@seymour:~$ touch filename matthew@seymour:~$ touch filename 4/12/2012
1 p 158 matthew@seymour:~$ rm abc* matthew@seymour:~$ rm abc* 4/12/2012
1 p 158 matthew@seymour:~$ sudo rm -rf / matthew@seymour:~$ sudo rm -rf / 4/12/2012
1 p 162 matthew@seymour:~$ sudo shutdown -r now
or
matthew@seymour:~$ sudo shutdown -r 0
matthew@seymour:~$ sudo shutdown -r now
or
matthew@seymour:~$ sudo shutdown -r 0
4/12/2012
1 p 163 $ whereis fdisk
fdisk: /sbin/fdisk /usr/share/man/man8/fdisk.8.gz
matthew@seymour:~$ whereis fdisk
fdisk: /sbin/fdisk /usr/share/man/man8/fdisk.8.gz
4/12/2012
1 p 163 $ info info matthew@seymour:~$ info info 4/12/2012
1 p 171 chmod --reference /home/matthew/myfile.txt * matthew@seymour:~$ chmod --reference /home/matthew/myfile.txt * 4/12/2012
1 p 193 matthew@seymour:~$ command

The program ‘command’ is currently not installed. You can install it by typing:

sudo apt-get install command
matthew@seymour:~$ command

The program ‘command’ is currently not installed. You can install it by typing:

matthew@seymour:~$ sudo apt-get install command
4/12/2012
1 p 194 $ PS1=’$OSTYPE r00lz ->’ matthew@seymour:~$ PS1=’$OSTYPE r00lz ->’ 4/12/2012
1 p 211 matthew@seymour:~$ sudo passwd -l username matthew@seymour:~$ sudo passwd -l username 4/12/2012
1 p 212 matthew@seymour:~$ sudo useradd heather -p c00kieZ4ME -s /bin/zsh -u 1042 matthew@seymour:~$ sudo useradd heather -p c00kieZ4ME -s /bin/zsh -u 1042 4/12/2012
1 p 218 matthew@seymour:~$ cat /etc/passwdd matthew@seymour:~$ cat /etc/passwdd 4/13/2012
1 p 218 matthew@seymour:~$ sudo cat /etc/shadoww matthew@seymour:~$ sudo cat /etc/shadoww 4/13/2012
1 p 223 root~# exit root~# exit 4/13/2012
1 p 227 matthew@seymour:~$ sudo mount -o ro,remount partition_to_be_remounted mount_point matthew@seymour:~$ sudo mount -o ro,remount partition_to_be_remounted mount_point 4/13/2012
1 p 243 matthew@seymour:~$ chmod +x myenv matthew@seymour:~$ chmod +x myenv 4/13/2012
1 p 279 matthew@seymour:~$ ls /etc/rc1.d/ matthew@seymour:~$ ls /etc/rc1.d/ 4/13/2012
1 p 281 matthew@seymour:~$ sudo telinit S
The telinit command uses the init command to change runlevels and shut down currently running services.
After booting to single-user mode, you can then return to multi-user mode, like this:
matthew@seymour:~$ sudo telinit 2
matthew@seymour:~$ sudo telinit S
The telinit command uses the init command to change runlevels and shut down currently running services.
After booting to single-user mode, you can then return to multi-user mode, like this:
matthew@seymour:~$ sudo telinit 2
4/13/2012
1 p 283 sudo /etc/init.d/apache2 start
Starting apache 2.2 web server [ OK ]
matthew@seymour:~$ sudo /etc/init.d/apache2 start
Starting apache 2.2 web server [ OK ]
4/13/2012
1 p 284 matthew@seymour:~$ sudo /etc/init.d/ufw stop matthew@seymour:~$ sudo /etc/init.d/ufw stop 4/13/2012
1 p 298 #!/bin/bash
sleep 45 &&
exec conky -d -c ~/conky/conkyrc &
# sleep 50 &&
# exec conky -d -c ~/conky/conkyrc_weather &
exit
#!/bin/bash
sleep 45 &&
exec conky -d -c ~/conky/conkyrc &
# sleep 50 &&
# exec conky -d -c ~/conky/conkyrc_weather &
exit
4/13/2012
1 p 345 matthew@seymour:~$ sudo modprobe 8139too matthew@seymour:~$ sudo modprobe 8139too 4/13/2012
1 p 350 matthew@seymour:~$ sudo route add default gw 149.112.50.65
Note that you could use a hostname rather than an IP address if desired. Another common use is to add the network to the routing table right after using the ifconfig command to configure the interface. Assuming that the 208.59.243.0 entry from the previous examples was missing, replace it using the following command:
matthew@seymour:~$ sudo route add -net 208.59.243.0 netmask 255.255.255.0 dev eth0
You also can use route to configure a specific host for a direct (point-to-point) connection. For example, suppose that you have a home network of two computers. One of the computers has a modem through which it connects to your business network. You typically work at the other computer. You can use the route command to establish a connection through specific hosts using the following command:
matthew@seymour:~$ sudo route add -host 198.135.62.25 gw 149.112.50.65
matthew@seymour:~$ sudo route add default gw 149.112.50.65
Note that you could use a hostname rather than an IP address if desired. Another common use is to add the network to the routing table right after using the ifconfig command to configure the interface. Assuming that the 208.59.243.0 entry from the previous examples was missing, replace it using the following command:
matthew@seymour:~$ sudo route add -net 208.59.243.0 netmask 255.255.255.0 dev eth0
You also can use route to configure a specific host for a direct (point-to-point) connection. For example, suppose that you have a home network of two computers. One of the computers has a modem through which it connects to your business network. You typically work at the other computer. You can use the route command to establish a connection through specific hosts using the following command:
matthew@seymour:~$ sudo route add -host 198.135.62.25 gw 149.112.50.65
4/13/2012
1 p 358 matthew@seymour:~$ sudo cp /etc/dhcp3/dhclient.conf/
etc/dhcp3/dhclient.conf.backupp
matthew@seymour:~$ sudo cp /etc/dhcp3/dhclient.conf/etc/dhcp3/dhclient.conf.backupp 4/13/2012
1 p 442 matthew@seymour:~$ sudo testparm /path/to/smb.conf.back-up matthew@seymour:~$ sudo testparm /path/to/smb.conf.back-up 4/13/2012
1 p 443 matthew@seymour:~$ smbclient -I 10.10.10.20 -Uusername%password matthew@seymour:~$ smbclient -I 10.10.10.20 -Uusername%password 4/13/2012
1 p 496 matthew@seymour:~$ sudo service vsftpd status matthew@seymour:~$ sudo service vsftpd status 4/13/2012
1 p 500 matthew@seymour:~$ sudo /etc/init.d/inetutils-inetd restart
Stopping internet superserver inetd: [ OK ]
Starting internet superserver inetd: [ OK ]
matthew@seymour:~$ sudo /etc/init.d/inetutils-inetd restart
Stopping internet superserver inetd: [ OK ]
Starting internet superserver inetd: [ OK ]
4/13/2012
1 p 508 matthew@seymour:~$ sudo /etc/init.d/postfix start matthew@seymour:~$ sudo /etc/init.d/postfix start 4/13/2012
1 p 547 matthew@seymour:~$ postmaster -D /usr/local/pgsql/data & matthew@seymour:~$ postmaster -D /usr/local/pgsql/data & 4/13/2012
1 p 569 $ sudo ldapadd -Y EXTERNAL -H ldapi:/// -f backend.example.com.ldif $ sudo ldapadd -Y EXTERNAL -H ldapi:/// -f backend.example.com.ldif 4/13/2012
1 p 586 matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu-system-
x86_64
And if you have a 32-bit system, use this:
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu-system-
x86_64
And if you have a 32-bit system, use this:
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu
4/13/2012
1 p 665 # perl -MCPAN -e shell matthew@seymour:~# perl -MCPAN -e shell 4/13/2012
1 p 665 cpan> install Bundle::CPAN
To download a desired module (using the example in Listing 36.6), use the get keyword like this:
cpan> get Mail::Sendmail
cpan> install Bundle::CPAN
To download a desired module (using the example in Listing 36.6), use the get keyword like this:
cpan> get Mail::Sendmail
4/13/2012
1 p 666 cpan> install Mail::Sendmail
The entire process of retrieving, building, and installing a module can also be accomplished at the command line by using Perl’s -e option, like this:
# perl -MCPAN -e “install Mail::Sendmail”
cpan> install Mail::Sendmail
The entire process of retrieving, building, and installing a module can also be accomplished at the command line by using Perl’s -e option, like this:
matthew@seymour:~# perl -MCPAN -e “install Mail::Sendmail”
4/13/2012
1 p 673 matthew@seymour:~$ php ubuntu1.php matthew@seymour:~$ php ubuntu1.php 4/13/2012