Monday, April 21, 2014

Mount a ntfs partion in Ubuntu, Linux

Generally no file can be executed at a pendrive or at a separate partition in Linux, unless it is mounted with proper permissions. The default mount (clicking on a pendrive or partition mounts automatically) does not provide necessary permission due to security issue.
This problem can be override by the following commands.

  1. First we need to find out our media to be mounted.
    fdisk -l
    This command gives a list of devices currently connected. Prompting this command at my terminal gives output:
    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0xfa61dadb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *   376006656   976773119   300383232    7  HPFS/NTFS/exFAT
    /dev/sda2            2046   376006655   188002305    5  Extended
    Partition 2 does not start on physical sector boundary.
    /dev/sda5            2048   360380415   180189184   83  Linux
    /dev/sda6       360382464   376006655     7812096   82  Linux swap / Solaris
    
    Partition table entries are not in disk order
    
    Suppose we are going to mount /dev/sda1.

  2. Now we have to define a mount point where that partition is going to be mounted. I will mount it into /media/Partition directory. The following command will create that directory.
    mkdir -p /media/Partition

  3. Finally, the following command will mount our partition.
    sudo mount -t ntfs -o nls=utf8,umask=000 /dev/sda1 /media/Partition
    We are mounting ntfs type partition or device, full list of supported type can be found at manual page of "mount" command. Umask = 000 means it allows read, write and execute permission for all (security risk).
Thats it. We have just mounted an ntfs file system into readable, writable, and executable mode.

Sunday, April 20, 2014

Software list for my new Ubuntu 14.04 Trusty Tahr

Just finished installation of Ubuntu 14.04 in my laptop, making only OS of my computer system. I think I'll make a review later, but right now I'll make a list of new softwares I am installing now.
  • VIM
  • VLC Player
  • Codeblocks
  • Terminator - a command interpreter
  • Ubuntu Restricted Extras
  • Google Chrome - my secondary browser
  • Oracke JDK
  • Xampp
  • Php-Storm
  • Eclipse
  • Android Studio
  • Avro
  • Shutter - Screen Capture
  • Gimp - Image Editor
  • qBitTorrent
  • Dropbox
  • Google Drive Ocamlfuse - Google Drive Client for Linux [Currently using Grive]
  • Grive (Google drive client)
  • Okular (Document Viewer, Specially for PDF)
  • todo-indicator (task manager)
  • Texmaker (LaTex Editor)
  • Weka (Data Analysis Tool)

Monday, January 13, 2014

Installing JDK, JRE in Ubuntu

Installation of "default-jdk" using "apt-get" was perfect though in my system it was showing that OpenJdk 6 was installed. I did not wanted it and deleted it from Software Manager. Unfortunately, uninstalling OpenJdk 6 installs OpenJdk 7!!!
I was searching for a solution on the web. Then I found the following link. It describes how to install Oracle Jre and Jdk. This link is so helpful.

http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux

Friday, December 20, 2013

Roadway to Ubuntu

This post is neither a solution nor a suggestion. This is what I experienced during installation of ubuntu in my system.
    Since the first day I used a computer, I was using MS Windows as default and primary operating system. Though, its important for a student to cope with different operating systems. During this time, I have used different Unix/Linux based live OS. Deciding which OS I should use is pretty tough decision because there are bunch of choices and all of those are free. :P
    My first attempt to install Linux was on a AMD A55 machine. It was a failure because of hardware configuration. ( I have tried it with both 32bit and 64bit different OSs. )
Then I got my laptop, an Intel system with pre-installed Windows 7 in it. Well, I removed it with Windows 8 from DreamSpark account at 0.00$ cost. :D Living together with Windows 8 was quiet fun. xD However, when I took Operating System course at University, it was a necessity having a Linux OS in my system. But, I failed again. Ubuntu live OS ran fine, installation started every time, but it could not modify the karnel about installation! I tried with Fedora, OpenSuse, Ubuntu, BackTrack and LinuxMint. Each time it started fine, but ends with error. Error! Error!! Error!!! ( Now I have figured it why.. Windows hibernate/hybrid-shutdown option was not allowing any other OS to modify the storage. Later I turned it off using the following command. )
powercfg /h off
    Enough installing Linux for me! So, I kept it cool with Windows.
