Monday, December 13, 2010

How To Block Unwanted Website In Ubuntu Linux

Open Terminal by navigating to Applications->Accessories->Terminal

Use the following command to edit HOSTS file

sudo gedit /etc/hosts

Suppose you want to block YouTube and Facebook on Ubuntu. Just add the following two lines in file as shown in the screenshot and click save.

127.0.0.1 www.youtube.com
127.0.0.1 www.facebook.com

Restart your computer. Now you won't be able to access these websites, no matter whatever web browser you use ;)

Tuesday, August 17, 2010

Easily Create A Custom Ubuntu Live CD With Ubuntu Customization Kit (UCK)

When Ubuntu 10.04 Lucid Lynx comes out, I will probably upgrade instead of doing a fresh install. But I will also create an .ISO file for various usages and my Ubuntu Live CD will have GIMP installed by default (among other changes I will make to my custom ISO)! I'm not going to comment on the decision to exclude GIMP from the default Lucid installation, but I don't want to accept it so I will make a custom Ubuntu Lucid Lynx Live CD.

Ubuntu doesn't support customization before downloading the ISO, but you can customize your Ubuntu Live CD by using UCK - Ubuntu Customization Kit.

Ubuntu Customization Kit is a GUI tool that helps you customizing official Ubuntu Live CDs (including Kubuntu/Xubuntu and Edubuntu) to your needs. You can add any package to the live system, for example language packs, or applications.

Ubuntu Customization Kit

Using Ubuntu Customization Kit (UCK)



To use UCK, you will need (download link at the end of the post):

1. about 5 GB of free disk space in ~/tmp
2. Internet access for fetching language packs
3. apt-source line "deb-src http://archive.ubuntu.com/ubuntu/ karmic main" enabled (necessary for bootlogo building) - "karmic" should be changed if you use a different Ubuntu version.


If you want to build an ISO for an Ubuntu version other than the once you are currently using, you must open your /etc/apt/sources.list and search and replace (temporarily) any occurrence of your current Ubuntu version with the Ubuntu version you want to build the ISO for. Doing this is pretty easy: press ALT + F2, enter:
gksu gedit /etc/apt/sources.list

If for instance you are using Ubuntu Karmic and want to create an Lucid ISO (obviously, you will also need the Lucid ISO), replace "karmic" with "lucid" and save the file. Don't forget to revert the changes after you finish building your custom ISO (repeat the steps above, and replace "lucid" with "karmic" - in my example).

Note: If customizing a CD for another architecture than the installation used for customization the executables from the LiveCD may not run.

If you don't want to build a custom language ISO, you can simply click OK on the first 2 configuration screens, select your default Ubuntu .iso downloaded from the website, then just choose yes when asked if you want to customize the ISO. After this, the fun part begins: you can choose to open the UCK Package Manager which is basically Synaptic, but for UCK and then you can install new packages and remove others:

UCK package manager

You can also chose to select which packages to add / remove, via a terminal.

Once you are done with the customizations, select "Continue building":

uck

Now all you have to do is wait for UCK to finish your custom Ubuntu ISO. On a slow computer, it cant take quite a while. Once the ISO file is ready, it will be saved under ~/tmp/remaster-new-files/livecd.iso.

Thursday, August 5, 2010

UBUNTU 10.04 Tips & Tricks...!!!!!

Customize the Panel

Ubuntu includes a top panel and a bottom panel by default. If you prefer to keep only one panel at the bottom just like the Windows Taskbar, then these are the steps to follow:

  1. Ubuntu DesktopDelete the bottom panel: right-click over it and click "Delete This Panel".
  2. Move the top panel to bottom: right-click over it, select "Properties" and change Orientation from "Top" to "Bottom".
  3. Add running program buttons: right-click the panel, select "Add to Panel", scroll down and select "Window List", click "Add".
  4. Replace the Menu Bar ("Applications-Places-System") with the "Main Menu" to save space in the panel:
    1. Right-click the "Menu Bar" and select "Remove From Panel".
    2. Right-click the panel, select "Add to Panel" and choose "Main Menu", click "Add".
    3. Right-click the items (Firefox, etc) and untick "Lock to Panel".
    4. Right-click the added "Main Menu", select "Move" to relocate it to the far left.

These are basic changes. The panels are much more flexible than the Windows Taskbar in that many items in the panels can be easily added, removed or configured.

