Author: rahul

  • Partition Backing Up and Restoring Tools

    Partimage

    Partimage is an excellent tool for taking backup of any partition. But please note that when you restore, the partition size should be the same as the original partition size. If it is less, the restore will not take place and if it is more the extra space will be wasted. Also the partition should not be mounted if you are taking a backup. As of version 0.6.0, partitions can be saved across the network.

    Dump/Restore Utilities

    Dump/Restore Utilities overcome some of the limitations of partimage but it can be used only on ext2 filesystem.

    Dump examines files in a filesystem, determines which ones need to be backed up, and copies those files to a specified disk, tape or other storage medium. Subsequent incremental backups can then be layered on top of the full backup.

    The restore command performs the inverse function of dump; it can restore a full backup of a filesystem. Single files and directory subtrees may also be restored from full or partial backups in interractive mode.

    For dumping a full partition, run:
    # dump -0vz -f /mnt/hda4/impdata.gz /dev/hda7

    For restoring the dumped file of a full partition, format the destination partition, mount it, enter the mount directory and run:
    # restore rf /mnt/hda4/impdata.gz

    For more info on how to use dump/restore, refer Backup with dump and restore on Linux mini-HOWTO

    Entire hard disk backup using g4u

    g4u is an excellent tool for taking backup of the entire hard disk. I had used it once which I have documented here.

  • TV Tuner software and remote control software

    XawTV and TVtime

    “xawtv” comes as the default tv watching program for Mepis. “xawtv” also features recording ability but I think a lot of work has to be done on this feature.

    But when it comes to quality and full-screen mode “tvtime” rules. TVtime is installable via apt. The Indian cable settings are:

    Default Television Standard: PAL
    Default Frequency Table : Europe
    Default Audio Standard : PAL-BG

    Other TV viewing software

    There are other software such as mythtv, freevo, mplayer, mencoder, kplayer, etc. available for watching TV. But I had problems in configuring most of them. MythTV is an excellent TV viewing application but i think it relies on some xmltv listings which is not available for India and hence I believe this application cannot be used here.

    Remote control

    Remote control support is provided in linux using LIRC. lirc can be installed via apt.

    Notes:

    1. While installing lirc, it will prompt you for two things. The first prompt is about the remote model which you are using. I am using Pinnacle Stereo TV Tuner card and the model to be selected for it is “Other serial port devices -> Pinnacle Systems PCTV (pro) receiver”.
    2. The second prompt is for the serial port to which your receiver is connected. Most PCs generally have only two serial ports. If you know whether your remote is connected to COM1 / COM2, you can select it right away. If you are not sure then just select the first option and while testing if the remote doesn’t work, you can either fix the receiver to the other serial port and test / you can modify the com port setting (DEVICE) in “/etc/lirc/hardware.conf”, restart the lirc daemon and then test.
    3. In order to test whether everything is working properly, you will need to run the command “irw” and press some buttons on the remote. The output should be similar as below (remember the lirc deamon should be running before you execute the command):
      # irw
      000000000000002f 00 Power PinnacleSysPCTVRemote
      0000000000000033 00 3 PinnacleSysPCTVRemote
      0000000000000032 00 2 PinnacleSysPCTVRemote
      0000000000000031 00 1 PinnacleSysPCTVRemote
      0000000000000034 00 4 PinnacleSysPCTVRemote
      0000000000000035 00 5 PinnacleSysPCTVRemote
      000000000000003f 00 Chan+Play PinnacleSysPCTVRemote
    4. Sometimes lirc may give problems working with your remote. It would be a good idea to get the latest sources from the website, compile, install and then test.
    5. Once your remote control is working fine, you can then configure lirc for tvtime. Instructions on configuring lirc for tvtime can be found here.

    Software tried and failed for Recording

    – Freevo (depends on xmltv listings)
    – MythTV (depends on xmltv listings)
    – vdr (needs a specific DVB card)
    – dvr (gave some error when executed)
    – vcr
    – streamer

    I am still looking for some TV capture software in linux. If anyone of you comes across such a software, kindly let me know.

    Recording using ffmpeg

    Upon looking for a way to capture from TV Tuner card, I posed the problem to one of my college mates Anurag Singh. He suggested the below method. Though I have not tried it out, you can give it a try if interested.

    Hi sir,
    Ofcourse I remember you. How are you? Ok, I’ll tell you in detail about the
    whole thing.

    We’ve set up two frameworks for recording. The first one is for
    news.iiit.ac.in. In this one, we decided a static list of channels for
    various 30 min time slots for the whole day. We wrote some shell scripts
    which execute periodically using cron and they record the required channel as
    one video each. For this, we had to find out the frequency of the required
    channel to be recorded. We used xawtv to tune the channels. Its done like
    this.

    We open xawtv. We press up and down arrow keys to change channel. Say for
    example we somehow reached ‘ZEE TV’. Now, if you want to note the frequency,
    right click on the xawtv window and select ‘Channel editor’. You can then see
    the channel frequency. Generally it will be a number from 1 to 25… or S01
    S02 or SE1 SE2 or E1 E2, etc kind of a string. Also just before you do all
    this, you need to select the ‘frequency type’ …. which can be selected from
    xawtv. For all channels in India, we need to select ‘europe-west’.

    Anyways, for all these tuning purposes also, we’ve written shell scripts,
    which can be used to create frequencies of all channels with human assistance
    though.

    Another part of the whole framework is tv.iiit.ac.in. This part was done to
    get IIIT a supply of videos on demand. It uses a php portal and a mysql
    database. It takes votes of people all 24 hours and finally records the
    channel which was voted the most. It also uses cron for the whole thing. Here
    also we needed to manually tune the channels which were available as choices
    to be recorded. These tuned frequencies keep changing when the cable operator
    switches then, so we need to keep monitoring the correspondence of channel
    name and frequency from time to time.

    Anyways, here are a few commands of help.

    v4lctl setchannel S01
    This command makes the hardware start receiving the channel at frequency S01.
    If you do ‘xawtv’ just after this, the first channel to be shown will be the
    one at S01.

    v4lctl setfreq 69250
    This command has the same effect as the previous one. This basically sets the
    frequency based on the value instead of the tag name. You can find the values
    and tag name mappings in /usr/share/xawtv. The europe-list file, along with
    what it includes, is of interest.

    ffmpeg -tvstd pal -vd /dev/video0 -deinterlace -ad /dev/dsp1 -minrate
    1000 -maxrate 1000 -b 1000 -bufsize 3000 -aspect 4:3 -s 640×480 -y -t 40
    something.avi
    This command can be used to record the telecast into a file ‘something.avi’.
    The option -t specifies number of seconds to record (40). -aspect specifies
    aspect ratio, -s specifies resolution, -y specifies allow overwriting the
    file if it exists. -vd option is used to select the video device
    (video0), -ad for audio device. The deinterlace option is to deinterlace the
    video as the input will generally be even and odd rows of video in alternate
    frames. The -b, -minrate, -maxrate, -bufsize options specify the bitrate of
    recording. -tvstd option is generally optional.
    Other interesting options for ffmpeg are
    -qscale <num>
    The num can vary between 1 to 35 and can be used in place
    of -b, -minrate, -maxrate, -bufsize options. 1 refers to best possible
    quality and 35 to the lowest quality.
    -sameq
    This options asks the encoder to use the same quality as source.

    We’ve tried all these options… and for good enough recording.. the above
    given ffmpeg command works well.

    The current news.iiit.ac.in is fully working.. and I can give you all the
    scripts to use it. But I think static recording wont be of much use to you.
    The tv.iiit.ac.in portal last worked in April. We’ve stopped working on it
    since then, but seems after a few tweaks it can function as well. But I
    guess, using cron, v4lctl, xawtv and ffmpeg, it’d be a matter of 20 mins for
    you to set up your own recording system, rather than debugging that whole
    portal. I’ll happily send it to you if needed.

    And do write back if you have more queries (which I am sure you’ll have as I
    am not very good at explaining :D).

    Regards,
    Anurag.

    शुक्रवार 01 सितम्बर 2006 22:09 को, आपने लिखा था:
    > > Hi Anurag,
    > > I hope you remember me. I am Rahul from the 2k batch. I needed a small
    > > piece of information. I have a Pinnacle PCTV Plus TV Tuner Card. I have
    > > tried umpteen number of times to set up PVR in linux for this card. But
    > > failed everytime. I tried Mythtv, Freevo, Xawtv, VDR, DVR, etc. but all
    > > in vain. Most of them require some XML listings while in some of them
    > > recording quality is very bad and some of them don’t even work. What I
    > > have heard is that a video recording solution has been set up in IIIT
    > > and you are part of the team. It would be very helpful if you can answer
    > > my below two queries:
    > >
    > > – Are there are any tools which are tried and tested by you using which
    > > I can record TV shows?
    > > – Can I use the software developed at IIIT for recording i.e. is it free
    > > and and in a usable state?
    > >
    > > Hoping everything is going fine on your end. Looking forward to a
    > > response …
    > >
    > > Regards,
    > > Rahul.
    > >
    > > P.S.: I am able to view TV using tvtime. So getting the card to be
    > > recognised and loading the appropriate drivers for it is not an issue.

  • Mail Clients, pop3 servers, configuration settings

    Mail Clients

    Thunderbird and KMail are two excellent mail clients for linux users. I tried Evolution (it seems to be very popular) but it kept crashing and hence I had to stop using it.

    KMail was excellent except for two problems – i. the composer does not wrap text automatically and ii. Support for IMAP folders is not very extensive.

    Thunderbird provided me almost all the features of KMail except for a missing system tray icon which I was easily able to add using the alltray package (installable via apt). Hence I decided to use Thunderbird as I use an IMAP mail as well along with POP3.

    Accessing Yahoo Mail Using POP3

    YPOPs! is an application which emulates a POP3/SMTP mail server and provides free POP3 and SMTP access to Yahoo! Mail.

    You need to download the source from the site, compile it and install it. Also YPOPs! source requires the mimepp library version 1.3.3.

    Assuming that you have set POP3 port to “11111” and SMTP port to “25251”, the below settings should work for KMail while creating a POP3 account for yahoo.
    POP3 – 127.0.0.1/11111, username: amaramrahul, Mail Encryption – None, Password Auth – Clear Text

    Accessing Hotmail using POP3

    Hotwayd is a utility which functions similar to YPOPs! and offers POP3 and SMTP access to Hotmail. Luckily hotwayd and hotsmtpd is available via apt. The below steps should be followed for accessing Hotmail via POP3.

    1. First install hotwayd and hotsmtpd
      # apt-get install hotway
      # apt-get install hotsmtp
    2. Add the below two lines in /etc/services:
      hotwayd 11110/tcp # Hotwayd Http-POP3 Gateway for Hotmail
      hotsmtpd 25250/tcp # Hotwayd Http-SMTP Gateway for Hotmail
    3. Add the below two lines in /etc/inetd.conf and restart the inetd service (/etc/init.d/inetd restart):
      hotwayd stream tcp nowait root /usr/sbin/tcpd /usr/bin/hotwayd
      hotsmtpd stream tcp nowait root /usr/sbin/tcpd /usr/bin/hotsmtpd
    4. Configure KMail with the below settings while created a Hotmail POP3 account.
      POP3 – 127.0.0.1/11110, username: amaramrahul@hotmail.com, Mail Encryption – None, Password Auth – Clear Text

    Accessing GMail using POP3

    Use the below settings in KMail to access Gmail via smtp.

    POP3 – pop.gmail.com/995, username: amaramrahul, Mail Encryption – SSL, Password Auth – Clear Text
    SMTP – smtp.gmail.com/25, username: amaramrahul, Mail Encryption – TLS, Password Auth – Plain

    Other utilites which provide similar functionality

    FetchYahoo is a perl script that downloads mail from a Yahoo! account to a local mail spool. It is meant to replace fetchmail for people using Yahoo! mail since Yahoo!’s POP service no longer free. It downloads messages to a local mail spool, including all parts and attachments. It then deletes messages unless requested not to. It can also optionally forward messages to a specified e-mail address and repeat with a given interval.

    Gotmail is a perl script to download mail from hotmail.com without user interaction. It is probably best run from a cron job.

    Getmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail. To see a sample configuration file for fetching gmail mails, click here.

    MrPostman is a java program that allows you to access Yahoo Mail, Hotmail and other webmail services directly from your favorite mail client. It converts the web pages of your favorite webmail provider to e-mails and provides the standard POP interface to your mail client. Currently supported webmail providers:
    * Hotmail
    * mail.com
    * Yahoo
    * gmail (Google mail)
    * indiatimes.com
    * juno
    * rediffmail
    * Gossamer mail
    * Outlook Web Access (Exchange 5.5)
    * Outlook Web Access 2003

    While it might be obvious that FetchYahoo and Gotmail are not POP3 servers, MrPostman is clearly a replacment for YPOPs! and Hotwayd. But why I did not choose it is because YPOPs! and Hotwayd work much better than MrPostman. Nevertheless it deserves a special mention here for the high number of providers to which it provides POP3 access.

  • Popular Linux Browsers

    Firefox

    Firefox is the best browser available for linux. What makes it so good besides its advanced features is it’s wondeful plugins and extensions support. Firefox is installable via apt.

    Useful extensions for firefox:

    1. Flashgot: FlashGot is a free Mozilla/Firefox/Flock/Thunderbird extension (compatible with Netscape too), meant to handle single and massive (“all” and “selection”) downloads with several external Download Managers. You can install flashgot for firefox from here.
    2. Tab Mix Plus: Tab Mix Plus enhances Firefox’s tab browsing capabilities. It includes such features as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more. It also includes a full-featured session manager with crash recovery that can save and restore combinations of opened tabs and windows. You can install Tab Mix Plus for firefox from here.

    Opera

    Opera is an alternate browser which can be used in case you find problems with displaying of some sites in Firefox. Opera is now available in MEPIS repositories. So you can install it directly.
    # apt-get install opera

  • Searching Techniques in Linux

    Here I shall cover the various techniques that can be used for searching.

    Searching for files

    “locate” works by maintaining a database of all the files which are present on the hard disk. When a search is performed for a specific file, this information is retrieved from the database. In order to update the database run the command “updatedb”. For example,

    # updatedb
    # locate ‘rc.firewall’

    “find” command is used for the same purpose as “locate” but the difference is that instead of maintaining a database it directly searches. For example,
    # find /etc/ -name ‘rc.firewall’

    Searching for files within packages

    You can either use “dpkg” or “apt-file” but for dpkg it is necessary that the package be installed and for apt-file you have to perform update regularly.
    # dpkg -S ‘apt.conf’
    (if the package containing apt.conf is installed then only will it return the result)
    OR
    # apt-file update
    # apt-file search ‘apt.conf’

    This search is useful if you want to know to which package a particular file / command belongs to.

    Searching (and replacing text) in multiple files

    “grep” is a very popular command which can be used to search for text in directories recursively.
    # grep -R ‘search_string’ *

    “rpl” (package installable via apt) is a good utility for replacing text in multiple files. For example,
    # rpl -vRa ‘old_string’ ‘new_string’
    (use option -s for simulation run)

  • Instant Messaging

    Instant Messaging – my favourite topic. There was a time in my graduation when I used to chat like hell and experiment with all the available messaging clients. My two cousins Sumana and Sujana and a friend Swetha used to always be the ‘bakras’ (scapegoats) bearing me :-). Times have changed now and I don’t chat so much but that doesn’t stop me from writing on my favourite topic. So go ahead and read it.

    Gyach (Yahoo Messenger for Linux)

    Gyach is yahoo messenger for linux and is supposed to support voice chat along with webcam. It is not availabe by default in the mepis/ubuntu repository and you will have to download it. You can either download their rpm, convert it to .deb using “alien” and install or you could download their source, compile it and install. There is also a thread which discusses how to install Gyach on Mepis.

    I was unable to use Gyach voice chat. But with other better software such as skype available, voice chat is not a big issue. As far as webcam is concerned, I was able to view other’s webcam but not able to broadcast mine. I also had a few issues with gyach (installed from rpm) crashing on my machine.

    Also, please note that there is an official Yahoo Messenger provided by Yahoo for linux users. But it is so outdated that I highly don’t recommend it.

    Skype
    Skype is a cross-platform voice messenger which is based on P2P technology. Mepis comes installed with Skype by default. If necessary, you can download the binary package for Mepis here.

    Pidgin

    Welcome to the King of Instant Messengers – Pidgin (formerly know as Gaim). Pidgin is a multi-protocol instant messenger available for both Linux and Windows. Using this messenger alone you can log into yahoo, msn, aim, google, etc. There are also many plugins available. Some very good plugins which are available by default are “System Tray Icon” and “Message Notification” plugins. Currently pidgin does not support voice/video chat but these are going to be added in the next major release.

    Notes:

    1. At the time of writing this article, there does not seem to be a binary package (.deb) available for pidgin. So you will have to download the source and compile and install it.Pidgin is now available in debian backports repository.
    2. Pidgin stores all message conversation in “~/.purple/logs/”. I generally move this folder to a location of which I take backup regularly and then create a soft link “~/.purple/logs” to the new location.
    3. Pidigin now comes with a console based messenger known as “finch”.

    Guifications

    Guifications is another plugin available for pidgin. This plugin is used to display events like user login, logout, etc. in a box at the corner of the screen.

  • Auto-mounting partitions

    The details of the partitions detected on the hard-disk is maintained in ‘/etc/fstab’ file. Simply Mepis automatically detects the available partitions and adds them as dynamic entries in /etc/fstab. If you want to make that partition entry as static, you will have to move that entry above the line “# Dynamic entries below, identified by ‘users’ option” in ‘/etc/fstab/’ file.

    In order to auto-boot a parition, you will have to change ‘noauto’ to ‘auto’. It is also a good idea to remove ‘users’ from the mount options so that only the superuser (root) can mount and un-mount partitions.

  • Mepis Basics

    Now that I have convinced you into using Linux (I do hope I have :-)), it is time to get into action. This page is the first of the many pages which I am going to write as to how best you can customize linux to suit your needs. Now that we are all set, let’s going.

    Gettting and installing Simply Mepis

    Simply Mepis is available for free and its ISO can be download from any of its mirror sites. Installing mepis is a child’s play and the official mepis site have also provided some documentation related to it.

    Notes:

    1. If you have no idea about what partitions are and how to create partitions, then I suggest you take the help of someone who is more experienced so that you don’t screw up something.
    2. It is always advisable to take backup of important data on your hard disk before partitioning, so that even if anything goes wrong you don’t lost valuable data.

    Basics of Linux

    In order to follow my articles, it is necessary that you have a basic understanding of what linux is, the console mode, the directory structure, some useful commands, etc. A book on basic linux usage may provide handy. Alternatively there will be many articles online which help you in getting started with linux. You can google for articles on introduction to linux on the net.

    Below are some linux useful commands which I highly recommend you understand before proceeding any further. I have just given a brief description for each of the commands. You may want to refer its man page or google for more information. Also execute each of the commands at least once so that you understand properly how it works.

    1. at – Executes commands at a later time
    2. alias – nicknames a command
    3. bash – Command Interpreter (shell)
    4. bc – Arbitrary calculator language
    5. cc – c language compiler
    6. cat – concatenates files to std output
    7. cd – Change Directory
    8. chmod – Change file access permissions
    9. clear – clears the screen
    10. csh – C shell
    11. cut – remove sections from each line of a file
    12. date – echoes and sets the systemdate
    13. diff – find differences between two files
    14. df – report disk space usage
    15. du – disk usage of each file
    16. env- runs a program with a modified environment
    17. exit – exits a shell
    18. export – exports a variable
    19. fg -runs a job in the foreground
    20. find – searches for a file in a directory hierarchy
    21. finger – displays information about a user
    22. ftp – allows user to transfer files to and from a remote network site
    23. g++ – c++ compiler
    24. gcc – same as cc
    25. gdb – gnu debugger
    26. gunzip – compress and uncompress files
    27. host – lookup hostnames using DNS domain server
    28. hostname – shows the system’s host name
    29. history – shows the last 1000 commands in .bash_history
    30. info – program to read documentation
    31. kill – Terminate a process
    32. killall – Kill a process by name
    33. last – show listing of last logged in users
    34. less – justs like more but you can scroll up or down
    35. links – popular text browser which supports frames
    36. ln – creates a link to a file or directory
    37. login – its used to sign on to a system .Switching between users.
    38. logname – prints users login name
    39. logout – exit a login shell
    40. ls – lists directory contents
    41. lynx – general purpose www text browser for linux
    42. mail – send and receive mails
    43. man – displays online manual pages
    44. mesg – controls write access to your terminal
    45. mkdir – creates the directory if does not exists
    46. more – opposite of less .read files by pages
    47. mv – moves (rename) files
    48. nohup – runs a command ignoring hangup signals
    49. pico – simple text editor in the style of pine composer
    50. ps – report process status
    51. pwd – prints the name of current working directory
    52. reset – restores variables to default values
    53. rm – remove files or directories
    54. rmdir – remove empty directories
    55. sleep – pauses for number seconds
    56. sort – sort lines of text files
    57. su – changes the effective user id and group id to that of a USER
    58. tail – outputs the last part of files (see also head)
    59. talk – copies lines from your terminal to any other terminal
    60. tar – tar archiving utility
    61. touch – change file timestamps like modification times etc.
    62. tty – prints the filename of the terminal connected to the standard input
    63. ttutor – typing tutor for linux
    64. umask – sets the default permissions for the file creation
    65. vi – Text editor for linux
    66. vim – Improved vi editor
    67. vimtutor – starts the vimtutor for learning the vim commands
    68. w – Shows who is logged on and what they are doing
    69. wall – send a message to everybody’s terminal
    70. whereis – locate the source/binary for a command
    71. whatis – search the database for complete words
    72. who – show who is logged on
    73. whoami – prints the effective userid
    74. write – send a message to another user
    75. zcat – compress uncompress files

    Mepis Configuration

    Many gui-based tools are provided exclusively by Mepis for performing some basic configuration of Linux such as configuring mouse and monitor, configuring network, creating and deleting uers, copying between desktops, testing and repairing paritions, etc. Some of them are mentioned below.

    1. msystem – MEPIS System configurator
    2. mnetwork – MEPIS Network assistant (some great news, since version 6.5 MEPIS supports WPA authentication for wireless networks)
    3. mxconfig – MEPIS X Window assistant
    4. muser – MEPIS User Assistant

    Control Center

    ‘kcontrol’ is a utility provided by KDE to configure many settings of your system which include setting background and screen saver, session management, power management, etc.

    Installing, uninstalling and upgrading packages from repository (using Synaptic and apt-get)

    Before I get into the details of how to use the tools for package maintenance, I shall give a brief introduction about debian package maintenance (as MEPIS is based on Debian and is tightly integrated with the Debian repositories).

    Debian provides a central repository for all the well-known Debian software. There may be other repositories provided by other debian software developers. The list of the repositories which we are using can be found in ‘/etc/apt/sources.list’. The database of what packages are available and their versions are stored locally on our machine. We need to update these databases regularly so that we know when newer versions of the packages are available. Please note that only the details of the debian packages and not the packages itself are what are stored on our machine locally. When you run a command to install a package, then only is the package actually transferred to our PC and installed.

    Now that I have explained how debian package maintenance works, let me cover the tools which we use for this purpose. There are two tools which can be used currently:

    1. apt-get (text based)

      Before installing a package or upgrading your system, it is very important that you update the database on your system which has information of the available packages and their versions. This can be done by running the command:
      # apt-get update

      In order to install a package, after running ‘apt-get update’, run:
      # apt-get install packagename

      In oder to uninstall a package, run:
      # dpkg -r packagename
      or if you want to remove the configuration files as well run:
      # dpkg –purge packagename

      The equivalent commands using apt for the above two operations are:
      # apt-get remove packangename
      # apt-get –purge remove packagename

      In order to upgrade the entire system, after running ‘apt-get update’, run:
      # apt-get upgrade

      You can limit the rate at which apt downloads packages using one of the below methods:

      • Set up a proxy server with delay pools and use apt-get to work with proxy as below (complicated).
        # apt-get -o Acquire::http::Proxy=’http://192.168.0.1:3128/’ upgrade
      • Install “trickle” package and use it to rate-limit apt-get as below (simple but might not work).
        # trickle -d 8 apt-get upgrade
      • Execute the below script “update.sh” to download all the upgraded packages and once this is done, run “apt-get upgrade” (simple and highly recommended method).


        #!/bin/bash

        cd /var/cache/apt/archives || {
        echo Failed to change to /var/cache/apt/archives >&2
        exit 1
        }

        apt-get update

        # first filter out all but the URIs with the grep
        # next grab just the first arg in uri and second arg in name
        apt-get --print-uris -y dist-upgrade | grep "^'" | while read uri name x;
        do
        # trim the leading and trailing quotes from the URI
        uri=`echo $uri | sed -e "s/^'//; s/'$//"`
        #echo $uri
        wget -c -t 0 --limit-rate=8k "$uri" -O "$name"
        done

        This code had been taken from Bandwidth limited apt-get

    2. Synaptic (gui based)

      Synaptic is a wonderful GUI tool using which you can install, remove, upgrade specific packages and also upgrade the entire system. Please note that before performing an install or an upgrade, it is important you click on ‘Reload’ button (this is equivalent to ‘apt-get update’). In order to upgrade the entire system, after reloading, click on ‘Mark All Upgrades’ followed by the ‘Apply Changes’ button.

    Notes:

    1. All the packages which are downloaded during installation are stored in ‘/var/cache/archives/’ directory. This directory is emptied by default when the system is rebooted. This can be unset by either using ‘msystem’ (select System Tweaks and uncheck ‘Clear packages at boot’) or by setting EMPTY_CACHE=no in /etc/default/mepis directory. Besides doing this, you will also have to open Synaptic, go to Settings->Preferences->Files and select what to do with the downloaded packages.

      In order to delete the downloaded packages you can just run:
      # apt-get clean

      In order to delete the downloaded packages which are no longer available in the repository you can run:
      # apt-get autoclean

    2. Avoid using “apt-get dist-upgrade” or the “Smart” upgrade option in Synatpic. Always use the default upgrade option. Use the smart upgrade option only if you are 100% sure that you know what you are doing. Becaue smart upgrade may tend to uninstall certain packages in order to install some packages.
    3. All the archives which are downloaded are stored in “/var/cache/apt/archives” directory. As this is located in the root partition, if it is formatted sometime for upgrading, these files may get deleted. Therefore it is not a bad idea to move this folder into some other partition and create a soft link “/var/cache/apt/archives” pointing to the new location of archives directory.
    4. While performing an upgrade, if you do not want to upgrade a particular package, you can execute the below command.
      # echo packagename hold | dpkg –set-selections

    Here are some related links.

    Debian Repository HOWTO
    APT HOWTO

    Installing a package not available in repository

    While the above procedure tells you how to install from the debian repository sometimes the software may not be available in the repository. Instead a binary package (.deb/.rpm) or the source (.tar.gz/.tar.bz) may be provided. In that case you will have to use the below method.

    From binary debian package (example: package.deb)

    The procedure is straight-forward for a binary debian package. Run the following command”
    # dpkg -i package.deb

    From binary rpm package (example: package.rpm)

    You will have to first convert the .rpm to .deb using ‘alien’ as below:
    # alien package.rpm

    This will generate a .deb binary file which can be installed as above:
    # dpkg -i package.deb

    From source (example: package.tar.gz / package.tar.bz2)

    You will have to first extract the source using the below commands depending upon whether .tar.gz is provided or .tar.bz2 is provided:
    # tar -xvzf package.tar.gz
    or
    # tar -xvjf package.tar.bz2

    After extracting the source directory, enter it and read ‘README’ or ‘INSTALL’ file for instructions on how to build and install the package. Please note that building a package from source generally requires the development packages of the libraries which it uses to be installed (development packages end with ‘-dev’). While the libraries are necessary for running the application, the development packages of the libraries are not necessary and can be un-installed once the compilation is over. Generally the below steps are following while installing from sources:

    1. Configuring: This involves generating Makefile’s depending upon the configuration of your system by running:
      # ./configure –prefix=/usr/local/packagename
    2. Compiling:
      # make
    3. Testing (may or may not be available):
      # make test
      or
      # make check
    4. Installing:
      # make install
    5. Uninstalling (may or may not be available):
      # make uninstall

    Adding and removing startup services

    Services can be added and removed from startup using ‘update-rc.d’ command. The start-up scripts are generally located in ‘/etc/init.d/’ directory. For example if you want to start the service ‘ssh’ during boot-up, you would run the following command:
    # update-rc.d ssh defaults
    and to stop the service ‘ssh’ from starting, you would run the following command:
    # update-rc.d -f ssh remove

    While services can be added and removed from startup using the above method, please note that when upgrading the system, during the upgradation of the package providing the service, the service is added to boot at start-up automatically. Hence I recommend that if you are sure you are not going to use a particular service, it is best to completely uninstall the package providing that service rather than just removing it from start-up. I shall later cover how we can know as to which package does a particular service (or start-up script) belongs to.

  • Introduction to Linux

    Why Linux?

    The million dollar question – Why use Linux? In my view, for three simple reasons.

    1. It is free
    2. It is more secure
    3. You don’t have the problem of viruses

    And my justifications for the above three reasons.

    1. Yes, I feel very guilty being a software engineer and using pirated software. You may argue that Microsoft is minting, they are robbing us, their software is extremely costly, it won’t make a difference to them, blah … blah … but I still believe that it is ethically wrong to use pirated software. And the same holds for music. There are always free sites as Music India Online and Raaga from where you can listen to streaming audio.
    2. Linux is open-source which means people get to see the code. Hence all the loop-holes in the software are already reported before they can be exploited. This makes Linux more secure than Windows.
    3. Viruses .. they are all around us :-). Need I really say anything about this?

    Talking about the superiority of Linux, I should confess that right now Windows still rules in the market. Some top reasons being:

    1. Its gui is far better than most of the linux distros.
    2. If my stats are not wrong, 90% of home machines use Windows. Maybe in 2020 only 10% of home machines would use Windows but the bottom line is that right now, its Windows which has dominated the OS market.
    3. Last but not the least, because of above point, drives for TV Tuner Cards, digicams. etc. are written for only Windows by the hardware product supplier. Believe me, this was one time when I felt … Oh God, why arn’t there any official linux drivers for this hardware product (referring to my TV Tuner Card)?

    Which Linux distro?

    Just before I get into suggesting which linux to use, let me give you a small background on how these distros – Ubuntu, Fedora, Mandrake, Suse, Mepis, etc. are made.

    The heart for any linux distribution is the kernel. This kernel is maintained by the Linux Guru “Linus Trovalds”. There are a set of kernel developers who keep working on the present kernel and improving it. Once they have added some new features, they send it to Linus for review. Linus reviews them and incorporates them in the kernel and releases its new version.

    Now, individual packages (like firewall, photo editing software, etc.) are generally maintained by organizations or individuals.

    Now the various linux distros are formed by taking this kernel, taking the software whichever they feel is necessary and bundling them together and giving to the user as an Operating System.

    Giving you an overview of how generally Linux distros are made, I now go into which linux distro. to use and the one I suggest is Mepis. Few reasons why I chose this OS are

    1. It is debian based which has a huge user community
    2. It has a great UI (almost as good as Windows)
    3. It runs off a live CD. What I mean by a live CD is that you don’t need to install it on your hard disk to have a look and feel of it. You can run it directly from your cd, check for its compatibility with your hardware and then install.

    This has also been awarded the Best Free Desktop Linux . Point & Click Linux! is an excellent book which helps users in gettting started and using SimplyMepis.

    Just on a side note, Mepis is based on Debian which is based on apt package manager (I will talk about apt in the later chapters). If you are looking for a rpm based distribution which is great for beginners just like Mepis, then you may try out PCLinuxOS.

    Distrowatch.com is a great website which keeps track of all the Linux Distributions.

    Is shift from Windows to Linux possible?

    Though I am linux fan, I shall not lie in saying that this completely depends upon the level of exposure to Linux and inquisitiveness of the user.

    • If you are someone who has never used Linux and are least interested in learning something new, then I suggest you stick to Windows.
    • If you are someone who has a fair knowledge of Linux (like the basic commands, permissions, etc.) and have some exposure to Linux, then you can shift to Linux completely.
    • If you are somewhere between a novice and an expert, then I suggest you install Linux (without deleting Windows) and later when you get hold on Linux, you can completely shift to it from Windows.
  • Love Letter By A Mathematician

    My Dear Love,

    Yesterday, I was passing by your rectangular house in trigonometric lane. There I saw you with your cute circular face, conical nose and spherical eyes, standing in your triangular garden.

    Before seeing you, my heart was a null set, but when a vector of magnitude (likeness) from your eyes at a deviation of t radians made a tangent to my heart, it differentiated.

    My love for you is a quadratic equation with real roots, which only you can solve by making good binary relation with me. The cosine of my love for you extends to infinity. I promise that I should not resolve you into partial functions but if I do so, you can integrate me by applying the limits from zero to infinity.

    You are as essential to me as an element to a set. The geometry of my life revolves around your acute personality. My love, if you do not meet me at parabola restaurant on date 10 at sunset, when the sun will be making an angle of 160 degrees.