Meanwhile, my pc was attacked by SIREFEF virus. It turned off, turned off(!) Windows Defender permanently and converted system directories into junctions. Thats why I could not turn Windows Defender on. It ate all the website certificates on all browses. Whenever I turned on the pc, a VB script was creating executable file and some null processes on background. I got rid off this virus using HitmanPro.
    Another thing this virus did was making disk partitions undetectable in disk management tool or windows setup. So, I was thinking on a new set up. Why not Linux now? Yes, it was time for Ubuntu to take all the disk spaces. :D This time I was stuck with, UEFI abd Legacy Mode. Certainly I wanted Ubuntu in UEFI mode but did not find any option for Windows but Legacy mode. Oh, I surely wanted a duel boot.
    I created partitions, installed Ubuntu. Then another problem did arise! Windows could not format GPT partitions. I erased the whole disk using diskpart.
diskpart
list disk
select disk *
clean
convert gpt
exit
    Well, windows was installed. Finally, I installed Ubuntu by formatting unallocated spaces. Installation Finish! Restart!! Windows Boot!!!
    Ah, the MBR, windows boot manager. Again I inserted Ubuntu live USB to install GRUB.
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair
sudo boot-repair
    At last... Got my dual boot system with Ubuntu 12.04.2 and Windows 8. Decided to use Ubuntu as primary and Windows as supporting OS.
Finally, Enjoying Ubuntu!!

Monday, December 16, 2013

Maximum Interval Product

Previously, I have posted about maximum interval sum. Now, unlike summation, product of an interval or segment is bit different.
Well, the problem is, from a given array of integers we have to determine the maximum product which can be found by any segment of the given array of integers.
Example:
Let, we have an array of these integers:
1 -2 4 -3 -1
So, the maximum interval product is 24 from 1 to -3 ( 1*-2*4*-3 ).
1 -2 4 0 -3 -1
Here, the maximum interval product is 4 from only 4.
Iteration:



initial

1

-2

4

-3

-1

mp

inf

1

inf

4

24

12

mn

inf

inf

-2

-8

-12

-24

mxProduct

-1

1

1

4

24

24

Code:
// Maximum Interval Product
// Complexity: O(n)
long long mxProduct  = -1;
// maximum product is stored. if unchanged, no valid product.
long long t1, t2;
long long mp = INF, mn = INF;
// two counters for maxPositiveProduct and maxNegativeProduct
for( i=0; i<N; i++ ) {
    scanf( "%d", &arr[i] );

    if( arr[i] == 0 ) {
        if( mp != INF ) mxProduct = MAX( mxProduct, mp );
        mp = mn = INF;
        continue;
    }

    if( mp==INF && mn==INF ) {
        arr[i] > 0 ? mp = arr[i] : mn = arr[i];
        if( mp != INF ) mxProduct = MAX( mxProduct, mp );
        continue;
    }

    if( mp == INF ) {
        if( arr[i] > 0 ) {
            mp = arr[i];
            mn = arr[i] * mn;
            mxProduct = MAX( mxProduct, mp );
            continue;
        }
        if( arr[i] < 0 ) {
            mp = arr[i] * mn;
            if( arr[i] >= mn ) mn = arr[i];
            else mn = INF;
            mxProduct = MAX( mxProduct, mp );
            continue;
        }
    }

    if( mn == INF ) {
        if( arr[i] < 0 ) {
            mn = arr[i] * mp;
            mp = INF;
            continue;
        }
        if( arr[i] > 0 ) {
            mp = arr[i] * mp;
            mn = INF;
            mxProduct = MAX( mxProduct, mp );
            continue;
        }
    }

    t1 = arr[i] * mp;
    t2 = arr[i] * mn;
    if( arr[i] > 0 ) mp = t1, mn = t2;
    if( arr[i] < 0 ) mp = t2, mn = t1;
    mxProduct = MAX( mxProduct, mp );
}

Source:
http://acm.uva.es/board/viewtopic.php?f=33&t=11466&hilit=11059&sid=6ed77239e43f67e7ca9999e1412b0180
Thanks - Jajabor, 2014