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

Friday, January 3, 2014

I am so tired of Unity: Part 2 AKA I like Kubuntu/KDE

I have been trying Kubuntu for last week or so and so far I am really liking it. I must say that I am impressed. KDE looks a lot more polished and stable than Unity or even GNOME 3 for that matter. The UI is really sleek and stylish. The effects are good looking and so are fonts and icons. The text in title bars, buttons, menus and everywhere else is thinner and a lot more smoother than it is in Ubuntu. And most importantly I really like Kate. I am used to Notepad++ and Gedit always felt so ancient in comparison. But Kate seems like a good replacement. I think I will stick around for a while.

Friday, December 27, 2013

I am so tired of Unity

I am an avid Ubuntu user. It has been my primary OS since 2008 i.e for almost six years now. But I am now getting tired of Unity, not Ubuntu, just Unity. For those not familiar with the term, Unity is the desktop environment of Ubuntu. Ubuntu switched to Unity from GNOME a while ago when GNOME 3 was about to be released. I have read that Canonical did not agree with the direction GNOME was heading in and when they were not able to sort their differences with GNOME they decided to create their own desktop environment for Ubuntu and so Unity was created. But this is what I have read on internet and considering how reliable internet is, I am not sure what really happened but the fact remains that Ubuntu switched to Unity.

Unity has its own merits but it has made it difficult for me to perform day to day operations. For example whenever I have to run an app for which I don't have a launcher icon I have to click the home button and then type the app name for it to appear in the app list and then click on it. I don't like that. I also do not like that there is not button to minimize all windows. I also do not like the fact that every program has its menu in the top panel. When I have two windows open side by side and I need to use their menu, I have to first select the window and then move my pointer miles away to top panel to get to the menu. Similarly I like the close button for a window to be in the top left or top right corner of the screen when they are maximized. This makes closing them easy. But with Unity this is no longer possible. There are a lot of other similar issues which are not a big deal them self but together they make it really difficult for me to perform everyday operations.

But this does not mean I am giving up on Ubuntu, I am not ready to go back to Windows, but I have decided to give Kubuntu a try as well and see how I feel about KDE. No matter whom I end up with, KDE or Unity, I will still be using Ubuntu.

Saturday, December 17, 2011

Android: Debugging your application on real hardware (phone/tablet) on Ubuntu 10.10

If you own an Android smartphone and want to debug your application on your smartphone instead of emulator, you need to declare your application debuggable and setup your device.

To declare your application debuggable, add android:debuggable="true" to  element in your application's AndroidManifest.xml

To setup your device, connect it to your computer with a usb cable and run following command:
adnan@adnan-laptop:~$ adb devices
List of devices attached
emulator-5554 device
???????????? no permissions
if the output contains a line with many question marks (?), as in the above example, then Ubuntu was not able to identify your device. In this case create the file /etc/udev/rules.d/51-android.rules and add following line to it:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
Here the 0bb4 is the vendor id for HTC (Check the list of vendor ids at the end of this post for vendor id of your device) Now unplug and replug the usb cable connecting your device and again  run "adb device":
adnan@adnan-laptop:rules.d$ adb devices
List of devices attached
emulator-5554 device
SH1A6TR23522 device
Your device is ready now and can be used for debugging an application but before trying to install and debug your application on this device, make sure that you have selected the following options on your device:
Settings->Applications->Unknown sources
Settings->Applications->Development->USB debugging
Now when your run your app from Eclipse, you will be presented with a dialog of available emulators and devices. To run your app on device instead of emulator select the device from this dialog and your app will be installed and run on the device.



Vendor IDs:

CompanyUSB Vendor ID
Acer0502
ASUS0B05
Dell413C
Foxconn0489
Garmin-Asus091E
Google18D1
Hisense109B
HTC0BB4
Huawei12D1
K-Touch24E3
KT Tech2116
Kyocera0482
Lenevo17EF
LG1004
Motorola22B8
NEC0409
Nook2080
Nvidia0955
OTGV2257
Pantech10A9
Pegatron1D4D
Philips0471
PMC-Sierra04DA
Qualcomm05C6
SK Telesys1F53
Samsung04E8
Sharp04DD
Sony Ericsson0FCE
Toshiba0930
ZTE19D2

Saturday, May 21, 2011

VPTCL Wireless: Connect to internet using VPTCL from Ubuntu 10.04


PTCL DSL is great. Its cheap and offers good (reasonable) speed. But PTCL landlines are very untrustworthy and you never know when it will stop working. So I keep VPTCL as my backup internet connection. It is not fast but it works and has almost no down time. PTCL provides drivers and documentation for connecting to internet with VPTCL but everything is for Windows. So you are at loss if you are a Linux user. But dont worry, its really easy to connect VPTCL from linux especially Ubuntu. Basically the driver is there (usb-serial), so all you need is a dialer to connect to internet. Wvdial is a good tool for dialing different PPP connections. Earlier I have written about connecting to Windows VPN using it. To install Wvdial use the following command:
sudo apt-get install wvdial  
after the installation is complete, open file /etc/wvdial.conf and add following lines to its end:
[Dialer VPTCL]
Modem = /dev/ttyUSB0
Baud = 230400
Phone = #777
Init1 = ATZ
Stupid Mode = 1
Dial Command = ATDT
Username = vwireless@ptcl.com
Password = ptcl
PPPD Options = lock noauth refuse-eap refuse-chap refuse-mschap nobsdcomp nodeflate
Now save and close the file. You will need sudo rights for installing wvdial and editing the conf file.
Now from terminal issue the following command:
wvdial VPTCL 
Wvdial will connect to internet using VPTCL. You will get the connection information in the terminal after issuing this command i.e DNS servers and other stuff. Don't close the terminal as this will disconnect you from internet. Only close it when you want to disconnect. Pressing Ctrl-C in terminal will also end wvdial and disconnect you from internet.

Note: PTCL charges 2 rupees per 20 minutes for VPTCL internet service.

Tuesday, March 29, 2011

Install Firefox 4 in Ubuntu

Firefox 4 is available for Ubuntu 10.04 and 10.10. To install it use the following commands

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get upgrade

This will update your Firefox to version 4. Note that this will not install Firefox 4 side by side with your previous version as used to be the case with beta versions. As this installs the stable release version of Firefox so your previous version will be removed and after installation you will only have Firefox 4.0.

Wednesday, January 19, 2011

Limit Internet Bandwidth Usage (internet speed) in Ubuntu

There are many reasons one would want to limit internet bandwidth/speed on a system e.g you dont want your siblings to choke your internet or, if you are a network admin, you dont want one user, downloading a big movie over torrent, to hurt every one else's surfing.

To limit internet bandwidth on a Ubuntu machine install wondershaper. For this open a terminal and type following command:
sudo apt-get install wondershaper
Now use ifconfig command to find out the name of interface connected to internet. The name will be something like eth0, eth1, wlan0 or something similar. In my case it is eth0


Now issue a command similar to follwoing (relpacing eth0 with your interface name):
sudo wondershaper eth0 1024 256
this will limit the download speed to 1024 Kbps and upload to 256 Kbps. Remember that this limit is for all internet traffic i.e torrent, ftp, browsing and any thing else.

If you want to remove these limits use
sudo wondershaper clear eth0
again replacing eth0 with your interface name

Tuesday, December 21, 2010

Install Firefox 4 beta (Minefield) on Ubuntu

UPDATE: Firefox 4 (stable version) is now available for Ubuntu. So you can install it instead. Instructions on installing Firefox 4 can be found here

To install Firefox 4 beta on Ubuntu execute following commands
sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa
sudo apt-get update
sudo apt-get -y install firefox-4.0
The new browser will appear as Minefield 4.0 Web Browser in Applications Menu. It will be installed alongside your existing Firefox install (if any).

Sunday, December 19, 2010

Track Your Internet Bandwidth Usage with NTM (Network Traffic Monitor)