Note: If you need to restore the panels to the original state, enter the following commands into the Terminal and re-start the system:

  1. sudo gconftool-2 --shutdown
  2. sudo rm -rf .gconf/apps/panel
  3. sudo pkill gnome-panel

Set Full Transparent Panel

When you set the panel to be transparent in the default Ambiance theme in Ubuntu 10.04, you will find that some panel items' backgrounds are not transparent, but you can make them transparent and consistent with others, following these steps:

  1. Ubuntu DesktopGo to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter cp -R /usr/share/themes/Ambiance ~/.themes/
  3. Enter gedit ~/.themes/Ambiance/gtk-2.0/gtkrc to open Ambiance's ftkrc file with gedit.
  4. Search for this line bg_pixmap[NORMAL] = "panel_bg.png"
  5. Ubuntu DesktopComment out the line by placing a # at the beginning of the line, like this: # bg_pixmap[NORMAL] = "panel_bg.png"
  6. Save the gtkrc file.
  7. Go to System > Preferences > Appearance, switch to the other theme and then back to the Ambiance theme.

Note: If you'd like to change to the Radiance theme, replace Ambiance with Radiance in the above command lines, but you'd like to change to the New Wave theme, then enter cp -R /usr/share/themes/"New Wave" ~/.themes/ in step 2, enter gedit ~/.themes/"New Wave"/gtk-2.0/gtkrc in step 3, search for and comment out this line bg_pixmap[NORMAL] = "Images/Panel/PanelBarLong.png" in steps 4 and 5 respectively.

Customize the Theme

Themes in Ubuntu can be customized to match the applications or suit your needs. I once tried the "New Wave" theme and the menu (File, Edit, View, etc) was hardly visible on the dark background in OpenOffice. These are easy steps to customize a theme, for example, "New Wave" so that the menu can be more visible in OpenOffice.

  1. Customize the ThemeGo To System > Preferences > Appearance.
  2. Under the "Theme" tab, click the "Customize" button while the "New Wave" theme is selected.
  3. Under the "Controls" tab, click any other control item such as "Ambiance" and click the "Close" button.
  4. Now it becomes your Custom theme and you can save it as a new theme, such as "New Wave with Ambiance Controls".

The menu should now be clearly visible in OpenOffice in this new theme (See the lower section in the screenshot).

Set Aero Glass Effect

In Ubuntu you can set nearly the same aero glass effect to window borders with alpha transparency as available in Windows 7.

  1. Aero Glass EffectPress Alt-F2 to bring up "Run Application" window.
  2. Type gconf-editor into the box, click "Run" to bring up Configuration Editor.
  3. Browse to apps > gwd, look for "metacity_theme_active_opacity" on the right panel.
  4. Change the value in "metacity_theme_active_opacity" from 1 to 0.75 (or smaller such as 0.5 for more transparency).
  5. Then go to System > Preferences > CompizConfig Settings Manager
  6. Select "Effects" from the left panel.
  7. Tick "Blur Windows" and click the "Close" button. (Note: default values in Blur Windows can be applied.)

Pin Programs to the Panel

Frequently used programs can be easily pinned to the panel.

  1. Browse to the program from "Applications" or "Main Menu".
  2. Drag and drop the program to an empty space in the panel, or right-click the program and select "Add this launcher to panel".
  3. Right click the program icon, select "Move" and drop it to a new place in the panel.
  4. Right click the program icon and select "Lock to Panel".

See also "Enable Windows 7 Superbar".

Hide Drive Icons on the Desktop

Ubuntu adds an icon to the desktop for every removable drive that you attach to your system. The icons can be hidden by these steps:

  1. Press Alt-F2 to bring up "Run Application" window.
  2. Type gconf-editor into the box, click "Run" to bring up Configuration Editor.
  3. Browse to apps > nautilus > desktop.
  4. Untick "volumes_visible" and close the window.

The drive icons would then disappear from the desktop. Remember that you can always access the drives from "Places".

Move Window Control Buttons to the Right

Ubuntu 10.04 sets the Minimize, Maximize and Close buttons to the left in a window. If you prefer to change them to the right, follow these simple steps:

  1. Move buttons to rightPress Alt-F2 to bring up "Run Application" window.
  2. Type gconf-editor into the box, click "Run" to bring up Configuration Editor.
  3. Browse to apps > metacity > general, look for "button_layout" on the right panel.
  4. Change the value in the "button_layout" from close,minimize,maximize: to menu:minimize,maximize,close and press the Enter key.

