Saturday, July 5, 2014

Tor in Ubuntu 14.04

Earlier I had written how to use tor with Ubuntu 12.04 and 11.10 . Those methods have become pretty outdated. With the recent versions of tor browser bundle the process of setting up tor is simpler. But to use use tor with other applications you need to still a bit of tweaking.


1. Set up tor browser bundle

         The first step is to download tor browser bundle and extract  it. Tor can be launched by running start-tor-browser script in extracted directory. If permission is denied then run "chmod -R a+x * in a terminal to add executable bit to the files. During first run, set the proxy  settings and exit tor. Start tor again. Once the connection is established tor browser will come automatically. This is a tweaked version of firefox. By default, add-ons and other extensions are disabled.  If you want to use tor just for browsing rest of the steps are irrelevant for you.

2. Find out the Control and Socks Port

          Inside the tor browser bundle directory  there is a Data/Tor directory which contains the torrc-defaults file. The Control and SocksPort are present in the file. In my case it is as follows :
SocksPort 9150
ControlPort 9151

3. Socks proxy
      
        Your socks proxy will be 127.0.0.1:SocksPort. In my case it is 127.0.0.1:9151. This can be set as the proxy in any application to use it under socks proxy provided by tor.

4.  Setting up http and https proxy for tor

     4.1 For this install polipo and make sure that privoxy is not installed.

           

     4.2 Use  sudo visudo and add the following lines at the end of file:

           

    4.3 Using editor command sudo gedit /etc/polipo/config replace the contents of /etc/polipo/config with the following content. Make sure that 9150 is replaced with your Socks Port found in step 3.

         

   4.4 Restart polipo.

           

   4.5 Set polipo not to start by default

        We have to remove the polipo service from startup. For that sudo apt-get install sysv-rc-conf. After installation run sudo sysv-rc-conf. It will display a table , scroll down by the use of arrow key to the line with polipo and disable all selections by the use of space key.  sysv-rc-conf  can be quit by using the key q.
 
Now u can use the proxy 127.0.0.1:8118 as http, https and ftp proxies under tor. After tor connects run 'sudo service polipo start' to start the polipo service.

5.  To use tor in firefox follow either steps
 
a) Set the proxy to
http , https and ftp 127.0.0.1:8118
socks host 127.0.0.1:9150
bc) Use foxyproxy for custom proxy management
use 27.0.0.1:8118 and other proxies in a mixed manner specifying custom patterns in urls. (I prefer this method ).
6.  For torrent use the client vuze. and set the http or socks proxy.

7. Using tor from Virtual machine.

 If you are using virtualbox then we can use the host tor network in the guest os. For that set all proxy in guest OS as : 10.0.2.2:8188

Sunday, March 16, 2014

Some Useful Tips and Applications for Ubuntu

