Sunday, July 31, 2011

How to make a simple easter egg in ubuntu

How To Make A Simple Easter Egg in Ubuntu

Do you know "apt-get moo" ubuntu easter egg

If not
1)Go to terminal
2)Type "apt-get moo"

Now you can see
************************************
rukshan@rukshan:~$ apt-get moo
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
************************************

Lets learn how make that type simple easter egg

Step1

Make small shell file which echo something like above.(lets take easter.sh)

#!/bin/bash
echo "---------********-----------"
echo "------------*****-------------"
echo "---------------*-----------------"

Step2

*Then Make a executable form that shell file.(easter.sh)

*If You do not know How to make a executable from shell file.refer below link
http://vatfossworld.blogspot.com/2011/07/how-to-make-executable-file-from-shell.html

Step3

*Rename that executable file as you need.(any name which like.as a example i
renamed it as "vos")

*Then Copy it to /bin Folder

Step4

*ok you are already done.
*Now go to terminal type your executable file name(in my case i just typed "vos")

now you can see

---------********-----------
------------*****-------------
---------------*-----------------

This is your easter egg .Enjoy Your Own Easter Egg
CHEERS.....KWAK





How to enable your touch pad

I came across this problem when im working Ubuntu with my laptop. I noticed my touch pad is not working and i couldn't do any thing using my mouse. So I restart my machine and check but i couldn't find a way to re-enable the Synaptic Touchpad of my HP Pavilion Dv5. When im restaring my computer my i noticed my mouse works fine on the login screen, i was happy but after logged in again it doesn't work.

This can be happened when you suspend your computer with the disabled mouse pad(with the physical button ).

You can do this by using Gconf-editor GUI by Desktop -> Gnome -> peripherals -> touchpad then doing the Touch pad enable true

This is how you can do it by using terminal.

Command Line(Terminal) The Easy way
gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled 

Type this command and just press enter your mouse will work properly.

Bold

Friday, July 29, 2011

How to remove installed software packages in ubuntu

In normal case, if you want to remove a good quality software package you can remove it easily using,

1. synaptic package manager(GUI method) or
2. in terminal type sudo apt-get --purge remove yourpackagename

This should remove the package from the system.

wrost case:

But there are some cases, you try to install some bad quality software packages, after that the synaptic package manager crashes and you cant open up it.
And also you can't use terminal to remove it.

The real headache is you may not be able to install or remove any software package using software center or terminal.

if you are in this kind of situation the following command is the solution.


sudo dpkg --remove --force-remove-reinstreq yourpackagename

if you want to list all the packages in your system and make sure weather the package has removed properly, use the following command.

dpkg --list



note:
I personally had to face that problem from which i had to face many difficulties.

How to find out grub version of your machine

Open the terminal and type

$grub-install -v

This will print something like below.


grub-install (GRUB) 1.99~rc1-13ubuntu3


In the example, it is showing that GRUB2 is installed in your machine.

Don’t misunderstand “1” in the version number, as legacy GRUB will display as 0.97 (or earlier) :)

Thursday, July 28, 2011

How to create dialog boxes in shell scripting using zenity tool

zenity is a simple gui creation tool which comes default in ubuntu 11.04.you can make use of this tool to create nice dialog boxes in your shell scripts.

example explaination:

To ask a question from user add the following lines to where it should prompt.
zenity --question --text "Are you sure you want to continue ?"
echo $?

$? variable will contain the output of the GUI.

if user clicks yes $? variable will contain 0
if user clicks no $? variable will contain 1

according to the content of the $? you can do whatever you wish.

These are some other dialog boxes you can use.

1.To give warnings to the user

zenity --warning --text "This will kill, are you sure?";echo $?

2.To create a radio list

ans=$(zenity --list --text "How good are you in java?" --radiolist --column "Pick" --column "Opinion" TRUE expert FALSE Average FALSE "moderate" FALSE "newbe"); echo $ans

this will print the option user selected.

3. To create a check list

ans=$(zenity --list --text "What do you want?" --checklist --column "Pick" --column "options" TRUE "rice" TRUE "egg" FALSE "fish" FALSE "chicken" --separator=":"); echo $ans

this will print: rice:egg


4.To get a date from user

szDate=$(zenity --calendar --text "Pick a day" --title "Medical Leave" --day 30 --month 7 --year 2011); echo $szDate

this will print date as follows:
07/30/11


5.To get text input from user

szAnswer=$(zenity --entry --text "what is your name?" --entry-text ""); echo $szAnswer

this will print the user input.

6.To give the error message

zenity --error --text "Installation failed! "

7.To give information to the user

zenity --info --text "this is a blog you can get more geek stuff"


you can find out more zenity dialog boxes through internet.
Enjoy using zenity dialog boxes!!!!

