Posts

    Showing posts with label ubuntu. Show all posts
    Showing posts with label ubuntu. Show all posts

    Thursday, 28 April 2016

    Problem with clipboard on Ubuntu

    Clipboard on Ubuntu is "broken". Well, maybe not. But copy-paste is broken in a lot of applications on Ubuntu. Let me give you an example,

    • Open LibreOffice.
    • Write something and copy it.
    • Paste it somewhere else. It works as expected.
    • Now close LibreOffice and try pasting. It won't work.
    This is a well known bug - Copy-Paste doesn't work if the source is closed before the paste; affecting a lot of applications on Ubuntu. And they are not so keen on fixing it, atleast not any time soon.
    The reason for this is that these applications do not comply with the clipboard specification from FreeDesktop
    If a client needs to exit while owning the CLIPBOARD selection, it should request the clipboard manager to take over the ownership of the clipboard, using the SAVE_TARGETS mechanism. If there is no clipboard manager, or if the SAVE_TARGETS conversion fails, the application should simply exit.
    Applications need to transfer ownership of the clipboard to clipboard manager before exiting for copied data to perisist after it exits. There is certainly nothing you can do about it, unless offcourse you are willing to modify the source code of each of these applications to make it comply to FreeDesktop specs.

    Fix. Well.. workaround.

    The reporter/ moderator of the bug report suggests that we should install diodon, klipper, glipper, parcellite or xfce4-clipman as a workaround for this issue.
    Working of diodon


    Tuesday, 26 April 2016

    Ubuntu 16.04 won't wake up from suspend

    I recently installed Ubuntu 16.04 LTS Xenial Xerus on my Thinkpad E550. I honestly regretted it not just because it doesn't support AMD proprietary fglrx driver aka AMD Catalyst or AMD Radeon Software but because the suspend feature stopped working.

    I initially thought that this had something to do with video drivers that I had installed on Ubuntu 15.10 which were now incompatible with 16.04. I realized that this was not the case as the issue persisted even on opensource drivers that it is compatible with.

    Also on a closer observation I realized that it was not that my system was not able to wake up from suspend, but that it was not able to suspend at all. On suspending, the screen would go off but my laptop kept running, heating up and draining battery. This problem existed when I hibernate or shutdown as well.

    Now the only possible reason for this is some problem in acpi which is not letting my system to suspend. Ubuntu 16.04 is shipped with kernel 4.4. A quick search on this issue on kernel 4.4 made me realize that this exists across several destros and mostly on thinkpads. So I upgraded to kernel 4.5 and the problem is resolved.

    Installing kernel 4.5

    32 bit

    64bit

    Then reboot!

    Thursday, 4 April 2013

    Open with script in Gnome/Ubuntu

    I always liked the feature open with script which was there in old ubuntu. I have no clue why they removed it. However as always in Linux there is always a way to do anything! Today I will show you a simple way( complex than before though ) to do it. Using this I was able to install Picasa Photo Viewer, Logism, yEd, MS Office..etc on my Ubuntu \m/

    Step 1: Find MimeType of the target file (the file you want to open). You can find it in file properties


























    Step2: Download this gist. And make it executable:

    $ chmod +x open_with_script.sh

    Step3: Then run the script and enter necessary details. For example I was trying to install yEd, an awesome Software Engineering Drawing tool. This is what I did:
    NOTE that if the command is <command> <file name> enter as <command> %U





















    Step4: This step is optional. This is to set font to the script. If you don't wanna do it, skip it. Open application called "Main Menu" or alacarte which comes by default in ubuntu. Then search for the script you just added and then set the font.

























    Step5: Now just set the file to open with the script by default if necessary using file properties.


























    Now you can simply open the file using yEd by default. So you are done!!! 

    Tuesday, 26 February 2013

    Make STAR WARS message greet you when you open the terminal

    I am a great fan of STAR WARS like many of you out there. So I decided to write a script which greets me with star wars message every time I open my Terminal to code.
    Suppose say you are using Bash, when you open your terminal the file ~/.bashrc will run. Similarly if you are using Zsh => ~/.zshrc will run. So basically I can just put an echo statement in that to make it greet me every time I open my terminal. Today lets do something more interesting. Someting like this:


    To get this you can just download this gist and add the contents in it to ~/.bashrc or ~/.zshrc or ~/.cshrc ..etc depending on which shell you are using. Or you can just copy the following and paste it in ~/.bashrc or ~/.zshrc or ~/.cshrc


    Saturday, 29 December 2012

    Minimizing all windows to show desktop in gnome 3.5.4

    I Just upgraded to gnome 3.5.4 from gnome 3.4 on Ubuntu and now I feel that it is one of the most buggiest gnome versions ever :(
    Gnome shell extensions are one of the best things ever for me especially when gnome came up with installing extension from their website. But unfortunately for Gnome 3.5.4 almost no extensions in their website support it :'( . And it is extremely hard to install gnome shell extensions from their source.
    One of the most annoying thing is that "Hide all normal windows" feature doesn't seem to work. And bug while changing brightness still not fixed.
    So I have decided to manually fix each of the bugs myself for now.
    Today I will show you how to enable "Show Desktop" or "Hide all normal windows"

    Open Terminal and install xprop and xwit

    sudo apt-get install xprop xwit 

    Download the Gist file which i have created or copy from below and save it as minimize.sh
    Loading ....
    Then open Keyboard shortcuts and create a Custom Shortcut










    Then give a name to the shortcut and in place of command give the link to the script which you just downloaded. Make sure that that file is executable. If not change it using file properties or use chmod.

    Now assign some key for it preferably Super+D

    If you don't  like doing all those there is a docklet called "Show Desktop" for Docky which still works pretty well if you don't mind using your mouse :P

    Monday, 3 December 2012

    Recover grub using ubuntu live CD


    Sometimes when you have both windows and other linux it is possible that windows somehow replaces  the bootloader with its own bootloader like NTLDR or MBR and this does not detect other operating systems. For example when you partition your hard drive using windows your bootloader is also replaced. Today I will show you how to recover grub using ubuntu live CD.
    The key here is to mount the linux file system to a particular location and mounting all the required devices, virutal files..etc to the mount point and then changing the working root to the mount point and updating the grub file (grub.cfg or menu.lst)

    1. Boot with your ubuntu live CD and select try ubuntu.
    2. After loading ubuntu, open Terminal
    3. Now say your linux file system exists in /dev/sda1 (use any application like 'Disks', 'Gparted', 'fdisk' to find it)
      Mount all the required folders to your linux file system.

      $ sudo mount /dev/sda1 /mnt
      $ sudo mount --bind /proc /mnt/proc
      $ sudo mount --bind /sys /mnt/sys
      $ sudo mount --bind /dev /mnt/dev
      $ sudo mount --bind /usr /mnt/usr
    4. The key here is to change the working root to the one in your installed linux
      $ sudo chroot /mnt

      If you get any error here like '/bin/bash not found.' or something, it maybe because /bin and /lib are not there. So type the following commands to bind the existing /bin and /lib with the ones at /mnt and retry chrooting to /mnt (type the above command again):
      $ sudo mount --bind /bin /mnt/bin
      $ sudo mount --bind /lib /mnt/lib

      If the above problem still persist try mounting /dev/pts also (it has something to do with signature keys)
    5. Now simply update and install grub to replace the existing bootloader

      $ grub-install /dev/sda
      $ update-grub or $ update-grub2
      If you get any error in the above step try this:
      $ grub-mkconfig -o /boot/grub/grub.cfg

    6. Now reboot the system
    Note: Sometimes it may happen that the version of the grub installed might be old. So to replace it with the original version simply boot using your linux and repeat step 5 with root permission.

    Update:
    Some people say that they get this error when the do update-grub :
    /etc/grub.d/00_header: 28: .: Can't open /usr/share/grub/grub-mkconfig_lib

    The reason is that some ubuntus have the required file for updating grub in a different place. So copy it to correct location:
    $ sudo cp /usr/lib/grub/grub-mkconfig_lib /usr/share/grub/
    and then update-grub

    Saturday, 1 December 2012

    Increase size of root partition in Linux

    Your root partition is out of juice and you cant afford to redo the installation procedure? Well today i am going to teach you how to solve this problem.
    There are two ways of solving this problem.

    1. Extend partition using gparted

    Install gparted.
    In ubuntu:
    $ sudo apt-get install gparted
    In fedora
    # yum install gparted
    Then resize your root partition to get more space for it using gparted.

    Note: This is risky and will not work on certain kind of partitions. If the above didn't work use second method.

    2. Using soft (symbolic) links

    Soft links are equivalent shortcuts in windows but these are more powerful. Here we can move files to other partition and create soft links of the files to their original places. However make sure that the other partition is always mounted. See this if you want to know how to auto mount devices.

    There are certain files which are not very crucial but are necessary for some application to perform
    for example ~/.cache folder has all the cache of applications including browsers..etc. Music,Video, Downloads, Documents are other such folders.
    1. Move all the folders to another partition, say it is /media/Ambusher/.
    2. Open terminal and create soft links
      $ ln -s /media/Ambusher/cache ~/.cache
      $ ln -s /media/Ambusher/music/* ~/Music/
      $ ln -s /media/Ambusher/videos/* ~/Video/
      $ ln -s /media/Ambusher/documents/* ~/Documents
      $ ln -s /media/Ambusher/downloads/* ~/Downloads
    3. Similarly create soft links for other folders also.
    Now you would have freed up a lot of space for your root partition.

    Sometime you may have to delete all the soft links in a folder. To remove all soft links in a folder do this:
    find FOLDER -maxdepth 1 -type l -exec rm -f {} \;
    For example:
    find ~/Pictures -maxdepth 1 -type l -exec rm -f {} \;
    Note: Soft links won't work if the disk partition type is FAT 16/32 or WIN 16/32 but works perfectly fine on NTFS
    Have a nice day!!

    Setup apache, PHP, MySQL, phpMyAdmin on ubuntu

    Today i will show you how to setup apache, PHP, MySQL and phpMyAdmin on ubuntu

     

    Express Install

    sudo apt-get install apache2 php5 mysql-client mysql-server php5-mysql

    Then restart the apache server
    sudo /etc/init.d/apache2 restart or sudo service apache2 start

    You are done!! If you want to do it step by step do this:

    Setup apache

     

    Type this in terminal
    $ sudo apt-get install apache2

    If you find any problem at any stage try restarting the apache server like this
    $ sudo /etc/init.d/apache2 restart

    Setup PHP

    Type this in terminal
    $ sudo apt-get install php5

    Your htdocs are present in /var/www/ you have to be root to change/create files by default. To fix this
    $ sudo -i
    # cd /var/
    # umask 0000
    # chmod +rwx -R www
    # chown <your username> www
    # chgrp <your username> www
    # exit

    Note: You may have to do this sometimes in the future also

    Now edit /var/www/index.php and add anything in php
    Open browser and type localhost as url and check whether it works

    Update
    Many people asked me how to see the error log of PHP. To see use this command:

    tail -f /var/log/apache2/error.log


    Setup MySQL

    Type this in terminal
    $ sudo apt-get install mysql-client mysql-server

    Note: You will be asked to enter password for your database. Enter a password and don't forget it as it is pretty important

    Connect PHP and MySQL

    In order for PHP to access MySQL do this
    $ sudo apt-get install php5-mysql

    Setup phpMyAdmin

    Download phpMyAdmin from here.
    Now extract contents and move phpMyAdmin to /var/www/

    Open /var/www/config.sample.inc.php and change following lines

     
    /* FIND THESE LINES AND CHANGE THEM IN YOUR CONFIG FILE*/
     
    /* Authentication type */
     
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
     
    /* Server parameters */
     
    $cfg['Servers'][$i]['host'] = 'localhost';
     
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
     
    $cfg['Servers'][$i]['compress'] = false;
     
    /* Select mysql if your server does not have mysqli */
     
    $cfg['Servers'][$i]['extension'] = 'mysqli';
     
    $cfg['Servers'][$i]['AllowNoPassword'] = false;
    

    Now open localhost/phpMyAdmin on your browser


    Run anything on startup in ubuntu


    Sometimes we might want some set of things to happen on startup. If it is a simple application/script we can simply add to startup applications. However this fails if we need to be root to run that. Today i will show you how it is done.
    Say I want to mount a set of disk drives on startup.




    1.  Open Terminal and type
      gedit mounter.sh
    2. Type the set of commands you want to run on startup in this file. Here it is
      mount /dev/sda2 /home/alse/Ambusher
      mount /dev/sda3 /home/alse/C
    3. Save and close the file. Now change permissions of the file.
      $ chmod +rwx mounter.sh
    4. Then move it to /etc/init.d
      $ sudo mv mounter.sh /etc/init.d/
    5. Add mounter.sh to rc.d
      $ sudo update-rc.d mounter.sh defaults
    Now mounter.sh will run on startup.

    Now I will show you how to remove something which you have already added
    Suppose say i want to remove mounter.sh from rc.d. Type
    $ sudo update-rc.d -f mounter.sh remove

    Update:

    Now you can just execute the script by adding in /etc/rc.local