I have been using Ubuntu since 06.06 and during these years I have found out that there are certain things in Ubuntu (or any Linux) that will come to you by experience only. Here I am sharing some useful tips and softwares that might help new Ubuntu users. 
  1. Home Partition: I will begin with the installation. The most helpful thing I guess will be creating a separate home partition. You can create a home partition of Ext4 format and mount it under /home. This is recommended because this will help you to reinstall Ubuntu again without losing any files or settings as you will not need to format the home partition every time. The partitioning can be done using the Ubuntu installer or Gparted available in the Ubuntu installation media. If you use the same home partition across multiple installations with same username it will work.  
  1. Installation on EFI systems: The detailed explanation on how to do this can be seen in my previous post here. 
  1. Archive Managers: The major packages that are helpful in creating or opening archives included unzip, unrar, p7zip-full, cabextract, etc. The packages needed for tar baz2 are preinstalled on Ubuntu. All these packages can be installed from a terminal using apt-get, aptitude or apt-fast. 
  1. Tweaking and Adjusting : Unity tweak tool is very good tools for tweaking the GUI. It can be used to activate hot corners, window spread, window snapping, launcher, panel, etc. There are many other features that can be tweaked with this tool. Other pretty advanced tools are compiz-config-settings-manager and dconf-editor. These two tools have large number of options tweaking which might lead to trouble also.  
  1. Download management: Most of the windows users are used to IDM or DAP for download accelaration and management. Downloads can be managed on a command line level using tools like wget, aria2, curl, etc. Flareget is a pretty good download accelerator and manager. The free version of the software doesn’t have browser integration and supports only up to 2 connections per download for files bigger than 25 MB. The browser integration can be achieved in Firefox using the flashgot add-on.  
  1. Power and temperature management: Heating and power management are two other issues in Ubuntu. The problems are interlinked and can be solved simultaneously. The detailed discussion on this problem is addressed in  one of my previous posts. 
  1. Intel-AMD dual graphics : This is a serious headache and I don’t know any method to make them work (If anyone knows a method please inform me through comments. I will add it to the text). The AMD-AMD dual graphics works without any problem with fglrx. This can cause a lot of heating up of system and the only  practical solution I know is to switch off the AMD cards and work with the Intel cards. The AMD cards can be turned of using the command: 
    echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
    This can be made permanent by editing the rc.local file in /etc or /etc/rc.d/ folder. Then add the following text to the file before the line 'exit 0'  
    chown /sys/kernel/debug/vgaswitcheroo/switch 
    echo OFF > /sys/kernel/debug/vgaswitcheroo/switch 
    If you have receive a ‘No such file or directory’ when running  the following command:
    cat /sys/kernel/debug/vgaswitcheroo/switch
    then open /etc/fstab and add the following line: 
    none          /sys/kernel/debug      debugfs        defaults    0      0 
  1. Bash History : The bash history can be accessed by using the history command. But the default Ubuntu settings has a limit up to which the history is saved. This can be changed by editing the .bashrc file in home folder. (The file is hidden and can be unhide by pressing Ctrl+H). The values of following two lines must be kept empty 
    HISTSIZE= 
    HISTFILESIZE= 
  1. Bleachbit :This is a tool similar to Ccleaner in windows. This a very powerful tool which can be run as sudo to clean the caches of APT, X11 etc. The normal user can clean the browser and other application caches. Please be sure to tick only those things you want to clear. There is option to clean bash history also which may be bad for many people who use history in terminal. 
  1. Open in terminal : The open in terminal extension available for nautilus is a  very useful tool. This helps to add a open in terminal option to the right click menu and can start a terminal from any location. The package can be installed by using the command : 
    sudo apt-get install nautilus-open-terminal 
    nautilus -q
    The nautilus -q command will restart nautilus closing all nautilus windows. 
  1. Creating a launcher : Certain applications installed doesn’t have a launcher by default. This problem can be solved by creating a launcher by yourself. The launcher is created as a file something.desktop and is to be placed under ~/.local/share/applications and need to be marked as executable. The following is an example content of a launcher. The Name will be displayed in dash with the Icon mentioned. The Exec will have the command to be excecuted
    [Desktop Entry] 
    Name=Name of Application
    Type=Application 
    Icon=path to icon
    Exec=path to executable with arguments if any 
  1. Microsoft Office : MS-Office can be installed and used with Ubuntu under wine. This is explained in detail in my previous posts (MS Office 2007 in 12.04/12.10, MS Office 2007 in 11.10, MS Office 2010 in 12.10/13.04/13.10)
  1. Movie and Music : The codecs can be installed to play all audio and video from the default movie player. The codecs can be found in synaptic package manager by searching the keyword gstreamer. The players like VLC can also be installed. For playing music I prefer clementine which offers music library, file browsing and playlist features. For audio editing softwares like audacity can be used. 
  1. Mounting NTFS filesystems permenantly : This can be done by editing the fstab file in /etc. By adding a line like this you can mount them during boot. The UUID can be found from gparted or running the command 'sudo blkid'.
    UUID=xxxxxxxxxxx mount path ntfs defults,umask=007,gid=46 0 0 
  1. Apt-fast : Apt-fast is an alternative to apt-get which can download the packages using multiple connections by using download managers like aria2. 
  1. Kernel Parameters: Installation of Ubuntu in  a system with Graphics card (mostly when you have dual graphics card) many times it fails to boot into GUI. The system will boot up to a low graphics mode or tty. In this case the system can be booted into GUI using the parameter 'nomodset'. If the system fails to boot into GUI and instead it boots to tty the problem can be solved using the parameter 'vt.handoff=7'.  
  1. Brightness Control: If the brightness control is not working then it can be solved by adding boot parameters.This can be done by editing the file /etc/default/grub. There will be something like:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 
    Change it to
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
    Save the file and run the command sudo update-grub and reboot. 
If you want anything else to be added to this post please inform me by comments. I will incorporate them if I know how to do it

Monday, February 3, 2014

Install Ubuntu on UEFI enabled Computers

Recently I have came across many people asking how to install Ubuntu in a UEFI machine. Unified Extensible Firmware Interface (or UEFI for short) is a new type of firmware that was initially designed by Intel (known as EFI then) mainly for its Itanium based systems. It introduces new ways of booting an OS that is distinct from the commonly used "MBR boot code" method followed for BIOS systems. A detailed description of UEFI can be found at the ArchWiki or Wikipedia

The installation remains similar to normal installation procedure but needs a little bit of tweaking. Having a PC with EFI firmware does not mean that you need to install Ubuntu in EFI mode. If you have a machine in which there is any operating system already installed in Legacy mode then you must install Ubuntu also in Legacy mode, unless you wish to format the system and start from scratch. If Ubuntu is the only operating system on your computer, then it does not matter, you can install Ubuntu in EFI mode or Legacy. But if you have a pre-installed Windows in UEFI mode then it is mandatory to install Ubuntu in EFI mode.
Update: The following method was tested with different versions of  Ubuntu starting from 13.04 to 19.10, KDE Neon and Linux Mint (by various readers of the blog).
 
