Chapter 5: Communicating Online


The default Ubuntu desktop installation includes a web browser, e-mail reader, instant messaging and chat-room client, and even a VoIP system. Although anyone can use them as is, you can get much more out of them by performing a few tweaks and tuning a couple of parameters. Whether you want speed, security, or fancier graphics and cooler features, you are going to want to modify the default applications. In this chapter, you will see how to adjust the web browser settings, secure your web traffic using Secure Shell, access your mail on a variety of systems, and chat online.

Hacking the Firefox Web Brower

The default web browser for Ubuntu is Mozilla Firefox. This browser is fast and supports HTTP 1.0 and 1.1 protocols, as well as HTML and DHTML (dynamic HTML). Although you can immediately use the browser for accessing web sites, some of the default settings could use a little modification.

Tuning Preferences

Firefox has a set of common preferences that can be adjusted to fit your needs. Open the main preferences menu by starting the browser and choosing Edit image from book Preferences from the Firefox menu. The preferences menu is divided in to categories, denoted by icons on the top of the window (see Figure 5-1). I change my preferences for security, speed, and convenience. Whenever I use a new browser, I immediately change the home page, Java and JavaScript settings, and cache options. If I plan to repeatedly use the browser (instead of a one-time install on a temporary system), then I also adjust the connection and privacy settings.

image from book
Figure 5-1: The Firefox Preferences window

Tuning the General Preferences

The General category provides basic settings for the browser.

  • Change the default location. I usually use a search engine or a blank page. If there is a particular site you usually go to first, put the URL here. But specifying a blank page gives you a faster startup time since the browser isn't busy accessing the network.

  • Make sure the default browser check box is not set. If you only have one browser, this is not an issue. Ubuntu is not like Windows, where various Windows applications can (and frequently do) hijack the default browser settings.

  • If you use a proxy instead of directly connecting to the Internet, Ubuntu gives you two choices. You can configure a system-wide proxy that will work for all network services (see Chapter 12), or you can give Firefox a special proxy setting through the Connection Settings button.

Tuning the Privacy Preferences

The Privacy category provides settings for managing cached information.

  • I usually reduce the history from the default nine days to one day. If I need to visit a site often, then I bookmark the URL. Keeping nine days of history just clutters the list of sites I have visited. But there are some reasons to keep a large history. For example, if you use the browser for researching a project, then a large history can allow you to quickly find places you visited days or weeks ago. Consider changing this value to match your needs.

    Tip 

    Anyone using your browser can see the sites you have visited. If you have privacy concerns, consider lowering the history or disabling it completely by setting the number of days to zero and then clearing the history once.

  • I usually disable saved forms and saved passwords. This is mainly for privacy. On the other hand, enabling these options can really speed up some web access. If you don't have privacy concerns and frequently visit the same sites that require forms or passwords, then you can enable these options.

  • Firefox keeps a history of downloaded files. The default setting enables you to manually clean up the list of files. I usually enable automatic removal of entries after downloads. This way, my list only shows failed downloads and ones in progress.

  • As much as privacy advocates complain about tracking people, cookies have become a way of life on the web. Yet, there are some safer ways to handle cookies. I suggest enabling cookies for only the originating site and blocking cookies that I have intentionally removed (see Figure 5-2). Unless you have a need for maintaining cookies long after you close the browser, I suggest the Keeping cookies: Until I close Firefox setting. When you close the browser, all cookies are removed.

    image from book
    Figure 5-2: Changing the Firefox cookie preferences

    Note 

    Firefox uses shared memory. You must close all Firefox browsers and windows to clear out the cookies. Closing one browser does not do it since the shared memory is not released.

  • Cache files are stored on your hard drive for quick access to sites you commonly visit. The default is 50 MB of cache. I usually reduce it to 20 MB. Most sites that I visit have dynamic content that changes hourly (active web forums, news sites, and so on). Despite what advertisers may think, I usually don't need to cache 50 MB of banner ads on my system.

Tip 

If a web page does not show current information, then it is likely cached. Hold down the Ctrl key when you click on the Reload icon in order to forcefully refresh the page. You can also use Ctrl+F5 or Ctrl+Shift+R.

