Remote Login to Linux from Windows (Non-VNC)

We can actually login to a *nix based system running X server remotely from Windows XP/Vista based machines. Although there are other ways to achieve remote login using Putty for a SSH login and file transfer over SSH using WinSCP. This particular method allows you to access the entire desktop as a independent session unlike VNC where actually you are viewing a already running X session.

Two things are required for this.

First, the *nix machine should be enabled with XDMCP protocol. Most distributions disable this with their default installation. This can be enabled if you have root or sudo access with simple steps. For eg:- for Gnome with Ubuntu, this can be achieved with System -> Administration -> Login Window. Go to the Remote tab and select Same as Local also go to the Security tab and uncheck Deny TCP connections to Xserver.
Reboot X and Thats it!

Second, In the Windows system download and install Xming. Its a free Xserver software for Windows. The installation is pretty simple. After installation launch Xlaunch from the menu.
Select One Window or Full Screen and provide the *nix host address.

If all goes well you should get the display manager running.. enter the username/password and you are tuxified!!!

Xming Login to Ubuntu Gutsy 7.10 from Win XP Pro

A Ubuntu session on network from WinXP

Update: For a VNC like remote login, use the following for gnome.

Install vino , in ubuntu or debian like distros, use sudo apt-get install vino.

Now run vino-server from /usr/lib/vino/vino-server this will enable the vnc server. To set preferences for accepting vnc sessions run vino-preferences and configure the same.

To connect from a *nix client use vncviewer hostip. From windows install vnc client from here.

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Download videos from youtube.com

Update:

On Ubuntu a better approach to download youtube videos from command line is using clive. It has options to download the best available format for the video using the -f option.

Also a to download videos directly from the youtube.com homepage a firefox extension provides a “Save As” option just below the playing video. Here again, we have option to download from HD to the lowest available resolution of the video. Get the extension from here. http://userscripts.org/scripts/show/25105

Old method below, keeping it around for the memories.!!

Recently I found a fantastic python script do download videos from youtube.com. http://www.arrakis.es/~rggi3/youtube-dl/

You just need to pass the url of the video like this
$youtube-dl -t http://youtube.com/watch?v=LNY7Lau0sJw

Below is a script which can download the videos based on your search results on youtube.com.
Suppose you make a search as Shilpa Shetty Big Brother 😛 and you get a results page, now save this page as say results.html

Now put the below give script into a file called as youtube_download.sh and run it from the directory u saved results.html

#script to download vids from www.youtube.com
#! /bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 filename.html |which has links from youtube.com search results"
echo "-Ajo Paul http://ajopaul.wordpress.com"
exit 1
fi
watchlink=""
for i in `cat $1 | grep "watch?" | cut -d '"' -f 2`
do
#watchlink="http://www.youtube.com"$i
if [ "$watchlink" != "$i" ]; then
echo "*********Now Downloading $i **********"
# youtube-dl -t $i 2>&1;
watchlink=$i
fi
done
echo "Done!"
echo "-Ajo Paul http://ajopaul.wordpress.com"

You can also put this script as a cronjob, but before that you must download youtube-dl and put in anywhere in your $PATH.

Setting up a SVN 1.4 server using Apache 2.2 on Ubuntu

To setup svn 1.4 , we need to compile both apache 2.2 and svn 1.4 from source.
This how to has been tested under Ubuntu Dapper and Edgy.

sudo apt-get install build-essential libneon25-dev autoconf libtool -y --force-yes

Before starting make sure you have removed previous apache2 and subversion installation from your system.
To do this:
sudo apt-get --purge remove apache2 subversion
sudo mv /etc/init.d/apache2 $HOME/apache2_bak

cd $HOME
mkdir softwares
cd softwares

wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvfz zlib-1.2.3.tar.gz
cd zlib-1.2.3/
./configure --prefix=/usr/local
make
sudo make install

cd ..
wget http://apache.forbigweb.com/httpd/httpd-2.2.3.tar.gz
tar xvfz httpd-2.2.3.tar.gz
cd httpd-2.2.3/
./buildconf

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-dav --enable-so --enable-maintainer-mode

make
sudo make install

sudo /usr/local/apache2/bin/apachectl start
Now test your apache2! goto browser and type http://localhost, you should see it works!!

sudo /usr/local/apache2/bin/apachectl stop


sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
sudo chmod +x /etc/init.d/apachectl

We just need to add a few lines to the file for it to work nicely:

sudo vi /etc/init.d/apachectl

Add the followinig, so the top of the file looks like:

#!/bin/sh
#
# chkconfig: - 85 15
# description: Apache is a web server.

Save the file.

sudo /usr/sbin/update-rc.d apachectl defaults

Securing Apache

It?s also a good idea to create a dedicate Apache system user account. It?ll make your install much more secure.

sudo adduser --system apache

Now we just need to make sure that Apache runs under this user. We do that by editting the configuration file:

sudo vi /usr/local/apache2/conf/httpd.conf

You need to find the lines that say:

User daemon
Group daemon

And change them so they look like:

User apache
Group nogroup

sudo /usr/local/apache2/bin/apachectl start

Installing Subversion 1.4

As we have built Apache from source, we’ll need to do the same for Subversion in order to get the Apache 2 modules mod_dav_svn and mod_authz_svn.