Set a Default View in File Browser

Windows Explorer allows for users to set a default view to all folders. In almost the same way, Ubuntu's Nautilus File Browser allows for these settings:

  1. Set File BrowserGo to "Places" and open a folder.
  2. At the top of the File Browser, click "Edit" and "Preference".
  3. Under Default View, change "Icon View" to "List View", to see more details in columns.
  4. Tick "Show hidden and backup files" if that's your choice.

Other various settings, such as single or double click to open items, icon captions, list columns, preview files and media handling can be done in the same window as well.

Open Up a Window in Center

When running an application without maximized, Ubuntu always puts it in the left-top corner of the desktop by default, but you are allowed to set a program window to open up in the center of the desktop area.

  1. CompizConfig Settings ManagerGo to System > Preferences > CompizConfig Settings Manager
  2. Select "Windows Management" from the left panel.
  3. Click "Place Windows".
  4. Change Placement Mode from "Smart" to "Centered", click "Back" and "Close".

Ideally, the window manager in Ubuntu should restore the last known position of an application window, but it does not do that unless an application remembers its own window position. (See reported bugs)

Enable "Rotate Cube" Effect

Ubuntu enables "Desktop Wall" by default. By holding Ctrl-Alt keys and pressing the left-arrow or right-arrow key each time, it slides through desktop workspaces horizontally for you to choose one to work on. Alternatively, you can change this to a "rotate cube" effect.

  1. Rotate CubeGo To System > Preferences > CompizConfig Settings Manager
  2. Select "Desktop" from the left panel.
  3. Tick "Rotate Cube".
  4. Select "Eable Desktop Cube" as this plugin is required by "Rotate Cube".
  5. Select "Disable Desktop Wall".

Immediately you can rotate your desktop workspaces in this way— holding down Ctrl-Alt keys, EITHER press the left-arrow or right-arrow key OR left-click the mouse and drag it to left or right.

Enable Windows 7 Superbar

In Windows 7, frequently used programs can be pinned to the taskbar (hence called Superbar). Likewise, DockBarX, a Gnome panel plugin, can be added to Ubuntu to achieve almost the same effect to pin and unpin or launch the applications from the panel.

  1. DockBarX AppletGo to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter wget https://launchpad.net/~dockbar-main/+archive/ppa/+files/dockbarx_0.30.0-0~ppa0_all.deb
  3. Enter wget https://launchpad.net/~dockbar-main/+archive/ppa/+files/gnome-dockbarx-applet_0.30.0-0~ppa0_all.deb
  4. Enter sudo dpkg -i *dockbarx*.deb
  5. Enter sudo apt-get install -f
  6. Log out then log into the system, right click the panel and click “Add to Panel”.
  7. Select the DockBarX Applet and click "Add".

Note: A thumbnail preview of a running program is a beta feature in DockBarX 0.30. To enable this feature, right-click the DockBarX item on the panel, select Properties, choose Advanced tab and tick "Show Previews".

Enable Windows 7 Aero Snap

In Windows 7, you can click and drag a window to the left or right edge of the desktop and it will fill half of the screen, or snap a window to the top edge of the desktop and it will be maximized.

In Ubuntu 10.04, you can click and drag a window to the left, right or top edge of the desktop to achieve the same result.

  1. In addition to CompizConfig Settings Manager, install WmCtrl if not added.
    1. Go to Applications (or Main Menu) > Accessories > Terminal.
    2. Enter sudo apt-get install wmctrl
    3. Enter password when prompted.
  2. Go To System > Preferences > CompizConfig Settings Manager.
  3. Select "General" from the left panel and click "Commands".
  4. In Command line 0, 1 and 2, paste the following codes:
    1. Command line 0, paste WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
    2. Command line 1, paste WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
    3. Command line 2, paste wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
  5. In the same window, click "Edge Bindings" tab.
  6. Change Run Command 0, 1 and 2 from "None" to "Left", "Right" and "Top" respectively.
  7. Click "Back" button and select "General Options", change "Edge Trigger Delay" to about 500.

Auto Mount Drives at System Startup

