Tagged: Linux Toggle Comment Threads | Keyboard Shortcuts

  • Tushar Neupaney 6:04 am on July 1, 2010 Permalink | Reply
    Tags: Linux, , service, stop,   

    stop mysql from running at startup 

    My Linux box was running mysql from the start and I did have no clue. It was not in my startup applications list, neither in my init.d folders.

    But whenever i did nmap of localhost, i could see the mysql port open. I could kill mysql service, need to kill it multiple times, only then it used to die.

    I even installed “sysv-rc-conf” so that i could stop it at run levels, but it was not running at any runlevels. I then did “update-rc.d mysql disable”. Which didn’t work either.

    Later I found that there was a file called “mysql.conf” in /etc/init/ folder. I renamed the file to mysql.conf.disabled and it worked out. Hope this will help others who have the same problem.

  • Tushar Neupaney 6:30 am on January 14, 2010 Permalink | Reply
    Tags: .vimrc, Configuration, Editor, Linux, , , Vim   

    My .vimrc file 

    Vim is the editor of my choice for my linux box. I have configured my .vimrc file in my ubuntu.


    ” Tushar Neupaney’s VIMRC File
    ” Followme twitter.com/tneupaney
    ” linuxfanatic.posterous.com

    ” (sw)shiftwidth: how many columns text is indented with reindent operations
    ” (sts)softtabstop: how many columns vim uses when you hit tab
    ” (ts)tabstop: how many columns a tab counts for
    set ts=4 sw=4 sts=2

    expandtab: appropriate number of spaces in insert mode
    set expandtab

    ” Make gvim colorscheme as evening
    if v:progname =~? “gvim”
    colorscheme evening

    ” Prevents keeping of backup after overwriting the file
    set nobk

    ” To see line numbers on the left
    set number

    autocomplete parenthesis, brackets and braces
    inoremap ( ()<Left>
    inoremap [ []<Left>
    inoremap { {}<Left>

    Syntax highlighting on
    syntax on

    share windows clipboard
    set clipboard+=unnamed

    Hightlight the curent column
    set cursorcolumn

    Hightlight the current line
    set cursorline


    Here is the Screenshot!

  • Tushar Neupaney 12:43 pm on August 23, 2009 Permalink | Reply
    Tags: Curl, , Linux, Longurl, Perl, Short url, , , url, XML   

    Using perl to convert short urls (shortened urls) into long urls 

    Perl is a powerful and useful programming language. It has been largely popular for it’s string manipulation, speed and ease of using. Perl is one of my favourite languages of choice. It suits best for small programs which needs to one thing but do it best.

    When I was writing a software to analyse twitter statuses, i had to see what people were actually trying to say. In twitter culture people include urls to present their view. For example, to say you don’t like Obama’s new agenda, you can give a link to a url where the view is strongly presented. Thus, to abstract the sentiment of tweet by a tweeter user, I had to look for url present in their tweets and rank their sentiments. Also, due to the limitation of tweet being 140 character, people include shortened urls in order to save spaces. These short urls use services like bit.ly, tinyurl, is.gd etc.

    Thus to lengthened the shortened urls, i built my own perl code. I made a sub function where I will pass a short url and it will return a long url for me. This will mean that when I come across a long url in a tweet I can immediately get a long url of it and get the rank of the site after seeing it (manually).

    The libraries and modules that I used is WWW::Curl::Easy and XML::QL. This script basically uses the api of longurl.org. The result which is returned from the site is what we need after we do some small formatting. WWW::Curl::Easy is the backend to pull the page. By using the XML::QL module we can actually find the location from the xml data which comes by when the curl function returns the result.

    The Code:

    use WWW::Curl::Easy;
    use XML::QL;


    sub long_url
    my $url = shift;

    $url =~ s/:/%3A/gi;
    $url =~ s/\//%2F/gi;
    $url = ‘http://api.longurl.org/v2/expand?url=‘ . $url;

    my $curl = new Www::Curl::Easy;
    $curl->setopt(CURLOPT_URL, $url);
    my $response_body;

    open(my $fileb, “>” , \$response_body);

    my $retcode = $curl->perform;
    my $result;

    if ($retcode == 0) {
    my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
    open (FL, “>tmp_curl”);
    print FL $response_body;
    close FL;

    my ($qry,$long_url);
    $qry = ‘WHERE <long-url>$long_url</long-url> ORDER-BY $long_url IN “file:tmp_curl” CONSTRUCT $long_url’;
    $result = XML::QL->query($qry);
    return $result;
    } else {
    $result = print(“An error happened: ” . $curl->strerror($retcode).” ($retcode)\n”);

    And According to Mr. Laryy Wall the following can be a small alternative to the above:
    perl -MLWP::UserAgent -e ‘print LWP::UserAgent->new->get(”http://post.ly/2fzW”)->base’

    • Larry Wall 1:40 pm on August 26, 2009 Permalink | Reply

      The answer would be much simpler using Perl’s LWP library. Here’s a simple command line:

      perl -MLWP::UserAgent -e ‘print LWP::UserAgent->new->get(“http://post.ly/2fzW”)->base’

    • Tushar Neupaney 5:56 am on August 27, 2009 Permalink | Reply

      Thanks larry, that was a nice one.

  • Tushar Neupaney 9:10 am on July 8, 2009 Permalink | Reply
    Tags: Change Password, Linux, , Password, Recovery   

    Reset your password in MySQL (mysql) 

    There are times when you forget your password and if it is from mysql it really suck!
    No worries if you run your mysql system.

    For linux users I have the following command lines try them will work:

    Stop the MySQL Server.
    sudo /etc/init.d/mysql stop

    Start the mysqld configuration.
    sudo mysqld –skip-grant-tables &

    Login to MySQL as root.
    mysql -u root mysql

    Replace YOURNEWPASSWORD with your new password!

    Enjoy 🙂

  • Tushar Neupaney 12:42 pm on June 13, 2009 Permalink | Reply
    Tags: , , Linux,   

    Change man pages to text file, pdf file 

    Sometimes it is really handy if you could convert the manual pages in unix/linux to formats that can help you read them outside the terminal. The most useful formats are text formats and pdf versions of file.

    To change the man pages into text file:

    Open Terminal and type the following command (If you want to convert the cd command’s man file into a text file):
    man cd | col -b > output-file.txt

  • Tushar Neupaney 10:04 am on May 6, 2009 Permalink | Reply
    Tags: , , , Linux, madwifi, modprobe, , , wifi, wireless   

    Install wireless in ubuntu debian 

    If you are trying to install wireless driver for linux in your ubuntu or debian machine try the following bash script in order to get read of the problem. For this you have to use madwifi and have to do modprobe as being the super user or root user (sudo). Here I will first download the madwifi from their site and then untar it then, modprobe the required drivers.

    Please comment about your result.


    wget -c http://snapshots.madwifi.org/special/madwifi-ng-r2756+ar5007.tar.gz
    tar xvf madwifi-ng-r2756+ar5007.tar.gz
    cd madwifi-ng-r2756+ar5007

    sudo make install
    sudo modprobe ath_pci
    sudo modprobe wlan_scan_sta

  • Tushar Neupaney 8:38 am on May 6, 2009 Permalink | Reply
    Tags: , google, Linux, , search, , Zenity   

    Search Google from terminal and save output to a file 

    Are you thinking to search and query for google from terminal shell with bash script. And what if you want to redirect the output to a text file. You can do it with the following code.

    This code also features zenity in order to save the output and query for what you are searching. This code is very productive and you can use it for many purposes.



    squery=$(zenity --text)
    (lynx "http://www.google.com/search?q=$(echo $squery|sed -e 's/+/%2B/g' -e 's/ /+/g')">$file) | zenity --progress \
    --title="Quering for the provided tag in google" \
    --text="Searching google ..... "\
    -- pulsate

  • Tushar Neupaney 5:58 am on August 3, 2008 Permalink | Reply
    Tags: Linux,   

    Thanks guys of Kathmandu! 

    When our head was busted with troubles setting up terminal server, for asking some help I could think of Surmandal. I hurrily called him and got him in his mobile.He tried to give me all the lines of dhcp.conf and I did what he said. Yet it was not working..

    Next call and he told me that he will find some help. Because we were in a room where internet was not available we could do noting but wait and keep crossing our fingers. Again Surmandal called us and said he has sent some messages (SMS’s) to me and we can do what it says. And yes, six messages came simultaneously. All the code carved in them, blishfully.

    (More …)

  • Tushar Neupaney 5:57 am on August 3, 2008 Permalink | Reply
    Tags: Linux,   

    Programming session in Biratnagar 

    Due to the excitement within, I went to biratnagar a day before the actual program started. Although Biratnagar is always hot, rainfalls were significantly making us feel cool… We tried to setup linux terminal server but in vain: even if we did not sleep upto 1 in the morning only connectivity could be established and nothing further to do.

    To sleep with something done sucessfully we setup internal modem of Prahmod and it was up and running and get into the bed. (More …)

    • Kshitiz 5:25 am on August 4, 2008 Permalink | Reply

      yes.. we too enjoyed the session..

      Hope u to see again in such again…

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc