Sunday, August 17, 2008
Ubuntu@Laptop: turning off internal speakers on connecting headphones
Open System->Preferences->Volume Control
There should be a tab named "Switches".
(If its not present, Goto Edit->Preferences and check "Headphone jack sense")
Goto the "Switches" Tab, and check the box in front of "Headphone Jack sense".
Thats it!!
If by default the options mentioned here are not there, then look for answers in the ubuntu forums.
Wednesday, August 13, 2008
Ubuntu@Laptop: Wireless Button LED does not work
I installed ubuntu 8.04 on it, and since there's a rule that not everything should be working - my wireless button was dysfunctional!
Doing a 'sudo lshw -C network' after pressing the wireless button showed that the button is actually toggling the radio, its just not making the LED glow.
i.e. after pressing it once, the command output will have the string -
wireless=radio off
and after pressing it again, it will contain -
wireless=unassociated
Solution -
Find the driver module for the wireless card, in my case it was ipw2200.
Remove the module:
sudo modprobe -r ipw2200
And insert it again with the led option:
sudo modprobe ipw2200 led=1
This makes the LED blink when the radio is turned on.
Note: This setting is lost on reboot, so add these two commands in /etc/rc.local
Display acronyms de-mystified
- VGA - 640 X 480
- SVGA - 800 X 600
- XGA - 1024 X 768
- QVGA - 1280 X 960
- SXGA+ - 1400 X 1050
- UXGA - 1600 X 1200
- QXGA - 2048 X 1536
- QSXGA+ - 2800 X 2100
- QUXGA - 3200 X 2400
- HUXGA - 6400 X 4800
- WXGA - 1280 X 800
- WXGA+ - 1440 X 900
- SXGA - 1280 X 1024
- WSXGA+ - 1680 X 1050
- WUXGA - 1920 X 1200
- QSXGA - 2560 X 2048
- HSXGA - 5120 X 4096
Saturday, May 17, 2008
ssh2 library for php
Extensions installed: snmp, curl, mysql, mysqli, pdo, pdo-mysql
On Ubuntu 7.10, apt-get of any of these php extensions does the following:
1. Copies the name.so (e.g. snmp.so) file in /usr/lib/php5/20060613/ directory.
(No idea why is the directory name a date, instead of 'ext' as mentioned in several forums. Anyways, in /usr/bin/php-config5, you can find the line:
entension_dir=/usr/lib/php5/20060613/)
2. In /etc/php5/conf.d, creates a file name.ini (e.g. snmp.ini), with a single line: extension=snmp.so
The php ssh2 library was not found using apt-get. The following steps were followed in install it. (assuming that openssl, pear, pecl are already installed)
(prerequisite: install the libssh2 library)
1. wget http://surfnet.dl.sourceforge.net/
sourceforge/libssh2/libssh2-0.14.tar.gz
2. tar -zxvf libssh2-0.14.tar.gz
3. cd libssh2-0.14/
4. ./configure
5. sudo make all install
(now, php ssh2)
6. sudo pecl install -f ssh2 - this created ssh2.so in /usr/lib/php5/20060613/
7. created a file /etc/php5/conf.d/ssh2.ini with a line: extension=ssh2.so
Most of the instructions were followed from this page. PHP's own documentation page for ssh2 couldn't help much, but the rest of the documentation can be found there.
Thursday, May 15, 2008
Sudo access for apache user
Web-based admin interfaces, like a network management web console, often require to execute certain commands with elevated previleges. Adding an entry in the sudoers file is one straight forward way to do this.
The apache user on debian is 'www-data' and on fedora it is 'apache'. Let apache_user denote the web server user, irrespective of the distro.
In /etc/sudoers, we need to add:
%apache_user ALL=NOPASSWD: ALL
This seems very naive from security perspective.Apache has a feature suEXEC for such purposes. But -
- It does not support if the target user is root (work around – let the target user be userx, such that userx is configured to have admin previleges)
- It requries re-compiling the apache server, and a very careful and complex configuration. Not really suitable for people who use off-the-shelf apache, with default configurations, like me :)
We can modify the line in 'sudoers' file to enhance security a little bit. Instead of sudo access to all commands, we can restrict the sudo access for very few number of commands.
%apache_user ALL=NOPASSWD: /bin/ls, /bin/cat
In my project – php based wireless-mesh network management suite – I've used this :-
%apache_user ALL=NOPASSWD: /usr/bin/php -f /path/to/my/script/daemon.php *
where, daemon.php handles all the tasks requiring admin previleges. The '*' at the end of the line is used to pass command line arguments to the daemon. This type of usage of the sudoers file gives enough security for most practical purposes. After all, I'm not managing a bank here!
Links: Useful thread on apache forum
Tuesday, May 13, 2008
Uploading files to blogs
For other files, you need to use an online storage service which allows access through blogs.
In the previous post, I've used the service of Box.net.
Create an account, upload files. Go to the services tab, and add export to blogs service. Currently it supports WordPress, Blogger and LiveJournal. Then right click on the uploaded file, you'll find an option to export the file to these sites.
In case of Blogger, just enter your blogger username and password, and the name of the post. In case you have multiple blogs, it itself decides which blog to post to.
Note: Even if there exists a post with the name you entered there, Box.net will create a new post with the name provided. So you should start by uploading and exporting files for your post, and edit that post to add your contents.
MRTG RRD Log Querying Tool
There are a lot of free MRTG front-end tools available on the web, but most of them are for the traditional MRTG logs and not for the rrd (round-robin database) log format. Though not as straight forward as sql, some complex queries can nevertheless be issued on the rrd log files using rrdtool.
This tool is a php-based rrd log querying tool developed as a part of my M.Tech thesis.
Requirements
- A functional web server, preferably apache
- MRTG and RRDTOOL should be installed on the system.
- In the mrtg configuration file, add LogFormat: rrdtool
- Enable passwordless sudo access for apache user (DEBIAN:www-data or REDHAT:apache) if you wish to add interfaces to the mrtg config through the web interface. (Read this post for the right way to do this step)
Installation
- In the queryMrtg.php:
- Set $mrtgdir to the location where mrtg is configured to store its rrd logs, e.g. /var/www/mrtg
- Set $mrtgcfg to the absolute path of the mrtg configuration file, e.g. /etc/mrtg.cfg
- Set $rrdcommand to the rrdtool binary, e.g. /usr/bin/rrdtool
- Set $cfgmaker to the cfgmaker binary, e.g. /usr/bin/cfgmaker
- Set $imgdir to the directory where images will be stored. Create this as a sub-directory of the exported directory in apache (e.g. /var/www/html/images). Add the path relative to the exported directory i.e. if /var/www/html is exported in httpd.conf, then simply write 'images'.
- In the $interfaces array, add all the interfaces that you wish to monitor and query.
- Copy queryMrtg.php to the web-exported directory. e.g. /var/www/html/queryMrtg.php
Usage
- On your browser, type - http://localhost/queryMrtg.php
- First time usage - Just click 'Submit'. It would report that MRTG configuration has not been added for the specified interface, and will show a button to add it. Just click!
- Once you have added interfaces to MRTG configuration, just play around with queries.
mailto: venkatesh@iitg.ernet.in OR rvenkatesh25@users.sourceforge.net
Screen Shots
Download
Downloading mp3 from Internet - the google way
intitle:"index of" (mp3|mp4|wav) name.of.file -html -htm -asp -jsp -cf -php
Explanation: you are searching for directory listings only. All web pages (html, php etc) are filtered out. Apache's directory listings have "Index of" in the title.
vimrc
" Set syntax onAcknowledgments to my friend and mentor Shriram V. This vimrc is the set of those lines which I understood from his highly sophisticated version :)
syntax on
" Indent automatically depending on filetype
filetype indent on
set autoindent
" Case insensitive search
set ic
" Higlhight search
set hls
" Incremental search
set incsearch
" Wrap text instead of being on one line
set lbr
" Change colorscheme from default to delek
colorscheme delek
" statusline shown in blue
highlight StatusLine ctermfg=darkblue ctermbg=white
" Show ruler
set ruler
" Set the shell to use
set shell=bash
" Show brace matching as you edit
set showmatch
" Show working mode
set showmode
" Show the command
set showcmd
" Display a status bar
set laststatus=2
" Number of screen lines to use for the command-line
set cmdheight=1
" Shift width when you press <<>> to indent a line.
set shiftwidth=3
" Set Shift rounding off
set shiftround
" Patten matching
set magic
" Switch buffer to edit a new file, and use open file if it already open
set switchbuf=useopen,split
" Changes how backspace works.
set bs=2
" Expand Tab
set expandtab
" Number of spaces for a tab
set tabstop=8
" lines longer than the width of the window will not wrap
set wrap
" Searches does not wrap around the end of the file
set nowrapscan
"Not always equal
set noequalalways
"F2 to Save file
map:w
map B :w
map!:w a
map! B:w a
"F6 to switch window
mapw
"Ctrl-Shift-F6 to show only curent file for editing in many windows
map:only!
"- to decrease the current window height
map --
"= to increase the current window height
map =+
"_ to decrease the current window width
map _<
"+ to increase the current window width
map +>
"Alt-Up to go to upper window
mapk
"Alt-Down to go to the lower window
mapj
"Alt-Left to go to the left window
maph
"Alt-Down to go to the right window
mapl