image from book
Cache and Privacy

The browser cache can lead to privacy concerns. Everything from web pages of online bank accounts to porn that you accidentally stumbled across gets stored in the cache. If your system is compromised or accessed by someone else, then everything in your cache becomes fair game.

Keeping a small cache does remove the data from a typical user, but it won't stop the professionals. Even through a file is deleted, it can still be recovered through tools such as e2undel and recover (for ext2 file systems), or more complicated tools such as The Coroner's Toolkit (tct), Sleuthkit, and Autopsy. Although these are not easy- to-use programs, they can recover most deleted files.

The best way to stay very safe is to completely disable caching, but that will lead to slow web pages. Every icon-regardless how small-must be downloaded from the network every single time. In general, adjusting the cache size is done more for speed and disk space than for privacy since anything saved to disk could potentially be recovered.

image from book

Tuning the Content Preferences

The Content category provides settings for handling HTML content.

  • I always enable popup blocking. If a specific site wants to create a popup, Firefox will inform me with a bar at the top of the page. Then I can explicitly permit popups for that page.

    Note 

    Blocking popups does not stop all popups. JavaScript can also be used to spawn popup windows without being caught by this setting. However, enabling popup blocking does stop a lot of the annoyances.

  • Enable warnings about new extensions and themes. Although this does not stop a web page from trying to install something cool, it does give you the option to stop it. This is really essential when you consider that the same auto-install mechanism for loading extensions can also be used to load a virus.

  • Disable Java. There are very few web sites that require it and there are security risks. I used to recommend that people disable JavaScript, but today there are too many web sites using JavaScript for making active web pages. If you do leave it enabled, be sure to look at the Advanced settings for JavaScript. Turn off anything you do not require. (And if you don't know, turn it off until you do know-usually you will not notice a difference.)

Tuning the Tabs Preferences

Tabs enable you to open new pages in the same window rather than opening a new browser. I find this to be the most useful feature of Firefox. I always have tabs shown (disable the Hide the tab bar option). This way, if I want to open a new tab, I can either press Ctrl+T or double- click on an empty part of the tab bar. Also, always having tabs displayed means the screen will not resize when I open a new tab bar.

Tuning the Downloads Preferences

The Downloads category determines how and where files are saved.

  • For downloaded files, I make a directory on my desktop called Downloads and set it as the default download directory. This way, I can easily find things I just downloaded. If you stick with the default, then files are saved to your desktop. If you have a cluttered desktop, then finding a new item could take some hunting.

  • Personally, I like to see the Download Manager, but I also like it to close when it finishes (the Close the Download Manager when all downloads are complete option). If you don't like seeing the download manager when a download finishes, this is where you can disable showing it. At any time you can always go to Tools image from book Downloads to see the Download Manager.

Tuning the Advanced Preferences

The Advanced category is a catchall for other Firefox options. The available options under Ubuntu are different than the Firefox settings under Windows. For example, you do not have the option to check for Firefox updates. This is because the Synaptic's update manager will tell you if new updates are available. You could choose to disable update checks for Installed Extensions and Themes and for Search Engines-neither of these change often enough to require periodic update checks, but leaving the options enabled does not hurt either.

The Advanced category contains three tabs: General, Update, and Security. The General tab covers accessibility and language support; the Update tab manages automatic software updates; and the Security tab manages SSL certificates. Unless you have special needs, you probably do not need to change anything under these tabs.

Fine-Tuning the Firefox Advanced Preferences

The Firefox Preferences menu shows you the most common things to tune, but those are not the only configurable items. There is a hidden configuration screen that you can access by entering about:config in the address bar (see Figure 5-3).

image from book
Figure 5-3: The advanced configuration menu

This configuration menu shows all of the configuration settings and their values. Default values are shown in regular text, whereas bold text denotes modified settings. In this case, you can see that when I changed my default download directory on the Preferences menu, it changed the settings in the advanced configuration. All items from the Preferences menu can also be modified here. To change a preference, double-click the item to change and enter a new value. Alternately, you can right-click the line to bring up a small menu. Selecting the Modify menu option is the same as double-clicking. For example, to completely disable saving files web pages and images to the disk cache, set the browser.cache.disk.enable option to false.

Beyond the common preferences, about:config gives you access to other configurable items. Some configuration items affect how the browser looks or how it displays items. For example, browser.blink_allowed controls whether the HTML <blink>…</blink> tags will make text flash. Setting this to false turns off blinking text.

Note 

Modifying how HTML is displayed, such as turning off blinking text, only affects new web pages. You will need to reload pages that are currently being displayed in other browser windows or tabs.

Other items manage performance. For example, the Hypertext Transport Protocol (HTTP) uses TCP for transferring data. TCP is not the fastest protocol and takes time to create and tear down network connections. To speed things up, HTTP allows you to make multiple requests over an established TCP connection. This way, when you need to request multiple pages or images from one server, you don't have the added delay from managing new connections. After a connection sits idle for a while, it is disconnected. You can adjust this timeout value using the network.http.keep-alive.timeout setting. The default value is 300 seconds (five minutes). If you use a home firewall (you have a home firewall, right?) then the timeout value on the firewall may be less than five minutes. For best performance, consider adjusting the Firefox timeout to match your firewall. Mine is set to 120 seconds (two minutes).

Since one TCP connection can transfer one piece of data at a time, the browser uses multiple connections for parallel downloads. You can also control the number of simultaneous connections by adjusting the network.http.max-connections and network.http.max- connections-per-server settings. The default settings, 24 total connections and 8 per server, are good for a cable modem or DSL users. But, if you have a faster network connection, you might want to increase these values (for example, 32 and 10) and if you are using a slow connection, such as a dialup modem or 802.11b wireless network, then you might want to lower these values to 8 and 4 for dialup, and 12 and 4 for wireless. The reason is based on bottlenecks: if you try to download too much data at once, it will all arrive at the same time. The resulting traffic will be interlaced and the network protocol may send flow-control packets back to the server, or the server may resend unacknowledged packets. As a result, lots of parallel downloads will be slower than if you download the data one file at a time.

Tip 

If you can see the browser slowly loading many images, and frequently get broken or partially loaded images, then you probably have a slow connection. Lower the number of simultaneous connections and see if performance improves. In general, the total number of concurrent connections should be two to three times larger than the number of connections per server.

Fortunately, there is nothing in this advanced configuration menu that is dangerous-changing a setting will not corrupt anything (but may slow down performance) and can always be reset to the default value but right clicking on the item and selecting Reset from the item's menu.

Managing Profiles

Firefox stores all settings in a profile. You don't need to use the same Firefox settings every time; you can create different profiles. For example, I use Ubuntu on a laptop that I carry between home and work. I have one profile configured to use a proxy for work, and another to connect directly to the Internet for home.

Note 

You can also use profiles if you are using a shared machine. Ideally, everyone should have different user accounts on the system. This gives all users independent profiles. But sometimes it is easier for family members to just use the same account. You can easily give everyone (including your dog) different profiles.

To bring up the profile manager, you will need to run Firefox at a command prompt:

 firefox -ProfileManager 

This brings up the Profile Manager, where you can add, edit, or remove profiles (see Figure 5-4). The main profile is called default-don't delete this unless you want to lose all of your settings. After you create your new profile, you can select it and click the Start Firefox button. All preferences that you change now will only impact your new profile. Later, you can start Firefox with your new profile by specifying it on the command line. For example, in Figure 5-4, I created a profile called SOCKS Proxy. I can use this proxy by running: firefox -P "SOCKS Proxy". Alternately, I can specify the default proxy by using -P default, or I can just use -ProxyManager to see the menu again.

image from book
Figure 5-4: The Profile Manager window

Extreme Firefox Tweaks with File Configurations

The settings from the Edit image from book Preferences menu are minimalist, and the about:config menu allows you to control a lot of functionality, but not everything. If you really want to tweak Firefox, you'll need to edit some configuration files.

Firefox stores all files in the $HOME/.mozilla/firefox/ directory. In this directory are sub- directories for each profile you created. These directories have a random eight-character string followed by the profile's name. In each profile directory are all of the configuration files. For example, the file prefs.js contains all of your modified configuration settings from the about:config menu.

Another cool directory is the chrome subdirectory (for example, ˜/.mozilla/firefox/ *.default/chrome/). This is where you can define what Firefox should actually look like. There are two example files in this directory: userChrome and userContent. The former controls the display of Firefox and the latter controls the default rendering options.

  1. At a command prompt, go into the chrome directory. In this example, you'll use the default profile, but you can really choose any profile.

     cd ~/.mozilla/firefox/*.default/chrome 
  2. If you have not already created customized files, then copy over the examples.

     cp userChrome-example.css userChrome.css cp userContent-example.css userContent.css 
  3. Edit userChrome.css. This allows you to alter what the browser looks like. The other file, userContent.css, is for customizing the default web page settings.

  4. After modifying these files, save your changes. You will need to close all open browsers and then open Firefox to see the changes.

Here are some examples of cool things you can do with these configuration files:

  • Stop scrolling text! While scrolling marquee text at the bottom of the browser's window can be informative, most web sites are just annoying. Besides, I like to see the URL when I hold the mouse over a link. To disable marquee text, add the following to the userContent.css file:

     marquee {   -moz-binding : none !important;   display : block;   height : auto !important; } 
  • While you can turn off blinking text in the about:config menu and pref.js file (set browser.blink_allowed to false), you can also set it in the userContent.css file.

     blink {   text-decoration: none ! important; } 
  • By default, all tabs have a dull gray background color. If you use lots of tabs then you might find it convenient to highlight the active tab. In this case, I modified the userChrome.css file to change the active tab to a light green and the inactive tabs are set to dark red.

     /* Change tab colors */ tab{   -moz-appearance: none !important; } tab[selected="true"] {   background-color: lightgreen !important;   color: black !important; } /* Change color of normal tabs */ tab:not([selected="true"]) {   background-color: darkred !important;   color: white !important; } 
  • You can specify any web color by name (for example, lightgreen or white) or by specifying the RGB values. For example, rgb(128,255,128) is a puke green color.

You will need to close all open browsers and then re-open Firefox to see the changes made to the userChrome.css and userContent.css files.

Tip 

The sample userChrome and userContent files contain few examples. They are mainly used to show formatting and offer a few simple examples. You can find larger lists of tunable items at http://www.mozilla.org/unix/customizing.html and http://www.mozilla.org/support/firefox/tips.

Adding Search Engines

When Firefox first starts, the top left corner has a text entry field for doing searches on Google, Yahoo!, eBay, and a few other sites. There is no reason why you cannot add your own search engine. For example, if you work for a large corporation, then your company probably has its own search engine for the internal network. You can create your own search entry for performing these searches. As another example, you might want to add the search engines for SourceForge (http://sourceforge.net) or Google Linux (http://www.google.com/linux) to the menu so you can quickly look for open source software.

  1. Open a command prompt and go to the /usr/lib/firefox/searchplugins directory. This is where the search engine plug-ins are defined.

  2. Create a new search engine.

     sudo gedit sourceforge.src 
    Tip 

    The /usr/lib/firefox directory contains all of the system-wide default settings. All changes you make here will impact all users on the system. You can create a search engine that is only accessible to your default profile by using the $HOME/.mozilla/firefox/*.default/ searchplugins/ directory instead. Initially you will need to create this directory, but you do not need root access to create any files in your home directory.

  3. Edit the src file for your needs. For example, I created an engine to search SourceForge for open source projects. I found the query values by typing anything into the search bar. What I saw was a search URL that said:

     http://sourceforge.net/search/?type_of_search=soft&words=anything 

    This has a URL with two query fields (listed after the "?"). The first field is static and defined by SourceForge for software searches: type_of_search=soft. The second field is the user field and it holds the query. So, my sourceforge.src file becomes:

     <search   name="SourceForge"   description="SourceForge Search"   method="GET"   action="http://sourceforge.net/search/"   queryCharset="utf-8" > <input name="type_of_search" value="soft"> <input name="words" user> </search> 
  4. (Optional) Create an icon for your search engine. This can be a 16x16 GIF or PNG file. Give it the same name as your engine (sourceforge.gif or sourceforge.tif). If you do not create an icon, then it will be assigned the default spyglass icon.

  5. Save the file, close all browsers, and restart Firefox. You should see your plug-in (for example, SourceForge Search) added to the list of search engines.

There are other options for the search plug-in file, but most are not needed. If your search engine uses a POST instead of a GET (you'll know because the search term will not appear in the URL), then you will need to find out the parameters. You can do this by viewing the source of the search engine's web page and seeing what fields get sent with the form (or jump to Chapter 11 and learn how to capture packets and see what is really being sent).

Playing with Plug-ins and Extensions

Plug-ins and extensions are small programs for Firefox that provide additional functionality. For example, the default Firefox installation cannot play SWF (Macromedia Flash) files. By adding in the Flash plug-in (see Chapter 4), you can add in an SWF player. To see the list of installed plug-ins, enter about:plugins in the address bar. While you cannot add, edit, or remove plug-ins from here, you can see what is installed.

Adding Plug-ins

When Firefox does not know how to handle a particular file type, it gives you a couple of options. First, it can save the file to disk. Although this doesn't run any programs, at least it can save it for you.

Another option is to search for an available plug-in. Firefox searches for plug-ins at https://addons.mozilla.org/plugins/. You can also proactively go to this URL and browse the list of available plug-ins. Another site that hosts plug-ins for Linux is at http://plugindoc.mozdev.org/linux.html, but Firefox does not normally search this site.

A final option requires you to know the plug-in's name and install it using apt-get.Some plug-in packages include mozilla-helix-player, totem-gstreamer-firefox-plugin, and totem-xine-firefox-plugin.

Removing Plug-ins

In the event that you add in a plug-in and it turns out not to be what you wanted, you need some way to remove it. Unfortunately, the Firefox menus offer no solution here. If you installed the plug-in using apt-get, then you can remove it (for example, sudo apt-get remove totem-xine-firefox-plugin). But if Firefox installed the plug-in, then you need to delete it by hand.

Plug-ins are stored in one of two directories. The $HOME/.mozilla/plugins/ directory stores plug-ins owned by you and that are only available to you; it is created when you install a plug- in without being root. The other directory, /usr/lib/firefox/plugins/, stores system- wide plug-ins. Deleting files from these directories removes unwanted plug-ins from FireFox.

Note 

Some plug-ins create multiple files in the plug-in directory. For example, the Helix plug-in creates nphelix.so and nphelix.xpt. Be sure to delete all the files associated with the plug-in.

Helping Handlers

When a file is downloaded, it can be displayed in the browser window, saved to disk, or passed to another application. Web browsers have two ways to determine how to handle a downloaded file. The first method uses MIME types. For example, HTML pages are text/html, plain text is text/plain, and an image could be image/gif or image/jpeg. Each MIME type contains a general category (for example, text or image) and a specific format identifier (for example, gif or jpeg). The second method uses file name extensions. For example, a file named ch05.doc is a word processor document file, and 05-03.tif is a PNG image.

Note 

Many Unix and Linux applications use a third method to determine file content. Called a magic number file, this method looks at the file's contents for identifying features. The file /usr/share/file/magic under Ubuntu lists the common magic values. Firefox uses this method when no mime-type is available, but not to identify unknown mime-types.

When you access data on a web site, the information is returned with a mime-type. The file name may be specified in the HTTP header, but is usually taken from the end of the URL. If the browser sees something it knows, such as text/html or image/gif, then it renders the file. However, if the browser does not recognize the MIME type (for example, application/binary- octet or video/x-ogm+ogg), then the options are limited: save the file or search for a plug-in. Although other web browsers allow you to associate helper applications to MIME types or file extensions, Firefox does not allow you to create your own helpers.

The solution to this limitation is a plug-in called mozplugger.

 sudo apt-get install mozplugger 

This plug-in creates a configuration file called /etc/mozpluggerrc that allows you to associate a MIME type or file extension with a program on the computer. For example, if you want PostScript (ps and eps) files to open using Ghostview (gv), follow these steps:

  1. Install the Ghostview Postscript viewer (if you have not already installed it).

     sudo apt-get install gv 
  2. As root, add the following lines to /etc/mozpluggerrc:

     application/postscript:ps,eps:Postscript   : gv $file 

    The first line specifies the MIME type, extensions, and a description. Multiple extensions can be placed in a comma-separated list. The second line identifies the handler. The documentation for mozplugger (man mozplugger) explains many more options for this control file, including conditionals and special handling.

  3. Remove the cached plug-in list generated by Firefox. Without this step, new handlers will not be recognized.

     rm $HOME/.mozilla/firefox/pluginreg.dat 
  4. Enter about:plugins in the address bar. Your new handler will be listed in the moz- plugger section.

When using mozplugger, you do not need to close your browser for changes to take effect.

Opening Remote Browsers

Firefox is an intelligent program. It knows how to communicate with other running instances in order to save memory. If you open two browsers and look at the process list for Firefox (ps -ef | grep firefox) you will see only one running process. This is because the second process detected the first and told it to open a new window rather than actually running a new, independent browser.

While reusing code is great for reducing memory requirements, it does have one undesirable side effect: you cannot run a browser remotely if you have one open locally. This situation happens often to system administrators. For example, you will log in to a remote host with X-Windows enabled, and want to run Firefox on that remote host, but want the browser's display shown on your local system. This is different than running the browser on your system because all web-network requests will originate from the remote system. Unfortunately, just running firefox on the remote host will tell your local browser to spawn a new window. Instead, use firefox –no-xshm. This tells Firefox not to communicate through the X-Windows system in order to identify any running browsers. The result is that the remote browser will not see your local browser, it will start running on the remote system, and it will send its display over to your system.

Using Other Web Browsers

Although Firefox is the default web browser, it is not the only one available. Many other browser packages can be installed, including mozilla, epiphany-browser, amaya, konqueror, and lynx.

  • Mozilla-The Mozilla browser is similar to the Mozilla Firefox browser because they stem from the same source. But Mozilla provides slightly different options compared to Firefox.

  • Konquerer-Konquerer is the default browser for the KDE environment. If you choose to install Konquerer, you will need to install the entire KDE run-time environment.

  • Lynx-Although Lynx is a text-based browser, I strongly recommend installing it and knowing how to use it. When you crash X-Windows, lose the graphical display, or are simply using an Ubuntu server installation, you cannot use Firefox to search the web for help-no graphics means no Firefox. As primitive as Lynx may appear, it will allow you to search for help and download patches.

Why Use Different Browsers?

Although some web browsers are suited to different purposes, others just provide alternatives. Many web developers install an assortment of browsers in order to test their web pages. A page you design may look nice under one browser, but have serious problems with a different browser.

I sometimes use different web browsers in place of different Firefox profiles. Even if I give each profile a distinct color scheme, they can still look too familiar. For example, I use one browser for direct Internet use and a different browser for connections through a public proxy. The last thing I want to do is use the direct browser for things that should be done via proxy. If I use two different Firefox profiles at the same time, then I risk mistaking the two windows. But, if I use Firefox for direct access and Mozilla for proxy access, then the browsers look completely different-I won't mistakenly use Firefox thinking it is using the proxy. (See the next section, "Securing Web Access with SSH," to understand why I'd want to use a proxy.)

Mitigating Crashes

Firefox is a pretty stable browser, but it has crashed on me during rare instances. When it crashes, all Firefox windows vanish. Even if you connect with multiple profiles and one window crashes, all Firefox windows close-regardless of the profile. This can seriously impact productivity if you're like me and you heavily depend on web access for your work. A browser crash at an inopportune moment can cost me hours of searching that will need to be redone.

If you're going to access sites that occasionally crash your browsers (in 2006, http://www.cnn.com comes to mind), you can limit the risk from a crash by running a different type of browser. For example, one browser can be used to look at news and entertainment sites and another can be used for work-related web access. Besides making a distinction between work and play, this also prevents a crash due to a fun web site from impacting the work browser. (This is something your boss may care about, even if you don't.)



Hacking Ubuntu
Hacking Ubuntu: Serious Hacks Mods and Customizations (ExtremeTech)
ISBN: 047010872X
EAN: 2147483647
Year: 2004
Pages: 124
Authors: Neal Krawetz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net