Ubuntu is capable of reading and writing files stored on Windows formatted partitions, but partitions must be 'mounted' before they can be accessed each time you start up the system. With these steps, you can auto mount the drives without the need to manually mount them for access.

  1. Storage Device ManagerInstall Storage Device Manager if it has not been added.
    1. Go to Applications (or Main Menu) > Ubuntu Software Center.
    2. Enter pysdm in the Search Box.
    3. Select Storage Device Manager, click the "Install" button.
  2. Go to System > Administration > Storage Device Manager, enter password.
  3. Extend the list of sda and select the sda you want to auto mount, click 'OK' to configure.
  4. Click the "Assistant" button.
  5. Uncheck "Mount file system in read only mode" and keep "The file system is mounted at boot time" checked.
  6. Click the "Mount", "Apply" then "Close" button, and restart the system.

If you wish to remove the auto-mount of a certain drive, you can similarly use Storage Device Manager to do the setting.

Manually Mount a USB Drive

A USB storage device plugged into the system usually mounts automatically, but if for some reasons it doesn't automount, it's possible to manually mount it with these steps.

  1. Go to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter sudo mkdir /media/usb to create a mount point called usb.
  3. Enter sudo fdisk -l to look for the USB drive already plugged in, let's say the drive you want to mount is /dev/sdb1.
  4. Enter sudo mount -t vfat /dev/sdb1 /media/usb -o uid=1000,gid=100,utf8,dmask=027,fmask=137 to mount a USB drive formatted with FAT16 or FAT32 system. OR:
    Enter sudo mount -t ntfs-3g /dev/sdb1 /media/usb to mount a USB drive formatted with NTFS system.

To unmount it, just enter sudo umount /media/usb in the Terminal.

Enable Media Playback

Ubuntu only includes completely free software by default and does not configure proprietary media formats such as mp3 and mp4 'out of the box'. The required codecs however can be easily installed for the default player to playback these files following a few simple steps below.

  1. Double click an mp3 file in a folder.
  2. Click "Search" button when the the default player shows up with a "Search for suitable plugin?" window.
  3. Click the "Install" and "Confirm" buttons to download and install the restricted software.
  4. Restart the player after the package files are installed.

You might need to do the same for other restricted media formats such as mp4 too.

Set Sound Output

When I first installed Ubuntu onto a PC with an integrated audio device and tried to play a media file on a player, it had no sound. I tried these simple steps in setting Sound Preferences and then it had sound. It works for me for the audio device I have.

  1. Go to System > Preferences > Sound to bring up the Sound Preferences window.
  2. Under the Hardware tab, change Profile to Analog Stereo Duplex from the drop-down menu.
  3. Under the Output tab, change Connector to Analog Output (LFE)/Amplifier from the drop-down menu.

As the items available from the drop-down menus might differ depending on the hardware devices detected by the system, you might want to try other items in the menus to see if they work for your devices. It might also help to check out the steps in Sound Troubleshooting from the Ubuntu Documentation.

Playing a media file in a proprietary format on a player might also have no sound if the required codecs are not installed. In this case, see Enable Media Playback in this article.

Terminate Unresponsive Programs

Xkill is part of the X11 utilities pre-installed in Ubuntu and a tool for terminating misbehaving X clients or unresponsive programs. You can easily add a shortcut key to launch xkill with the steps below.

  1. xkillGo to System > Preferences > Keyboard Shortcuts.
  2. Click the Add button to create a custom shortcut.
  3. Enter xkill to both the Name and Command boxes and click the Apply button.
  4. Click on Disabled at the xkill row in the Keyboard Shortcuts window (Disabled is then changed to New shortcut...).
  5. Press a new key combination, e.g. Ctrl+Alt+X (New shortcut... is then changed to Ctrl+Alt+X).
  6. Click the Close button.

Xkill is ready for use. Press the above key combination to turn the cursor to an X-sign, move the X-sign and drop it into a program interface to terminate the unresponsive program, or cancel the X-sign with a right-click.

Change Default Boot Options

After full installation, Ubuntu is set to be the default operating system to boot up if no key is pressed within a few seconds on a multi-boot system. You might want to set your preferred operating system to boot up by default. This can be done easily with StartUp-Manager.

  1. StartUp-ManagerGo to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter sudo apt-get install startupmanager(or copy the highlighted code and press Ctrl-Shift-V to paste it in the Terminal).
  3. Enter password used upon installation of Ubuntu.
  4. Go to System > Administration > StartUp-Manager
  5. Enter the same password to perform pre-configuration tasks, which include searching bootloaders to operating systems.
  6. Select the default operating system from the pull-down menu, click "Close" to perform post-configuration tasks.

With StartUp-Manager, you can also do others such as manage Usplash themes, adjust bootloader menu resolution or set timeout in seconds. Avoid changing timeout to 0 seconds if you need to select a system to boot up from a multi-boot menu.

