Friday, July 13, 2012

Best VI tutorial

Most of  the begginers don`t like  to use vi /vim as their Text editor.Because it is little bit different than other text editors.Before i found this tutorial i also thought vi is a very ugly editor to use.But what i am going tell u is  a inbuilt linux command which shows a best way to practice vi editor.No need talk much more .(vi is one of the best text editor for programmers).So lets try it.

goto terminal
Type vimtutor


Follow the lessons.




Cheers 



Sunday, January 29, 2012

Create a very Simple Python HTTP sever

This is what I would going to tell is something awesome in Python and Linux. Most of the time we need to share our stuff among the LANs and some time we needed to create HTTP serves. Python has given a very simple solution for this. Python comes with a small inbuilt HTTP server and you can easily convert any of your directories into a web server by using a single command.

Lets say you need to share your home account with others.
cd /home/prabodha
Then, You have to just type this on your command line and press enter
python -m SimpleHTTPServer
Now your sever is up and running,Then It will out put something like this

Serving HTTP on 0.0.0.0 port 8000 ...
Now any one in your LAN can access your server via HTTP://YOURIP:8000
http://192.168.1.2:8000
And you can access you sever via localhost
http://127.0.0.1:8000
Have fun with your very simple http web sever without installing apache or something similar.





Wednesday, December 14, 2011

important system information files in ubuntu

In ubuntu there is a directory which contains all the information of the hardware of the running system,which is /proc.

Given below are important and frequently used files you can find inside /proc directory.

/proc/cpuinfo – this file contains information about CPU such as vendor_id,cpu family,model
,model name,cpu MHz,cache size etc.

/proc/meminfo – this file contains information about memory such as MemTotal, MemFree, BuffersCached,SwapCached,Active,Inactive etc.

/proc/loadvg – this file contains cpu load average information in last 1,5,15 minutes respectively.

/proc/partitions – this file contains partition related information.

/proc/version – this file contains linux version and gcc version of the system.

How to send an email using a python script

Hi all,
If you want to send a mail you have to follow several steps including the following.
open up the web browser.
login into your account.
click on compose mail.
compose the message specify receiver and send the mail.

But if you can send a mail through a script it will save time for you.
Here is a python code for send a mail.

import smtplib
sender= 'senders_name@gmail.com'
receiver = 'receivers_name@gmail.com'
subject='Python is a powerful scripting language'
text = 'This is an auto generated email using python!!!'

# Credentials (if needed)
username = 'senders_name'
password = 'password'

msg = """\
From: %s
To: %s
Subject: %s

%s
""" % (sender, receiver, subject, text)


# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(sender, receiver, msg)
server.quit()

if the file name is mail.py
run this command in terminal by typing

>>python mail.py

Monday, December 12, 2011

How to access and see web contents without a browser

Hi all,
Have you ever seen contents of web pages without a web browser? There is a method in ubuntu to read web pages in terminal.This is really easy and it is a matter of installing just a one package.


sudo apt-cache search elinks
elinks - advanced text-mode WWW browser

sudo apt-get install elinks

to visit google :
>>elinks www.google.com

Saturday, November 19, 2011

Lenovo Laptops with Ubuntu 11.04

Me and my team encountered with this problem when we are testing our OS on laptops. We installed it to various laptops and this Lenovo laptops make us a big headache. Because Ubuntu has many hardware compatibility problems, most of the Lenovo laptops are not supporting to this compatibilities.
We find few issues when installing and running Ubuntu on Lenovo laptops.

1.System boots to garbled display

Refer this link and you can find the solution.

https://bugs.launchpad.net/ubuntu/natty/+source/grub-gfxpayload-lists/+bug/777212

2.Splash screen is not working properly when booting up.

This isn't solved yet. The problem is Lenovo is not picking up the correct resolution when the machine boots up and it directly calls to the text splash screen as my knowledge. when machine boots it will pick the resolution correctly and it outputs the correct splash screen. Suppose to give the solved answer when we fixed this issue.

3.Lenevo L412 slow to restart and shutdown .

This is another problem that occur when we testing the os on Lenovo L412. It took more and more time to restart and shutdown. We tried to find the reason few days and we couldn't at last we found it is a problem with the third party software called Likewise that we use join the machines to the domain. There were some processes that wouldn't kill when its shutting down. So the shutting down is waiting until this process kills. Our project manager Chamindra de Silva helped us to fix this issue.
1. Observe what is the process take more time to kill.

Press ALT + CTRL + F1 on the shutting-down splash screen then it will show what are the processes are killing. For me it was Likewise. There was a process that runs with likewise that took more time to kill. So what we do was go to the likewise source where /opt/likewise. Then went through the code and force to kill all all processes rather than hanging.




Wednesday, November 2, 2011

Basic customizations in ubuntu 11.04 using bash

How to change the wallpaper:
in terminal type
gconftool-2 --type string --set /desktop/gnome/background/picture_filename "path/to/wallpaper"

How to change the login window icon:
in terminal type
sudo cp path/to/icon /usr/share/icons/LoginIcons/apps/64/

create desktop shortcuts:
in terminal type the follwing 2 commands.
cp /usr/share/applications/any_file.desktop ~/Desktop
chmod +x ~/Desktop/any_file.desktop

If you have screenlets installed how to run sreenlets in terminal.
type the following command.
ex:run calculator screenlet:
python /usr/share/screenlets/screenlets-pack-basic/Calc/CalcScreenlet.py

change start menu icon:
in terminal type:
gconftool-2 --type string --set /apps/panel/objects/object_0/custom_icon "path/to/icon"
gconftool-2 --type bool --set /apps/panel/objects/object_0/use_custom_icon "true"