Friday 15 February 2013

Cool Linux Tips And Tricks

Ohk everyone
Hope you are liking all the cool Linux stuff that is continuously being posted on the blog.Here are some other cooler Linux Tricks..........

Collaborate with the screen command


Let’s say you and your co-worker are both working on debugging an application and your partner has run into a snag. Instead of having to march back and forth between offices, or leaving the comfort of your own chair (you lazy thing), you can log onto your co-workers machine and collaborate! Here’s how it works. Both machines will be Linux machines and both will have ssh accessibility. If you need to help your co-worker out follow these steps:

    Secure shell into your friends machine…the only catch is, you have to log on with his user name/password.
    Issue the command screen -s NAME Where NAME is any name you want.

Now your co-worker has to open up a terminal window and issue the command screen -x NAME Where NAME is the same name you used in your command. Now whenever either of you type in your screen both of you will see what is going on at the same time.

To detach yourself from this session you have to hit <Ctrl>a and then d. That means hold down <Ctrl>, hit a, and then hit d. You will be released from the session.

Execute files as programs in GNOME


Say you have that killer bash script you use for something tucked away in your home directory. You can run that script by open up a terminal window and issuing the command to run the script, OR…you can set up Nautilus so that files can be run with a simple double click. Now, use caution with this, because it can open up security issues. But if you know you are safe (are you ever really safe?) you can set this feature.

To set this up open up Nautilus to the directory that will house the script and then right-click the script and select Properties. In this new window click on the Permission tab and then check the box for Execute. Close the Properties window and then, back in Nautilus, double click that script and see what happens…it should execute.

Double your copy/paste pleasure


Yes you Read it right. It will be to your surprise that Linux allows you to copy 2 different segments of the text at the same time. This is because Linux have a primary and secondary buffer for copy/paste. You can highlight section A with the left mouse button drag/highlight method and then copy section B with the standard <Ctrl>c method. Now you two different pieces of text to paste – one with the middle mouse button and the other with <Ctrl>v!

Do try them Its fun using them :))

Hack Into Linux Kernal

Following is the procedure to reset root password if you are using GRUB as a boot loader:

   1. Select the kernel

   2. Press the e key to edit the entry

   3. Select second line (the line starting with the word kernel)

    4. Press the e key to edit kernel entry so that you can append single user mode

    5. Append the letter S (or word Single) to the end of the (kernel) line

    6.  Press ENTER key

    7. Now press the b key to boot the Linux kernel into single user mode

    8. At prompt type passwd command to reset password:


You need to mount at least / and other partitions:

# mount -t proc proc /proc

# mount -o remount,rw /


Change the root password, enter:

# passwd


Finally reboot system:

# sync

# reboot


My boot loader is LILO

At LILO boot loader type Linux single and press [ENTER] key:

Boot: Linux single

When you get the # prompt you will need to type passwd root to reset password:

# passwd

Reboot system:

# sync
# reboot

Restore GRUB2 after installing Windows

How I Restored GRUB2 after a Windows 7 Install. GRUB2 (Grand Unified Bootloader)  is a universal bootloader used by Ubuntu and other Linux Distributions. If you have a Linux Distribution installed on a partition, and attempt to  install Windows alongside it, your GRUB bootloader will be overwritten by the Windows bootloader, and your computer will only boot into Windows.



Recovering the GRUB2 Bootloader after a Windows Install  is simple. When finished, your Bootloader should detect all installed Operating Systems and automatically add a bootable menu item for each of them.
Note: This GRUB2 Installation process assumes that a Linux Partition still exists. If you overwrote Linux with Windows, this tutorial will not work for you, as there is no Linux system to recover boot.
How to Restore GRUB2 after installing Windows:
  1. Boot from an Ubuntu Live CD or Live USB
  2. Once up and running, Open a Terminal Open a Terminal
  3. Type sudo su (press enter after typing each command)
  4. Type fdisk -l Type sudo su and then fdisk -l
  5. Note which device contains your Linux partition (IE: /dev/sda1) Locate your Linux Device
  6. Type mount /dev/sdx# /mnt (replacing x# with your actual device and partition number)
  7. Type mount --bind /dev /mnt/dev
  8. Type mount --bind /proc /mnt/proc
  9. Type cp /etc/resolv.conf /mnt/etc/resolv.conf
  10. Type chroot /mnt mount and chroot
  11. Type grub-install --recheck /dev/sdx (replacing x with your actual device)
  12. Type reboot (to reboot your PC) Install grub 2 and reboot
Make sure to remove your Live USB or CD. Upon reboot you should be presented with a GRUB2 menu. However, Windows is missing. Now, I show you how to fix that.
Making GRUB 2 detect Windows Installs:
  1. Proceed to boot into your Linux environment.
  2. Open a terminal and type sudo update-grub (enter your root password when prompted) sudo update-grub
If all went well, grub should have updated it’s menu entries to reflect what it detected. Including existing Windows partitions.