Remove Old Linux Kernel, Clean Up Boot Menu

Each time when Ubuntu updates to a new Linux kernel, the old one is left behind and the boot menu gets longer. If your new Linux kernel works well, it's safe to remove the old one and clean up the boot menu. Do take these steps carefully as incorrect removal of the items can make your system unbootable.

  1. Go to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter uname -r to print the Linux kernel version you're running (e.g. 2.6.32-22-generic).
  3. Go to System > Administration > Synaptic Package Manager.
  4. Click Status from the left panel and select Installed.
  5. Enter the main version number (e.g. 2.6.32) in the Search box.
  6. Right-click the items with smaller sub version number (e.g. 2.6.32-21) for older Linux kernel and select Mark for Complete Removal. The files for the older version to remove may include linux-headers-2.6.32-21, linux-headers-2.6.32-21-generic and linux-image-2.6.32-21-generic.
  7. Click Apply from the top panel.
  8. Click Apply again from the pop-up window to confirm removal of the marked packages. The boot menu will be cleaned up automatically after the removal is confirmed.

Auto Shutdown the System

A simple command can be entered in the Terminal to schedule a time for the system to shut down.

  1. Go to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter sudo shutdown -h +m (replace m with the number of minutes, e.g. +60).
    OR: enter sudo shutdown -h hh:mm (replace hh:mm with the time on the 24hr clock, e.g. 23:15).
  3. Enter password and minimize the Terminal window.

The system will then shut down within the minutes or at the time specified. To cancel a scheduled time, enter sudo shutdown -c in the Terminal.

GShutdown is a GUI program for scheduling a time to shutdown the system but the current version 0.2 is noted not working well in both Ubuntu 9.10 and 10.04.

Install Extra Fonts

Do you prefer Windows TrueType fonts to the default fonts installed by Ubuntu? The Windows fonts can be installed and activated easily in a few steps below:

  1. Ubuntu Extra FontsGo to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter sudo apt-get install ttf-mscorefonts-installer(or copy the highlighted code and press Ctrl-Shift-V to paste it in the Terminal).
  3. Enter password used upon installation of Ubuntu.
  4. Go to System > Preferences > Appearance > Fonts.
  5. Click each of them and pick a font and size.

The screenshot here uses the following settings:

Application font: Verdana 9
Document font: Verdana 11
Desktop font: Verdana 11
Window title font: Sans Bold 10
Fixed width font: Monospace 10

After completing the above steps, if you like the Tahoma font which is not included in the mscorefonts package, you might want to copy the two files tahoma.ttf and tahomabd.ttf from /Windows/Fonts to the Desktop. Next, move them to the restricted folder by entering sudo mv Desktop in the Terminal. This font will then be available in step 4 above.

Install Screenlets

Screenlets are small applications to represent things such as sticky notes, clocks, calendars around on your desktop. You can launch a pre-installed screenlet from Screenlet Manager, or install a new one into the Manager for launching it. Here are the steps for installing and launching a screenlet, for example, WaterMark System Information.

  1. WaterMark ScreenletInstall Screenlets Manager if it has not been added.
    1. Go to Applications (or Main Menu) > Ubuntu Software Center.
    2. Enter screenlets in the Search Box.
    3. Select Screenlets, click the "Install" button.
  2. Download the screenlet "WaterMark System Information" to a folder.
  3. Go to Applications (or Main Menu) > Accessories > Screenlets.
  4. Click Install, select Install Screenlet and click OK.
  5. Browse to the folder, select the file downloaded and click "Open" to install the screenlet into the Screenlets Manager.
  6. Select the screenlet "WaterMark" and click "Launch/Add". (Tips: you can add more than one WaterMark screenlet and set it to display other system information.)

More screenlets are available for installation from screenlets.org.

Install Sun Java Packages

Ubuntu uses OpenJDK by default, but I note that some web services such as ezyZip.com might need the Sun Java Runtime Environment (JRE) to be installed in the system for running the services properly. If you would like to get the proprietary Sun Java packages for your system, you can download and install them from the Canonical Partner Repository with the steps below:

  1. Go to Applications (or Main Menu) > Accessories > Terminal.
  2. Enter sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" to add the partner repository.
  3. Enter sudo apt-get update to update the source list.
  4. Enter sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts to download and install the Sun Java packages. (If asked to accept the Distributor License for Java (DLJ) terms, use the left/right key to navigate and select Yes, then press the Enter key for installation).
  5. Enter sudo java -version to check the version of the Java used in the system.
  6. Enter sudo update-alternatives --config java to choose the default Java for use in the system when necessary.