For those of us with limited network connection Network Traffic Monitor (NTM) is a very helpful tool. It can monitor upload, download or total network traffic. It can also monitor time spent online and lot of other things. NTM is not available in Ubuntu repositories so you will have to download the .deb from here and install it. After installing start NTM from Applications->internet->NTM. Now right click on the NTM icon  in the taskbar and select preferences from the menu that appears. This will open the NTM preferences window. In the General tab specify the interface that you use to connect to internet. In my case it is wlan0


Now select Traffic tab and enter the traffic limit of your internet plan. I have entered 2G i.e 2048MB as an example value.


You can select Auto Disconnect if you want the connection to disconnect as soon as you reach your limit. This can be very helpful if extra MBs are charged at a high rate. Click Apply and you are all done. NTM will monitor your internet use and you can left click on the NTM icon in Taskbar to see your current speed, bandwidth you have consumed and lot of other information.


If you have time limited connection and not bandwidth limited i.e you buy internet hours and not GBs then you can also use NTM to keep track of time you spend on internet. Open the time tab to configure time related options.

Monday, December 13, 2010

Creating a screencast in Ubuntu Linux

To create a screen cast in Ubuntu we need three softwares
  • recordmydesktop for capturing and recording the desktop
  • gtk-recordmydesktop, a graphical frontend for recordmydesktop
  • mencoder for encoding the recorded video to xvid or any other format.

If you also need to record your voice in the screencast then you will need a properly configured sound card along with a decent microphone. You can test your microphone and sound card settings using Sound Recorder.

You can install the softwares using the following command:
sudo apt-get install mencoder recordmydesktop gtk-recordmydesktop
after installation completes run gtk-recordMyDesktop from Applications->Sound & Video menu

If you want to record your full desktop then simply press record and recording will start. You will see a small square in the Notification Area.
This shows that recordmydesktop is currently recording. When you are done and want to stop recording just click on this square and recording will stop. This square will then turn into a red circle and recordmydesktop will start encoding the captured video. It will take some time before it finishes, after that you can find the recorded video in your home directory.
But if you dont want to record complete desktop but only want to capture a single window then you can click on Select Window button and then click on the title bar of the window that you want to record and recordmydesktop will only record the selected window.
If you dont want a specific window but you want the recording to be limited to specific screen area then you can select that area from gtk-recordMyDesktop's preview area. Just left click and drag your mouse to select the desktop area for recording.
recordmydesktop produces files with .ogv extension. I dont know what codec it uses but the files are big e.g a 10 min recording my take upto 60-70 MB. To covert these files into divx use following commands
mencoder your_file.ogv -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=658:pass=1 -oac pcm -o /dev/null
mencoder your_file.ogv -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=658:pass=2 -alang en -oac mp3lame -lameopts br=96:cbr:vol=6 -o your_file.avi
This will convert the ogv files into avi with xvid video and mp3 audio. After that you are done and your screencast is ready. If you want to edit this avi file to add some effects or any thing you can use Pitivi video editor which comes by default with Ubuntu (10.04 onwards)

Saturday, December 11, 2010

Linux Tutorial 1 - Installing Ubuntu

This is my first attempt at creating a screencast, a video tutorial explaining the installation of Ubuntu Linux.

Part 1: Installation




Part 2: Post Install

Thursday, December 9, 2010

Simple network usage tracking with vnstat

If you use Linux, you can use vnstat to track your network usage.
Install vnstat using
sudo apt-get install vnstat
then configure it to monitor a network interface
sudo vnstat -u -i
you can find your network interface name using ifconfig or ip addr command. In my case its eth0

Now to see your network usage issue vnstat command


to view daily, weekly or monthly stats you can use -d, -w or -m switches with vnstat respectively i.e vnstat -m
To reset all the counters to zero you will need to delete the interface's database with vnstat and then recreate it. Use the following command for this purpose
rm /var/lib/vnstat/<interface>; vnstat -u -i <interface>
Please note that vnstat is not a packet sniffer, it simply uses the network stats exposed by kernel. This means there is  non-internet network traffic on your interface e.g file sharing, network gaming or etc than it will also be included in the stats. You can use vnstat as bandwidth monitor if you use a dedicated interface for internet usage like 3g usb modem.