How to change splash screen in Ubuntu Natty

Do not like the purple coloured screen and the ubuntu name that appears when the machine boots up to Ubuntu ?


 1.Then below is a simple way of changing it as you wish.I would like to offer total credit to following guide.

http://jechem.blogspot.com/2010/10/how-to-change-splash-screen-in-ubuntu.html


  • First create a directory named customsplash in /lib/plymouth/themes/
For that type in the terminal,

        sudo mkdir /lib/plymouth/themes/customsplash
Then you need to create customsplash.script.To do that just type following and it would open a gedit window for you.

sudo gedit /lib/plymouth/themes/simple/simple.script

Then copy and paste Following


  customsplash_image = Image("customsplash.png");
screen_ratio = Window.GetHeight() / Window.GetWidth();
customsplash_image_ratio = customsplash_image.GetHeight() / customsplash_image.GetWidth();
if (screen_ratio < customsplash_image_ratio)
  {  
     scale_factor =  Window.GetHeight() / customsplash_image.GetHeight();
  }
else
  {
     scale_factor =  Window.GetWidth() / customsplash_image.GetWidth();
  }
scaled_customsplash_image = customsplash_image.Scale(customsplash_image.GetWidth()  * scale_factor,
                                         customsplash_image.GetHeight() * scale_factor);
customsplash_sprite = Sprite(scaled_customsplash_image);
customsplash_sprite.SetX(Window.GetWidth()  / 2 - scaled_customsplash_image.GetWidth () / 2);
customsplash_sprite.SetY(Window.GetHeight() / 2 - scaled_customsplash_image.GetHeight() / 2);
customsplash_sprite.SetZ(-10000);

 Save the file and exit.

Next type in terminal:

sudo gedit /lib/plymouth/themes/customsplash/customsplash.plymouth

Then copy and paste this:

[Plymouth Theme]
Name=simple
Description=Personalized theme
ModuleName=script

[script]
ImageDir=/lib/plymouth/themes/simple
ScriptFile=/lib/plymouth/themes/simple/simple.script

Save and exit.

Next type in terminal:

sudo gedit /lib/plymouth/themes/customsplash/customsplash.plymouth

Then copy and paste this:

[Plymouth Theme]
Name=customsplash
Description=Personalized theme
ModuleName=script
[script]
ImageDir=/lib/plymouth/themes/customsplash
ScriptFile=/lib/plymouth/themes/customsplash/customsplash.script

Save and exit.


Then, in terminal type:

sudo nautilus

Type your password.

Navigate to File System>lib>plymouth>themes>customsplash

Copy and paste the picture you want to be on the splash screen.  Rename that picture to customsplash.png.

Now You need to update your current plymouth theme.

sudo update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/customsplash/customsplash.plymouth 100

sudo update-alternatives --config default.plymouth

choose customsplash.plymouth.

Still in terminal type:

sudo update-initramfs -u


Reboot and you will see your new splash screen.

You can perform this update via splash screen manager.To install this type in terminal.

sudo apt-get install splashscreenmanager


Then you can select the folder where your customised theme is in after running splash screen manager application.


Reboot and you will see your new splash screen.

2.Another way of changing the splash screen is just to do a little tweak in the file system.

You can find your default plymouth theme details inside /lib/plymouth/themes/ubuntulogo folder.Do a 'sudo nautilus ' in the terminal so that you can edit it's contents.Open them in gimp image editor and edit them according to your wish.
Changing ubuntulogo.png would change the splashscreen image and also you can edit the progress dot.

Remember to update your current plymouth theme as described above after applying above changes.
Have your own splash and enjoy.

Guess what?Once we used one of friend's splash screen to greet him on his birthday.He was quite happy to see 'Happy Birthday' on his splash screen instead of the usual screen.:)
May be that is one of the advantages of knowing such tweaks.Suprise your friends:)


How to make executable file from a shell script file

To create a executable from a shell script file you should have shell compiler installed in your machine.

first of all download it from the following link.
http://www.datsi.fi.upm.es/~frosal/

you should get the following archive.
shc-3.8.7.tgz

then install it as follows,
1.extract the shc-3.8.7.tgz archive

2.open up a terminal and type

$sudo mkdir -p /usr/local/man/man1

this will require your password.

3.In terminal go to the extracted location (inside shc-3.8.7 directory) and type,

$sudo make install

this should insatall shc in your machine.

To make sure shell compiler is properly installed,type the following

$shc

this should print something like this,
shc parse(-f): No source file specified

shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script


To create a executable,
in terminal go to the location of the shell script and type
$shc -v -r -T -f myshell.sh

this will create a C file as well as executable file for you.

To refer the manual of shc please visit the following link.