# rm -f /usr/local/lib/libsvn*
# rm -f /usr/local/lib/libapr*
# rm -f /usr/local/lib/libexpat*
# rm -f /usr/local/lib/libneon*

#Get the latest svn tar ball
wget http://subversion.tigris.org/downloads/subversion-1.4.2.tar.gz
tar xvfz subversion-1.4.2.tar.gz
cd subversion-1.4.2/

sh autogen.sh

./configure --prefix=/usr/local --with-apxs=/usr/local/apache2/bin/apxs --with-httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr

make
sudo make install

This will also add the relevant LoadModule directives into your Apache 2 configuration for you.
Creating your repository

Now, create your Subversion repository:

svnadmin create /home/yourusername/subversion/repos

We have to make that repository owned by Apache so that it can be accessed via the web:

sudo chown -R apache /home/yourusername/subversion/repos

Authentication File

Now create a user/password file for authentication:

/usr/local/apache2/bin/htpasswd -cm /home/yourusername/subversion/dav_svn.passwd yourusername

When prompted, enter your password.
Configuring Apache

Edit your /usr/local/apache2/conf/httpd.conf file with the following placed at the end:


<Location /svn>
DAV svn
SVNPath /home/yourusername/subversion/repos
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /home/yourusername/subversion/dav_svn.passwd
Require valid-user
</Location>

If you want access control based on different users, add the following line after the Require valid-user line:

AuthzSVNAccessFile /home/yourusername/subversion/svn_access_control

To setup a local mirror using svnsync

To have a mirror setup first ensure that the local repo you are going to use as the mirror should have the same uuid as that of the master.

To get uuid of a repo, go to its working copy and type
svn info

now make the mirror svn’s uuid same as masters uuid, you can get the uuid by typing
svn info URL/PATH

cat – <<EOF | sudo svnadmin load –force-uuid dest
SVN-fs-dump-format-version: 2

UUID: d48dd586-eb1d-0410-b581-e6e13afcedeb
EOF

cd /home/ajopaul/subversion/repos/hooks/
vi pre-revprop-change
sudo vi pre-revprop-change

Add the following lines
#!/bin/sh
USER="3"
if [ "USER" = "svnsync" ]; then exit 0; fi
echo "Only svnsync user can change revprops" >&2
exit 1

sudo chmod +x pre-revprop-change

sudo svnsync init --username your_master_svn_username file:///home/ajopaul/subversion/repos http://xxx.xxx.xxx.xxx/svn

sudo svn proplist --revprop -r 0 http://xxx.xxx.xxx.xxx/svn

sudo svn propget file:///home/yourusername/subversion/repos --revprop -r 0 http://xxx.xxx.xxx.xxx/svn

time sudo svnsync sync file:///home/yourusername/subversion/repos

Remember! local mirrors is/should be read only

To ensure no commits happen on the local mirror add the following lines to hooks/pre-commit script

#!/bin/sh
SVNLOOK=/usr/local/bin/svnlook
USER=`SVNLOOK author -t $3 $1`
if [ "$USER" = "svnsync" ]; then
exit 0;
fi
echo "Sorry no commit allowed on mirror! use 'svn switch' to point to master repo and then point back to local mirror after the commit" >&2
exit 1

If by any chance your svnsync locks ur mirror repo or if you recieve a message such as:
Failed to get lock on destination repos, currently held by ….
Type this
svn propdel svn:sync-lock --revprop -r 0 file:///home/ajopaul/subversion/repos/

References:
Source
svnsync.txt

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Assorted Linux/Ubuntu Gotchas!!

To customise Vi Editor
copy /usr/share/vim/vimrc to ~/.vimrc
:syntax on for color highlighting
:set incsearch for incremental search in vi editor

to clear and redraw the screen ^L

To get network info
netstat -lneap | grep tcp
5900 for vnc
21 for ftp

To mount Windows partitions (NTFS) on boot-up, and allow users read and write access

sudo apt-get install ntfs-3g

sudo vi /etc/fstab and add the following

/dev/hda5 /media/windows ntfs-3g defaults,locale=en_US.utf8 0 0

To mount network folder
//192.168.151.97/freeware /media/freesoft smbfs credentials=/root/.smbcredentials 0 0

To list all ips in a network
nmap -v -sP 192.168.185.1/24 | grep "appears to be up" | cut -d ' ' -f 2

Install FLash editor for linux
wget http://www.sonsuzdongu.com/paketler/f4lm_0.1-1_i386.deb

sudo dpkg -i f4lm_0.1-1_i386.deb

Postgresql
If you want to allow other(s) network system to access your
database, you need to make changes in two files : postgresql.conf and
pg_hba.conf.

in postgresql.conf file you need to specify IP address(es) to listen on,
with comma seperated. OR ‘*’ for ALL.

listen_addresses = ‘*’
And in pg_hba.conf you need to add the following line at end :
host all all 192.168.185.1/8 trust


Java 5 doc

wget http://javadocs.planetmirror.com/dist/jdk150-hh.zip

#To convert a wav to a mp3 file
sudo apt-get install lame
lame -h -v -b 128 music.wav music.mp3

#To convert all .wav files in a directory
#converts music.wav to music.wav.mp3
ls *.wav | xargs -i lame -h '{}' '{}'.mp3
or to find all files from current dir and subdirs
find . -iname "*.wav" | xargs -i lame -h '{}' '{}'.mp3

#to move files to a new directory
ls |xargs mv --target-directory=../somedir