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.

How to open up file browser with root permission

open up a terminal and type
sudo nautilus or
gksu nautilus

How to create debian packages

Using a debian package is one of the best methods for installing, upgrading, and removing software.
Before you creating a debian package you should know exactly where should go each files/folders in your software when installing.

Refer the following folder structure to decide which file to go which folder.

usr/share/ - main program binaries, packages, manuals, resource files.
/usr/bin - symbolic links to the main program binaries or you can have main program binaries.
/etc/- program configuration files.
/etc/skel - default configurations files to be installed for every new user.



Also ,Before doing all below, you should have installed the tools you need for creating deb packages.

To install all the packages needed for creating a .deb package, run the following command:


sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder

Here are the steps to follow to create a simple debian package.

1.Decide which file to go which folder for each of the file in your software.

2.Create a folder like ExampleDebianPackage_1.0.0

3.Inside that folder create folders like,
usr/share
usr/bin
etc/
etc/skel

and place your files inside those folders as appropriately.

4.then create another folder called DEBIAN inside ExampleDebianPackage_1.0.0

5.inside DEBIAN folder create a text file called "control" which is the most import file in debian packaging.


example control file:


Package: RoleSwitcher 
Version: 1.0.0  
Priority: optional 
Architecture: all
Depends: screenlets
Installed-Size: 1024
Maintainer: sampath bandara amarasinghe   
Description: Describe what can do your software primarily.
in addition to these fields there are some other fields.

like this create your own control file.

now you are ready to create the debian package.

6.open up a terminal and go to the ExampleDebianPackage_1.0.0 folder location and type

dpkg -b ExampleDebianPackage_1.0.0


this will create a debian package for you,


If you really want to change your ubuntu Start Button...

When it comes to Ubuntu it gave lots of facilities to customize your own machine than other operating systems. So its time to make the best out of it, sometimes you will amaze if I say its giving the opportunity to change your start button. If you need to make your start button as you wish it only have follow some few easy steps.
The first step is creating your own image to replace with the Ubuntu default start button. Considering image type the image should be in .SVG format. Because the start button support SVG and it is a vector type image so it is scalable without having jaggies. You can create the image easily using Gimp(because Gimp Supports SVG). If you going to create this image using windows I think it will impossible to even open a SVG. So try to create your beautiful image using Gmip :). When you done with your creative artwork you should re size the images as it need. Considering the file structure of ubuntu icons it has few images sizes, like 16 * 16 , 22*22, 24 *24, 32*32. So we should create these size of images. But im not forcing you to create all of the sizes because it resize when we give any size, for now lets make a 24*24 .SVG image and save it start-here.SVG

Now you should find where these icons are laying on your system. Its easy you can find it at /root/usr/share/icons. When considering the icons it comes along with the theme. A theme can compatible with one or more icon themes. When you stepped into icons directory you can see many icon themes with various names eg:- Humanity, Dust Sand, Humanity Dark, Gnome etc. Next you should find what theme you going to use and its default icon theme. You can find it by

1. Right clicking on your desktop and go to Change Desktop Background

2. Select the theme that you need to custermize and click on custermize button

3. Then you can make sure what is the default icon theme.


By knowing the default icon theme


1.Open usr/share/icon folder with sudo (try "sudo nautilus" on terminal, this will open a GUI with root permission)

2.Than open the icon theme that you need to change.( eg. Humanity)

3.Inside humanity go to places directory(this will shows some folders with numbers, those are the folders that contains images with the relevant size).

4.Now go to each folder and search for Start-here.svg and if it is there replace the image that you have created before.

Now it show time...... Change the theme and see the new image is applied. If it is have fun with your own start button.
There are many many more things that you can do using this icon folder. Because you can replace any of the icons according to your choice. So you can say bye bye.. to any icon and you can welcome any icon that you love. Try something new and have fun with Ubuntu :) .

How to give root permission privilages to a user

There are lots of applications and commands in ubuntu which need root passwords to be executed. you can avoid giving that password always, by following steps(editing /etc/sudoers.tmp).
in terminal type

1. sudo visudo
this will open up a file in terminal

2. Locate the following line
%sudo ALL=(ALL:ALL) ALL

3. Add the following line after above line
username ALL=NOPASSWD: ALL

4. Ctrl+x
it will ask to save

5. Give yes

You are done!!!
Then it will never ask you root passwords any more for applications which needs root password. :)

How to make a startup script in ubuntu

Create a Startup Script in Ubuntu
Step 1
Make a script as you need .(example vtest.sh)

Step 2
Copy that file(vtest.sh) to /etc/init.d directory.

Step 3
run follwing command to make the permission of the file.
sudo chmod +x /etc/init.d/vtest.sh

Step 4
run follwing command to add script to startup
sudo update-rc.d vtest.sh defaults


OK you are done :-).Now restart the machine & It ll run the script at startup.

When you want to remove it from Startup
run following command
update-rc.d -f vtest.sh remove

How to pass root password for your applications.

While working on developing our applications,  gksudo

How to edit your menu list in ubuntu

Most of us would love to see our own customized menu list in ubuntu,To have icons we would like for our programms,to have a menu including our programms with icons we would prefer.If you want to do this this post is for you.

1.You want to change the default icon that comes with the application.

The icons are located at /usr/share/applications folder.Look for the application for which you would like to change the icon.To apply the changes you would have to perform it as super user.Remember to do a 'sudo nautilus' on your terminal and goto above folder.

Right click on the icon on you want to change and select 'properties'.There you'll see the icon image and click on it and select the one you need.V would prefer selecting a .svg file since it is scalable.

2.You want to add a menu icon for your own script.







Tuesday, July 26, 2011

How to disable USB in an Ubuntu(Linux) machine

Considering an organization data should be very secured and protected. So USB is very vulnerable physical issue with computer data. If we could block the USB access from the users we can protect data by the people that needed. We came up this were when we creating Virtusa LiveConnect(a customized Ubuntu OS). There was a requirement form my manger to disable USB from the OS, that going to deploy in the kiosk machines and in the a meeting rooms. According to the policies of the Company the USB ports should be closed to the users. So when I got this requirement I Google on it and found some valuable resources.

----This is where you should go for disable USB----


http://www.cyberciti.biz/faq/linux-disable-modprobe-loading-of-usb-storage-driver/

According to the link there are many methods that we can do this thing. But tried with the modprobe.conf file.

Actually I did was i created a file called modprobe.conf file inside the etc directory( root/etc ). Because modprobe file used for automatic kernel module loading and can be configured to not load the USB storge. Then i write this script on it and save the file as sudo.

install usb_storage logger "formatted message"

This works for me and another amazing thing happened that was I was afraid that this will disable my USB dongle but it wouldn't because it only disable USB storages. So if you are willing to disable your USB storage, try this. On the other hand you can protect your own Ubuntu machine from unknown USB storages.






Wednesday, July 20, 2011

V

"Welcome aboard!" ,Said the FOSS world to us while  we were working on an open source project . We are a team inspired by the help out there in the FOSS world and willing to contribute.