Install More Useful Software

Ubuntu Software Center lets you search and get free software. If an application you need is not included in the Center, you can go to System > Administration > Synaptic Package Manager, type in an application name to search and install a software package from the repositories.

Alternatively, you can get the latest freeware applications by clicking the Install this now button from the GetDeb Repository after the getdeb package is installed with the instructions given.

See also our Best Free Software for Linux.

Note: CompizConfig Settings Manager (ccsm) can be installed here if not added:

  1. Click "Applications" (or "Main Menu"), select "Ubuntu Software Center".
  2. Type ccsm into the Search box.
  3. Select "Advanced Desktop Effects Settings (ccsm)" and click the "Install" button.
  4. Enter the password used upon installation of Ubuntu.

Friday, July 30, 2010

Why Linux is Better Than Windows

Our Linux Top 10 Reasons


  1. Security - Linux is Open Source Software, while Windows is not. The simplest benefits of Open Source Code to demonstrate are increased security, reliability and functionality; because users of Open Source are readily able to identify and correct problems with the programs and to submit their own enhancements for incorporation into the program. Closed Source systems enjoy none of those benefits.
  2. Scalability - Systems implemented under Linux can be cloned limitless times without paying additional software licensing fees - With Windows, you pay for each installation/workstation/server/cpu.
  3. Power - Linux is made with the Unix design philosophy, which dictates that system tools are small and highly specialized. The result is an incredibly powerful and reliable system, limited in capability only by the user's imagination and ability to integrate the Unix utilities. The Windows philosophy is to create unwieldy swiss army knives, limited in capability by how many features the user purchased on their particular knife. Diminished reliability is arguably a side effect of increased complexity. Thus with Windows, the case is often that you have tools that ALMOST do what you want them to, if they didn't crash.
  4. Reliability - The architecture of Linux is superior to Windows because critical operation system functions are implemented in such a way that buggy programs can't cause the computer to become unstable and crash. In fairness, though not quite as robust as Linux, Windows 2000 and Windows XP are much improved over Windows 9x and Windows Millenium Edition.
  5. Advanced Capabilities - In addition to the system utility tools from the Unix world, Linux usually comes with the Apache Webserver, an email server, router/firewall capabilities and SQL databases. These are extras costing up to thousands of dollars on Windows. There IS free software to do these jobs on Windows, but it has mostly been adapted from Linux and loses some functionality when ported to Windows.
  6. Compatibility - Linux is POSIX Compliant which means that applications developed for Linux can be operated on other POSIX compliant Unix derivatives with a minimum of reworking.
  7. Support - For persons not familiar with the Open Source Community, the quality of free technical support on the internet may come as a shock. Sometimes knowing enough to ask the right questions can be a problem, but overall the best and the brightest are there to assist you at no charge when you run into problems that can't be solved by reading the documentation included with Linux. With Windows or other commercial software, your manufacturer support is only free for a limited time and is often of little value anyways.
  8. Not Single Source Software - Linux is distributed by several companies, giving consumers to pick and choose the flavor that best suits their needs. Windows is the product of a single company, Microsoft Corporation. Windows users have no choice but to accept what Microsoft offers.
  9. Rate of Advancement - Linux has and will continue to advance at a rate impossible for a close development project such as Microsoft Windows to sustain. A few factors driving this rate of progress are (in no particular order): the number of active developers; quantity and quality of feedback from the field; short development cycle from development team to the end user; absence of corporate "meddling" in the design process; independently developed open source subsystems frequently incorporated into Linux, giving it quantum advances in a short time.
  10. Cost - That Linux is FREE deserves honorable mention and a bit of explanation. You can package and sell Linux for money. The competing Linux distributions all provide slightly different feature sets beyond the core system, including canned e-commerce solutions, printed manuals and phone support options. There is no rule that says you can't make money distributing Linux. For those who choose to download and install free distributions from the Internet, Linux is truely free. Some cynics have proclaimed, "Sure Linux is free now, but the Linux People will start charging for it once it catches on!". That statment is completely false. No single person or organization controls Linux, so that will never happen. In the unlikely case that Linus Torvalds (the author of Linux) adds some proprietary code and proclaims that all future releases will be $99.99USD, someone will simply take the latest "free" version and possibly rename it to Spin-UX. Then all the volunteer developers and contributors will jump on that bandwagon. Spin-UX will diverge from its Linux roots, over time becoming better supported and more advanced, rendering its ancestor obsolete, except possibly for purposes specifically addressed by that hypothetical proprietary added code. Furthermore Linux is covered by the Gnu Public License, stating that it and all derivative works must be distributed with the source code. This makes it extremely unlikely that anyone will wield monopolistic power in the Linux Sector.