Partitioning instructions for users without any pre-installed or Existing OS. (Formatting Entire hard-disk).
  1. The first and foremost thing is that the partition table followed in EFI systems is GPT and not the Legacy MS-DOS. If you are starting the installation on a system with no operating system then the first step is to create a GPT partition table.  This can be done from Gparted (after booting into Ubuntu live media) by using Create Partition table under device menu. A dialog box similar to one shown here appears and you can use Advanced option to set partition table to GPT. Then press Apply. The GPT partition table doesn't have the limitation of allowing only four  primary partitions as in an MS-DOS table.
          
  2. Now partition the hard disk to install Windows. You will require one NTFS drive at beginning to install Windows. If you need to install Ubuntu as only operating system then there is no need for this NTFS partition.
  3. The create an EFI partition using GParted. The type of partition is FAT32 with a size of minimum 100Mib (200MiB recommended). Set the boot flag for this partition using manage flags option.
  4. Leave a 100-200 MB free space before making next partiton. This space will be used as Reserved Area for Boot/GRUB during installation.
  5. Create an EXT4 partition for the root filesystem. The size of the partition can be limited to 15-20 GB (minimum 4GB) depending on how many softwares you are going to install.
  6. Create another EXT4 partition for the home folder. This is recommended because this will help you to reinstall Ubuntu again without losing any files or settings as you will not need to format the home partition everytime.
  7. Create a SWAP area. Rule of thumb is size is of SWAP is twice the amount of RAM you have. Swap area is needed but the it can be a smaller partition also. If you are running RAM intensive applications (or codes) or plan to do hibernation SWAP size twice RAM is recommended.
  8. Create the rest of partitions as per your need of partitions.
  9. Reboot and install Windows in the NTFS partition created in step 2. It will create the System/Recovery partition by dividing the existing partition. This will be taken care by the Windows Installer. After completing installation reboot and boot back into Ubuntu installer.
  10. Now proceed to the common installation instructions.
Partitioning instructions for users with Windows installed in EFI mode (Resizing hard-disk). 
  1. Boot into Ubuntu Live Disk/USB and select Gparted from dash.
     
  2. Resizing the disk: The partition table in machines with pre-installed Windows in EFI mode is GPT. Usually OEM manufactures install the OS with only single large C drive. However there will be small additional 2 or 3 partitions one for Recovery/System, EFI boot and manufacture specific drivers. These small partitions should not be disturbed while resizing (It may cause boot failure for windows). The C drive (largest NTFS partition)  can be resized to create free space.
  3. Your disk already contains an EFI partition (eg if your computer had Windows8 preinstalled), it can be used for Ubuntu too. Do not format it. It is strongly recommended to have only 1 EFI partition per disk.
  4. Leave a 100-200 MB free space before making next partiton. This space will be used as Reserved Area for Boot/GRUB during installation.
  5. Create an EXT4 partition for the root filesystem. The size of the partition can be limited to 15-20 GB (minimum 4GB) depending on how many softwares you are going to install.
  6. Create another EXT4 partition for the home folder. This is recommended because this will help you to reinstall Ubuntu again without losing any files or settings as you will not need to format the home partition every time.
  7. Create a SWAP area. Rule of thumb is size of SWAP is twice the amount of RAM you have. Swap area is needed but the it can be a smaller partition also. If you are running RAM intensive applications (or codes) or plan to do hibernation SWAP size twice RAM is recommended.
  8. Create the rest of partitions as per your need of partitions.
  9. Now proceed to the common installation instructions.

Common Installation Instructions after Partitioning.
  1. Start Ubuntu installation as normal and choose something else as installation type. 

                      
  2. Now in the next step choose the EFI partition created in Step3 as EFI boot partiton. Do not tick format this partition option.
  3. The Space left free in step 4 must be marked as Reserved BIOS boot area.

                         
  4. Set the EXT4 partition created in step 5 as root by setting mount point to /
  5. Set the EXT4 partition created in step 6 as home by setting mount point to /home
  6. Now proceed to further steps of installation and complete the installation.
  7. After reboot GRUB will appear as boot loader. If it loads directly into Windows instead of GRUB you can change the EFI boot order in EFI settings to put Ubuntu above Windows. This will set grub as the default loader.
  8. If there is still no GRUB or any boot error is shown while loading Ubuntu go back to UEFI settings and disable secure boot. 
Converting a Legacy Installation on GPT Hard Disk to EFI

Update: This section no longer works properly for users with Ubuntu 16.04 and above.


If you have mistakenly installed Ubuntu without following above steps into a GPT hard disk in legacy mode, it can be converted to EFI mode.  The first step is to boot into Ubuntu in Legacy mode. Now install boot-repair 

                   
  Launch boot repair from dash and do recommended repair. Follow the instructions on screen and run the commands shown on screen. This will convert the Legacy installation to EFI. Now reboot select EFI mode.