Tuesday, November 30, 2010

About .bashrc .bash_profile .profile .bash_login and /etc/profile

Have you ever wondered what is the purpose of ~/.bashrc ~/.bash_profile ~/.bash_login ~/.profile and /etc/profile files in Linux.

Bash is the default shell on most of the Linux distributions like Fedora and Ubuntu. If you take a look at man pages for Bash, you will get the following explanation:
When bash is invoked as an interactive login shell, or as a  non-interactive  shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.  
...
When  an  interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exist. 
Interactive shell is the one which is not running because of a script and lets you enter commands to interact with it. Login shell is the one where you are asked for user name and password before you can enter commands. An example of an interactive login shell is the one that you get after you login to a system using ssh. An example of non-login interactive shell is a shell that you get when you run terminal from menu item or some icon.

So when you login to a Linux system, first commands from /etc/profile (if it exists) will get executed. Then the system will look for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and execute commands from the first of these files that it founds. And when you open Konsole/Terminal from KDE or GDM, first commands from /etc/bash.bashrc (if it exists) will get executed and then commands from ~/.bashrc (if it exists) will get executed.

So if you want to execute a command for all users then you will need to add it to /etc/profile but if you want a command executed for a specific user then you can add it to .profile, .bash_profile, .bash_login or .bashrc in his/her home directory.

Please keep in mind that KDE and GDM are not login shells so there behavior is different. I dont know about KDE but GDM first executes command from /etc/profile and then from ~/.profile.

Friday, May 14, 2010

How to connect to Windows VPN from Ubuntu without the help of GUI

In Ubuntu, the easiest way to connect to VPN is using NetworkManager. But some times it is not possible. Like in my case NetworkManager wont detect my 3G Evdo modem, so I have to use gnome-ppp to connect to internet. And because of this NetworkManager thinks that there is no active connection and it wont let me connect to VPN. So I used pon and poff scripts to control my VPN connection. These scripts are provided by ppp package which is available in every Ubuntu installation by default. Given below is how I connected to a Windows PPTP VPN server.

First thing you need is to install pptp-linux package. So do
sudo apt-get install pptp-linux
Now create a file /etc/ppp/peers/vpnfile. You can change the file name vpnfile to any name you like but keep it simple as you will need it to connect to your VPN. Now add following lines to this file:

remotename myvpn
linkname myvpn
ipparam myvpn
pty "pptp  --nolaunchpppd "
name 
usepeerdns
require-mppe
refuse-eap
noauth
defaultroute

#defaults from the pptp-linux package
file /etc/ppp/options.pptp

The first three parameters provide name of the remote system, name for the link and a value to be passed to scripts in ip-up.d and ip-down.d directories, respectively. These values dont need to be same and can be different. The scripts in ip-up.d directories are called when a connection is established and the ones in ip-down.d are called when a connection is terminated. Next parameter i.e pty specifies that the given script should be used to communicate rather than any terminal device. Rest of the parameters control different attributes of the connection i.e what protocol to use or refuse or whether to use encryption or not and etc. The last parameter i.e defaultroute adds a default route to system routing table when this connection is established. This means that when this connection is active, by default all traffic is routed on this connection. If you dont need this behaviour, remove it and add scripts to ip-up.d and ip-down.d to add only your required routes.
More detailed explanation of these parameters can be found in manual entry for pppd i.e man pppd.

You will also need to add a line to file /etc/ppp/chap-secrets with username and password for this connection.

username connection-name password *


Connection name in this line must be same as remotename, which we have set to myvpn. 
Now to connect to vpn, issue command 
sudo pon vpnfile
and you are all set, connected to your vpn. To disconnect from the vpn, issue command
sudo poff vpnfile

Wednesday, May 20, 2009

Solving Skype audio problem in Ubuntu 9.04 (Jaunty)

I installed Skype on Jaunty but my audio was not working even though i was able to record my voice using Sound Recorder. After going through many web pages and trying many solutions the one that finally worked for me is this.