To conclude this hopefully persuasive bit of Linux Advocacy, it must be stated that an Operating System without suitable Applications is of little use. There are free web browsers and email clients for Linux, as well as the free Star Office product from Sun Microsystems. Star Office includes the traditional productivity applications: Word Processing, Spreadsheet and Database. Corel Office is also available for Linux at little or no charge.

As more small businesses adopt Linux, the number of Indepdendent Software Vendors offering industry specific (Vertical Market) applications will increase. As I learn of business applications designed for Linux, I will document them on this site.

Saturday, July 10, 2010

Mounting Linux Partitions in Ubuntu

If you plug in an external hard drive with a Linux filesystem, it will automount and show up on your desktop, just like any external media. But what if you have an internal hard drive or partition with a Linux filesystem? Well, that's what this tutorial is about.

Warning: The tutorial on this page is for an internal drive that will serve as an extra data partition. If you would like to mount a separate drive or partition as /home instead, you want a different tutorial.

First you have to determine what the partition is called and what filesystem it is. One quick way to do it if you know what filesystem you formatted the drive as (Ext3, for example) is to just type the terminal command

sudo fdisk -l

Here's how it could come out:

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000eb4ba

Device Boot Start End Blocks Id System
/dev/sda1 * 1 524 4208006 83 Linux
/dev/sda2 525 1044 4176900 83 Linux

As you can see, I'm able to locate that /dev/sda2 is my Linux partition, but in System, I don't find out if it's Ext3, Ext4, Reiserfs, or what it is. If I happen to know it's Ext4, cool.

But let's say I didn't know. Well, one way to find out for sure is to install GParted and find out:

sudo apt-get update
sudo apt-get install gparted gksu
gksudo gparted


You can go to System > Administration > GParted and enter your password to get it started.


Ah, now I can definitely see it's Ext4 for sure. Under Partition I see it's /dev/sda2, and under Filesystem, I see it's Ext4.

If you have a second physical hard drive (not just another partition), you might have to click on the top-right corner to focus on the second hard drive. (Click on the down-pointing arrow to get the drop-down menu.)

So now I'll create a mount point for that partition:

sudo mkdir /storage

Next, I want to determine the UUID of my partition.***

ls -l /dev/disk/by-uuid
and I get back this output:
total 0
lrwxrwxrwx 1 root root 10 2010-04-26 12:00 20bfd80a-a96b-461c-a63d-c96ff8e95872 -> ../../sda1
lrwxrwxrwx 1 root root 10 2010-04-26 19:19 d1d0cf46-958f-4a12-a604-0ac66040648b -> ../../sda2
Then I'll edit my /etc/fstab file:
sudo cp /etc/fstab /etc/fstab_backup
sudo nano /etc/fstab

Once in there, I should add in this line:

UUID=d1d0cf46-958f-4a12-a604-0ac66040648b /storage ext4 defaults 0 0

Then I can save (Control-X), confirm (Y), and exit (Enter).

Since we've made changes to the /etc/fstab file, we need to have Ubuntu acknowledge those changes:

sudo mount -a

Now I need to give it the proper permissions. Let's just assume, for this example, that my username is jessica.

sudo chown -R jessica:jessica /storage
sudo chmod -R 755 /storage

Now the partition is mounted in the /storage folder and is ready for use!

*** Yes, I could just use the name of it (/dev/sda2), but UUID is more precise. It's unlikely that I'll unplug my internal drive, plug in a new internal drive, and then plug back in my original internal drive so that the partition names are reassigned. Still, it's safer to use the exact partition identifier in /etc/fstab.


Command Line Partitioning

You'll be using "fdisk" to accomplish this. Refer back to the logical name you noted from earlier. For illustration, I'll use /dev/sdb, and assume that you want a single partition on the disk, occupying all the free space.

If the number of cylinders in the disk is larger than 1024 (and large hard drives always have more), it could, in certain setups, cause problems with:

  1. software that runs at boot time (e.g., old versions of LILO)
  2. booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)

Otherwise, this will not negatively affect you.

1) Initiate fdisk with the following command:

  •   sudo fdisk /dev/sdb 

2) Fdisk will display the following menu:

  •   Command (m for help): m 
    Command action
    a toggle a bootable flag
    b edit bsd disklabel
    c toggle the dos compatibility flag
    d delete a partition
    l list known partition types
    m print this menu
    n add a new partition
    o create a new empty DOS partition table
    p print the partition table
    q quit without saving changes
    s create a new empty Sun disklabel
    t change a partition's system id
    u change display/entry units
    v verify the partition table
    w write table to disk and exit
    x extra functionality (experts only)

    Command (m for help):

3) We want to add a new partition. Type "n" and press enter.

  Command action
e extended
p primary partition (1-4)

4) We want a primary partition. Enter "p" and enter.

  Partition number (1-4):

5) Since this will be the only partition on the drive, number 1. Enter "1" and enter.

  Command (m for help):

If it asks about the first cylinder, just type "1" and enter. (We are making 1 partition to use the whole disk, so it should start at the beginning.)

6) Now that the partition is entered, choose option "w" to write the partition table to the disk. Type "w" and enter.

  The partition table has been altered!

7) If all went well, you now have a properly partitioned hard drive that's ready to be formatted. Since this is the first partition, Linux will recognize it as /dev/sdb1, while the disk that the partition is on is still /dev/sdb.

Command Line Formatting

To format the new partition as ext3 file system (best for use under Ubuntu):

  •   sudo mkfs -t ext3 /dev/sdb1

To format the new partition as fat32 file system (best for use under Ubuntu & Windows):

  •   sudo mkfs -t fat32 /dev/sdb1

As always, substitute "/dev/sdb1" with your own partition's path.

Modify Reserved Space (Optional)

When formatting the drive as ext2/ext3, 5% of the drive's total space is reserved for the super-user (root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.

NOTE: You may run this command on a fat32 file system, but it will do nothing; therefore, I highly recommend not running it.

You can adjust the percentage of reserved space with the "tune2fs" command, like this:

 sudo tune2fs -m 1 /dev/sdb1

This example reserves 1% of space - change this number if you wish.

  • {i} Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.

Create A Mount Point

Now that the drive is partitioned and formatted, you need to choose a mount point. This will be the location from which you will access the drive in the future. I would recommend using a mount point with "/media", as it is the default used by Ubuntu. For this example, we'll use the path "/media/mynewdrive"

  •   sudo mkdir /media/mynewdrive

Now we are ready to mount the drive to the mount point.

Mount The Drive

You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.

Automatic Mount At Boot

You'll need to edit /etc/fstab:

  •   gksu gedit /etc/fstab

Add this line to the end (for ext3 file system):

  •   /dev/sdb1    /media/mynewdrive   ext3    defaults     0        2

Add this line to the end (for fat32 file system):

  •   /dev/sdb1    /media/mynewdrive   vfat    defaults     0        2
    The defaults part may allow you to read, but not write. To write other partition and FAT specific options must be used. If gnome is being used, use the right-click, mount method. Then launch the mount command from terminal, no options. The last entry should be the FAT drive and and look something like:
      /dev/sda5 on /media/mynewdrive type vfat
  • (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)

  • All of the parts between the parenthesis are the mount options and should replace "defaults" in the fstab file. The "2" at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to "0" will skip this. Run 'man fstab' for more info here.

You can now run "sudo mount -a" (or reboot the computer) to have the changes take effect.

If you want to allow a normal user to create files on this drive, you can either give this user ownership of the top directory of the drive filesystem: (replace USERNAME with the username)

  •   sudo chown -R USERNAME:USERNAME /media/mynewdrive

or in a more flexible way, practical if you have several users, allow for instance the users in the plugdev group (usually those who are meant to be able to mount removable disks, desktop users) to create files and sub-directories on the disk:

  •   sudo chgrp plugdev /media/mynewdrive
    sudo chmod g+w /media/mynewdrive
    sudo chmod +t /media/mynewdrive

The last "chmod +t" adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).

Manually Mount

Alternatively, you may want to manually mount the drive every time you need it.

For manual mounting, use the following command:

sudo mount /dev/sdb1 /media/mynewdrive 

When you are finished with the drive, you can unmount it using:

sudo umount /media/mynewdrive
That's it :)