stop skype, open terminal and issue following commands
  1. sudo killall pulseaudio
  2. sudo apt-get remove pulseaudio
  3. sudo apt-get install esound
  4. sudo rm /etc/X11/Xsession.d/70pulseaudio
now start skype and every thing works fine.

Sunday, November 9, 2008

Installing Sun Java 6.0 on Ubuntu

Ubuntu is defaultly deployed with GNU libgcj JVM which doesn't work with some applications, for example Eclipse. Also in my experience GNU libgcj JVM is much slower than Sun JRE.
Installing Sun Java 6 JRE is simple. Just issue the following command from shell:
apt-get install sun-java6-jre sun-java6-bin sun-java6-plugin sun-java6-jdk
You will need to be root or use "sudo" to perform this operation. You can skip package sun-java6-jdk if you dont plan on doing development in Java.

Once these packages are installed you can use Alternatives to make sun java your default JVM. To do this issue following command from shell:
update-alternatives --config java
You will get a screen like following:

The * sign means that this JVM is default. Enter the number for Sun JRE which in my case is 3. Now you can check your java version using: java -version

Sunday, October 5, 2008

Installing and using knockd to allow temporary SSH access

knockd is a port-knock server which runs silently on your machine until it sees a specific port-sequence. When it sees the specific port sequence it performs an action associated with that sequence. Port sequence and the associated actions can be easily configured in knockd's configuration file /etc/knockd.conf.
In below example we will use knockd to, upon seeing a specific sequence of port knocks, open a "hole" in our firewall to allow ssh access from outside. Dont worry this is not insecure as you will be the only one knowing that port sequence, unless ofcourse you share that sequence with some one else :)
To accomplish this we will need to do following:
  • install knockd
  • configure it to allow ssh access on seeing a specific port sequence
  • configure it to close ssh access on seeing a different port sequence
Install knockd using: sudo apt-get install knockd. This installation will create a file /etc/knockd.conf.
Open this file using “sudo nano /etc/knockd.conf”.The file will look something like this:

----------------------------------------------------------------------------------------------------

[options]

logfile = /var/log/knockd.log

[openSSH]

sequence = 7000,8000,9000

seq_timeout = 5

command = /sbin/iptables -A INPUT -s %IP% -p tcp --dport 22 -j ACCE$

tcpflags = syn

[closeSSH]

sequence = 9000,8000,7000

seq_timeout = 5

command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCE$

tcpflags = syn

-----------------------------------------------------------------------------------------------------

we need to change the sequence and seq_timeout lines for both, [openSSH] and [closeSSH] sections. This is just a precautionary measure as sequence 7000,8000,9000 is a very common and well known. So change the file to look as one below. You can use any sequence that you like but avoid commonly used ports. You can even use ports that are closed/blocked on ur system as knockd works on link layer and will see all the traffic destined for your system even for closed or blocked ports. Dont change command, tcpflags or logfile options. After you have changed the file save it.


Now you need to edit your /etc/default/knockd. Open that file using “sudo nano /etc/default/knockd”. Change it to match the following. This will ensure that knockd is always run as daemon at init i.e at system startup.

The “-i eth0” will ensure that knockd listens on eth0 for port knock sequence. You can change it to whatever interface that you want knockd to listen at.

Now start knockd. You need to do this just this one time.

sudo /etc/init.d/knockd start

Now you are up and running :). knockd will open ssh access for you on seeing the specific port knock sequence. To try this try SSHing this computer from any other machine connected to this computer on interface that you selected in /etc/default/knockd which in my case is eth0. Your firewall will not allow access. To get access you will need to knock at the doors of your computer and for that you will need knock client on the machine that you are using to do ssh. If you are using a linux machine install knockd package and if you are using windows machine you can use windows client from here.

To knock issue following command ( replace 192.168.1.2 with the IP of your computer)

knock 192.168.1.2 5000 7000 9000

This will open ssh access for you. Now use ssh to access your gateway. When you are finished issue following command to close the ssh access.

knock 192.168.1.2 6000 7000 8000