Saturday, February 25, 2012

Multi-Threaded Download in SHELL

If you are using LINUX and you if want to have faster downloads, this script may help you !

I've always wanted some tool such as FREE DOWNLOAD MANAGER on LINUX, especially via the SHELL.

So, I wrote this script which will download multiple chunks of the same file in parallel (because, at the server side, Apache web server supports content length). After it downloads the file chunks, it will "merge" them and you get back the original file :-)

So it works something like this:
Assume you want 4 different threads. Assume the file is 100 bytes and file name is (abc.tar.gz).
So, thread #1 will download chunk_1 (0 to 24 bytes)
thread #2 will download chunk_2 (25 to 49 bytes)
thread #3 will download chunk_3 (50 to 74 bytes)
thread #4 will download chunk_4 (75 to 100 bytes).

How to use the script:
# Usage:
#          ./this_file.sh -u  -t 
# Example: ./this_file.sh -u http://15.110.12.100/directory/files/boot.iso -t 8


Here is the script:

#!/bin/bash

####[ multi-threaded download in BASH shell using CURL command ]#####

# author: Giridhar Bhujanga ( giridhar.bhujanga@hotmail )
# Usage:
#          ./this_file.sh -u  -t 
# Example: ./this_file.sh -u http://15.110.12.100/directory/files/boot.iso -t 8

# Make sure  is a number between 4 and 24.

# Q: What will happen when we run the above command ?
# A: boot.iso in the above URL will get downloaded.
# Q: What is the advantage ?
# A: It will download '8' different chunks of the same file 
#    in parallel, and later on, it will merge all the chunks
#    to get back your original file.
#    This should definitely speed up your downloads
#    If things are still slow, try this before running this:
#      "unset http_proxy" (this depends on your network)
#       (you may or may not need to unset the proxy)
# I highly recommend you to run "md5sum "
# just to make sure integrity is maintained
############################################################

uflag=
tflag=
while getopts 'u:t:' OPTION
do
 case $OPTION in
  u) uflag="$OPTARG"
   ;;
  t) tflag="$OPTARG"
   ;;
  ?) printf "Usage: %s -u URL -t Total-Number-Of-Parallel-Threads args\n" $(basename $0) >&2
   exit 2
   ;;
 esac
done

if [ "$#" = "0" ]
then
 echo "----------------------------------------------------------------------------"
 echo "Please provide two arguments: -u  and -t "
 echo "----------------------------------------------------------------------------"
 echo " @ Example:"
 echo "   # parallel_download -u http://15.110.12.100/directory/files/DVD.iso -t 8"
 echo "----------------------------------------------------------------------------"
 echo " @ If you are downloading with in the company network, I'd highly"
 echo " @ recommend you do this before you start download:"
 echo "   \"unset http_proxy\""
 echo "----------------------------------------------------------------------------"
 echo " @ If you are downloading something outside the company network, you may"
 echo " @ want to do this before you start the download:"
 echo "   \"export http_proxy=http://web-proxy.atlanta.hp.com:8080\""
 echo "----------------------------------------------------------------------------"
 exit 0
fi

shift $(($OPTIND - 1))


# comment this out since we are parsing command line arguments
# url=$1
url=$uflag

unset http_proxy
unset ftp_proxy


new_path=$( echo "$url" | perl -MURI -le 'chomp($url = <>); print URI->new($url)->path' )
actual_file_name=`basename $(echo $new_path)`

len=`curl -I $url 2> /dev/null|grep "Content-Length:"|tr -d ' '|cut -d ':' -f2|tr -d "^M"`

STRING=$len

randomString=`od -An -N2 -i /dev/urandom|tr -d ' '`
newString="file_$randomString"

rm -rf $newString*

# comment this out since we are parsing command line arguments
# total_parallel_threads=$2
total_parallel_threads=$tflag

major_threads_number=$[$total_parallel_threads-1]
last_thread_number=1

echo "URL: $url"
echo "Number of Parallel Threads: $total_parallel_threads"

if [ "$total_parallel_threads" -le 3 ]
then
 echo "Please enter the number of threads greater than or equal to 4"
 exit 2
fi

if [ "$total_parallel_threads" -ge 25 ]
then
 echo "Please enter the number of threads less than or equal to 24"
 exit 2
fi


# first, strip underscores
CLEAN=${STRING//_/}
# next, replace spaces with underscores
CLEAN=${CLEAN// /_}
# now, clean out anything that's not alphanumeric or an underscore
CLEAN=${CLEAN//[^a-zA-Z0-9_]/}
# finally, lowercase with TR
CLEAN=`echo -n $CLEAN | tr A-Z a-z`

if [[ $CLEAN -le 0 ]]
then
 echo "The URL that you have provided: [$url] is Not valid. Please specifiy a valid URL !!"
 exit 0
fi

echo "content length = $CLEAN"
chunk_length=$[$CLEAN/$major_threads_number]
echo "chunk-size = $chunk_length"
major_length=$[$chunk_length*$major_threads_number]
echo "major length = $major_length"
remaining_length=$[$CLEAN-$major_length]
echo "remaining length = $remaining_length"
total=$[$remaining_length+$major_length]
echo "confirmation : $major_length (major) + $r (remaining)= $total"

start=0
end=0

for(( z=1; z<=$total_parallel_threads; z++ ))
do
 rm -rf $newString$z
done

time_start=`date +"%s"`

echo "Start Time = $time_start"

for(( i=0; ido
 i_plus_one=$[$i+1]
 file_name=$newString$i_plus_one
 start=$[$chunk_length*$i]
 end=$[$start+$chunk_length-1]
 curl --output $file_name --range $start-$end $url &
done

file_name=$newString$total_parallel_threads
start=$[$major_length]
end=$[$major_length+$remaining_length-1]
curl --output $file_name --range $start-$end $url &

wait

> $actual_file_name

for(( j=1; j<=total_parallel_threads; j++ ))
do
 cat $newString$j >> $actual_file_name
done

time_end=`date +"%s"`

echo "End Time = $time_end"
total_time_taken_secs=$[$time_end-$time_start]
total_time_taken_mins=`calc $total_time_taken_secs/60`
total_time_taken_hrs=`calc $total_time_taken_mins/60`
echo "------------------------------------------------------------------------"
echo "Time Taken to Download = [ $total_time_taken_secs secs ] or [ $total_time_taken_mins mins ] or [ $total_time_taken_hrs hrs ]"
echo "------------------------------------------------------------------------"

if [[ $total_time_taken_secs -le 0 ]]
then
 echo "Download got over very quickly ! Exiting..."
 cwd=`pwd`
 echo "Your downloaded file is: $cwd/$actual_file_name"

 rm -rfv $newString* 
 exit 0
fi

Bytes=$CLEAN
KBytes=`calc $CLEAN/1024`
transfer_rate_KB_per_sec=`calc $KBytes/$total_time_taken_secs`

MBytes=`calc $KBytes/1024`
transfer_rate_MB_per_sec=`calc $MBytes/$total_time_taken_secs`

echo "Average Transfer Rate = [ $transfer_rate_KB_per_sec KB/sec ] or [ $transfer_rate_MB_per_sec MB/sec ]"
echo "------------------------------------------------------------------------"

for(( z=1; z<=$total_parallel_threads; z++ ))
do
 rm -rf $newString$z
done

cwd=`pwd`
echo "Your downloaded file is: $cwd/$actual_file_name"

rm -rfv $newString*
exit 0

Friday, February 24, 2012

BASH Scripting Guide

BASH Beginners Guide

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html



Advanced BASH Guide

http://www.tldp.org/LDP/abs/html/index.html

NETBEANS for JAVA Programming

Sometimes, fonts in NETBEANS looks ugly !

Netbeans is no doubt a good tool for JAVA programming, but sometimes, I get frustrated by looking at the fonts.

By the way, some of my favorite "fixed width" fonts for Programming are:
> EnvyCode-R (just love this !)
> Consolas
> Liberation Mono
> Droid Sans Mono
> DejaVu Sans Mono


I either use NETBEANS locally on my Laptop (HP EliteBook 8440P: Which is a business Laptop) or I "remote desktop" to a LINUX box which is quite powerful (HP ProLiant DL-380-G6 Server with 16 CPU cores and 48 GB of RAM and 5 TB of space on /home : This is our Redhat Enterprise Linux build machine) and in this "remote desktop" session, I launch NETBEANS IDE.

It's not the same way you remote-desktop to Windows. Instead, I start "vncserver" (Google for VNC Client/Server) on the Linux box. Each "vncserver" instance allows me to do a remote desktop to the Linux box from Windows.

From my Laptop running Windows 7, I run the client. I use either "Tight VNC" or "Ultra VNC" Clients & then connect to the LINUX Box.

Now, coming back to the fonts, here is what you need to do to make the fonts look "better":

After installing NETBEANS (On Windows or Linux), you should be able to see this "netbeans.conf" file under "etc" directory.

Manually edit the "netbeans.conf" file, and _add_ the switches
-J-Dswing.aatext=true

and
-J-Dawt.useSystemAAFontSettings=on

to "netbeans_default_options"

That should do it ! Your Font should look better now !


For a even faster NETBEANS, play around with these settings

netbeans_default_options="-J-Xms256m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m
-J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled"



NETBEANS / JVM Performance Tuning
Visit this site: http://performance.netbeans.org/howto/jvmswitches/

Saturday, February 18, 2012

HP X9000 Network Attached Storage




X9000 Quick Specs


X9000 User Manuals

Useful Scripts

Script to remove spaces from filename and substitute with '_' character

Contents of '/bin/remove_space.sh'

#!/bin/bash
# To change the names of all files in a directory including directory names
# run the command
# This command is pretty useful if you have a collection of songs or 
# pictures transferred from your windows machine and you are finding 
# it difficult to handle the spaces in the filenames on UNIX
#
set -x
progname=`basename $0`
if [ $# != 1 ]
then
        echo "Usage: $progname \"file name with spaces\""
        echo
        echo "This utility is useful for renaming files with spaces in the filename."
        echo "Spaces in the filename are replaced with _"
        echo "\"file name with spaces\" will be renamed to \"file_name_with_spaces\""
        echo
        exit 1
fi

old_name=$1
dir=`dirname "$1"`
file=`basename "$1"`
new_file=`echo $file|sed "s/ /_/g"`
new_name=$dir"/"$new_file
if [ "$old_name" != "$new_name" ]
then
        mv "$old_name" "$new_name"
fi
exit 0

How to run ?

find . -depth -exec ~/remove_space.sh {} \;

Interesting Quotes

"The secret of getting ahead is getting started"


"Success belong to those who dare"


"Remember, happiness doesn’t depend upon who you are or what you have, it depends solely upon what you think"


"Only those who risk going too far can possibly find out how far one can go"


"The highest reward for man’s toil is not what he gets for it, but what he becomes by it"


"Work hard in the right path, Never giving Up..."

Thursday, February 16, 2012

Motivation













































LINUX Tips

Editing files remotely

Let us say you are on node-1 (IP=192.168.1.10) and you wish to edit a file on node-2 (IP=192.168.1.20), while you are logged in on node-1 without SSH'ing to node-2. Its pretty simple. All you need to do is open VIM, and let's say that you are editing a file (on node-1):

vim /root/install.log

Now, within the VIM session we can edit another file (assume that we need to edit /home/jack/hello.c directory from node-1):

:vsplit scp://root@192.168.1.20//home/jack/hello.c

The above command will do a "vertical split" within VIM and open the file "hello.c" that is existing on node-2. Yes, you may be prompted for password (unless you have password-less SSH setup across the two nodes).


Removing annoying "^M" characters in a file

There are quite a few ways of doing this, but a quick way to remove ^M scattered around your file is as follows in VIM:

:%s/C-vC-m//g

Where 'C-v' is 'Ctrl-v' and 'C-m' is 'Ctrl-m'.


Transfer a directory from LOCAL to REMOTE in a single command (using compression)

Let us say '/root/local-dir' exists on the local machine (from where you are executing the command) and '/root/remote-dir' exists on the remote node( with IP 19.2.168.1.100). To make a copy of '/root/local-dir' on '/root/remote-dir' on remote node:

tar -cvjf - *|ssh root@192.168.1.100 "(mkdir -p /root/remote-dir; tar -C /root/remote-dir -xvjf -)"

VIM Cheat Sheet

Click Here


CSCOPE/CTAGS

AS I deal with Java/C/C++ Code, I have a small script (put in /bin directory) which will automatically generate the CSCOPE DB. Assume that I'm in '/home/jack' directory and I have checked out my source tree in '/home/jack/project-1/src'. All the (*.cpp, *.java, *.c *.h etc) files are under 'src' driectory. So, I do a 'cd /home/jack/project-1/src' & then run the below script.
So here is the script ('/bin/do_cscope_ctags.sh'):

#!/bin/bash
echo "Generating CSCOPE.FILES for (*.java) / (*.cpp) / (*.c) / (*.h) / (*.js) files..."
find . -type f \( -iname "*.c" -o -iname "*.h" -o -iname "*.cpp" -o -iname "*.java" -o -iname "*.js" \) > cscope.files
echo "Runnning CTAGS..."
ctags -R
echo "Done !"
echo "Generating CSCOPE database..."
cscope -b -i cscope.files -f cscope.out
echo "---------------------------------------------------------------------"
echo " You can now run 'cscope' or 'cscope -C' (for case insensitive mode) "
echo "---------------------------------------------------------------------"



My ~/.vimrc file


imap ^? ^H
set t_Co=256
set cmdheight=2
syntax enable
syntax on
colorscheme inkpot
set autoindent
set smartindent
set ts=4
set shiftwidth=4
map :W :w
map :Q :q
set smartcase
set ignorecase
filetype plugin on
filetype indent on
set hlsearch
set noswapfile
set backupdir=~/.vim/backup
set laststatus=2
nnoremap :set invpaste paste?
set pastetoggle=
set showmode
set expandtab
set nu
nnoremap :TlistToggle
nnoremap :call g:Jsbeautify()
let Tlist_WinWidth = 50
filetype on
:map w
autocmd FileType java :setlocal sts=4 ts=4 shiftwidth=4
autocmd FileType c :setlocal sts=3 ts=3 shiftwidth=3
autocmd FileType cpp :setlocal sts=3 ts=3 shiftwidth=3
set tags=tags;/
set t_kb=^H
set bs=2
set cscopetag
let Tlist_Ctags_Cmd="/usr/bin/ctags"
fixdel
nnoremap . :tabn
nnoremap , :tabp
:map :e!



Passwordless SSH Setup across 2 Nodes


What is the end goal ?
Setup Passwordless SSH between node1 and node2

From node1, we should be able to execute a command on node2:
Example: ssh root@node2 “cp –r /root/files/*.jpg /tmp”

From node2, we should be able to execute a command on node1:
Example: ssh root@node1 “rm –rf /tmp/backup/*”

-------------------------------------
On Node1 = ibrvm-3-36-1 (hostname)
-------------------------------------

IP address = 10.3.36.1

Generate id_rsa.pub on both the nodes

[root@ibrvm-3-36-1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
4f:8f:b3:ca:52:fb:34:81:24:c8:be:a7:d7:d0:ef:ed root@ibrvm-3-36-1

Create authorized_keys file (if it does not exist) on both the nodes

[root@ibrvm-3-36-1 ~]# touch ~/.ssh/authorized_keys

Setup necessary permissions

[root@ibrvm-3-36-1 ~]# chmod 644 ~/.ssh/authorized_keys
[root@ibrvm-3-36-1 ~]# chmod 700 ~/.ssh

Copy node1’s ~/.ssh/id_rsa.pub to /tmp on node2
[root@ibrvm-3-36-1 ~]# scp ~/.ssh/id_rsa.pub root@10.3.36.2:/tmp

Append the contents of node2’s id_rsa.pub (which we’ve now copied to /tmp) to node1’s authorized_keys file
[root@ibrvm-3-36-1 ~]# cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

-------------------------------------
On Node2 = ibrvm-3-36-2 (hostname)
-------------------------------------

IP address = 10.3.36.2

Generate id_rsa.pub on both the nodes
[root@ibrvm-3-36-2 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
4f:72:13:b3:47:01:6d:40:a3:c4:3f:18:cf:72:28:6c root@ibrvm-3-36-2
Create authorized_keys file (if it does not exist) on both the nodes

[root@ibrvm-3-36-2 ~]# touch ~/.ssh/authorized_keys

Setup necessary permissions
[root@ibrvm-3-36-2 ~]# chmod 644 ~/.ssh/authorized_keys
[root@ibrvm-3-36-2 ~]# chmod 700 ~/.ssh

Copy node2’s ~/.ssh/id_rsa.pub to /tmp on node1
[root@ibrvm-3-36-2 ~]# scp ~/.ssh/id_rsa.pub root@10.3.36.1:/tmp

Append the contents of node1’s id_rsa.pub (which we’ve now copied to /tmp) to node2’s authorized_keys file
[root@ibrvm-3-36-2 ~]# cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys



Ethernet Link Speed

Q. How do I change the speed, duplex on for my Ethernet card?

A. Under Linux use mii-tool or ethtool package which allows a Linux sys admin to modify/change and view the negotiated speed of network interface card (NIC) i.e. it is useful for forcing specific Ethernet speed and duplex settings.
Depending on which type of Ethernet card is installed on the system you need to use either mii-tool or ethtool. I recommend installing both and use one of the tool, which will work with your card.

Task: Install mii-tool and ethtool tools

If you are using Debian Linux you can install both of these packages with following command:

# apt-get install ethtool net-tools


If you are using Red Hat Enterprise Linux you can install both of these packages with following command:


# up2date ethtool net-tools


If you are using Fedora Core Linux you can install both of these packages with following command:

# yum install ethtool net-tools

Task: Get speed and other information for eth0

Type following command as root user:

# ethtool eth0


Output:

Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes


Or use mii-tool command as follows:

# mii-tool eth0

Output:

eth0: negotiated 100baseTx-FD flow-control, link ok


Task: Change the speed and duplex settings

Setup eth0 negotiated speed with mii-tool
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD:

# mii-tool -F 100baseTx-HD
# mii-tool -F 10baseT-HD


Setup eth0 negotiated speed with ethtool

# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half


To make these settings permanent you need to create a shell script and call from /etc/rc.local (Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.
Read man page of mii-tool and ethtool for more information.


Some useful Linux Commands


What's using memory: You may find that your computer is running a bit slower. You can easily find out what's using up your memory:
# ps -aux | awk '{print $5,$6,$11}' | sort –n –k 1


Find files bigger than 1MB: This will find files in your home directory that are bigger than 1 megabyte
# find /tmp -size +1000k -print


To list all files on the system whose file name is `top', regardless of case, type:
# find / -iname top


To list all files on the system whose names begin with the characters `top', type:
# find / -name 'top*'


To list all files in the `/usr/local' directory tree that are greater than 10,000 kilobytes in size, type:
# find /usr/local -size +10000k


To list all files in your home directory tree less than 300 bytes in size, type:
# find ~ -size -300b


To find all empty files in your home directory tree, type:
# find ~ -empty


To list the files in the `/usr/local' directory tree that were modified within the past 24 hours, type:
# find /usr/local -mtime -1


To list the files in the `/usr' directory tree that were modified within the past five minutes, type:
# find /usr -mmin -5


To list all of the files in your home directory tree that were modified yesterday, type:
# find ~ -mtime 1 -daystart


Use the `-r' option with sort to reverse the listing and output the largest directories first.

To output a list of the subdirectories in the current directory tree, sorted in descending order by size, type:
# du -S . | sort -nr


To output a list of the subdirectories in the `/usr/local' directory tree, sorted in descending order by size, type:
# du -S /usr/local | sort -nr


To list the number of files in the `/usr/share' directory tree, type:
# find /usr/share \! -type d | wc –l


To list the number of files and directories in the `/usr/share' directory tree, type:
# find /usr/share | wc -l


To list the number of directories in the `/usr/share' directory tree, type:
# find /usr/share \! -type f | wc -l


Extended grep search *.dat files for "this" or "that" case insensitive (-i) and where found print line number (-n) along with the line contents.
# egrep -in "this|that" *.dat




Miscellaneous Commands


Resize all images in a folder and all of its subfolders

# find . -iname "*.jpg" | xargs -l -i convert -resize 1280x960 {} {}

Find out who is using how much of space in /home

# find /home -maxdepth 1 -type d -print|xargs -l -i du -B 1048576 -s {}|sort -n -k 1

Mounting Windows Shared Folder on LINUX

Assuming that you have shared "C:\MySharedFolder" as "MySharedFolder". This folder is owned by user "Jack" on Windows who has full permissions on the folder.

mount -t cifs //10.6.100.18/MySharedFolder /mnt/WindowsMount -o username=Jack,password=mypassword123,domain=localhost



Multi-threaded (Parallel) Downloads

LFTP - supports FTP, HTTP, and SFTP. Supports using multiple connections
to download a single file. Assuming you want to transfer a file from
remoteServer to localServer, install LFTP on localServer, and run:

lftp -e 'pget -n 4 sftp://userName@remoteServer.com/some/dir/file.ext'

The '-n 4' is how many connections to use in parallel.


SVN clean up

Strip ".svn" folders from a Subversion working copy

find . -name ".svn" -exec rm -rf {} \;



Force Un-mount

HowTo: Force umount a busy device in Linux
When you try to umount the regular way, if a device is busy you’ll get the following :

# umount /dev/sda1
umount2: Device or resource busy
umount: /boot: device is busy

This can be solver very easy by entering this:

# umount -l /dev/sda1



Create a new _Bootable_ DVD ISO file

Assume that you have loop-mounted your ISO and copied the contents to '/path/where-dvd-is/extracted'.

mkisofs -J -l -f -r -v -T -V "HPLinux" \
-o \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 8 \
-boot-info-table /path/where-dvd-is/extracted

Auto Logon & Lock Screen in Windows 7

At the start of the day in office at around 8.30AM, I do this every day:

1. Boot up Windows

2. Login (i.e enter Username & Password)

3. Launch Outlook

4. Launch SUN VIRTUAL BOX (boot up Ubuntu)

5. Netbeans/other tools that I may or may not need

6. Lock Screen, and then head straight to the cafe to get a cup of Coffee :D

So, I was very much in need to automating steps 1-6. Just power on my laptop and all the above steps should take care of itself.

After searching on Google, I came across quite a few sites which showed how this can be done.

Anyway, here is what you need to do to Automatically login with a specific user & Lock the screen (keeping in mind that you want to run a few apps right after login, and then lock the screen - launching the apps is asynchronous i.e screen gets locked, while the apps starts loading).

Create a shortcut on your desktop and point it to:

C:\Windows\System32\rundll32.exe user32.dll,LockWorkStation

Now place that shortcut/icon inside

Start > All Programs > Startup

That should take care of automatically locking the screen.
Now, what ever apps what you would like to launch after you log into the system (ex: Outlook or Office Communicator), place those apps inside the "Startup" folder.
Now to automatically logon with a specific user, goto >>
Start > Run

And type:
netplwiz

There you will see a list of users. Choose the user who would want to actually automatically logon and *Uncheck* "User must enter a user name and password to use this computer."

That should do it !

Ubuntu Performance Tweaks

To make your UBUNTU faster, here are some things which you could try:

1. User PRELOAD: Preload applications in memory - the next time you run the same app, it'll open faster:


# sudo apt-get install preload


2. Use ZRAM


# sudo add-apt-repository ppa:shnatsel/zram

# sudo apt-get update

# sudo apt-get install zramswap-enabler


3. Increase Swappiness

# sudo vim /etc/sysctl.conf

Edit:

"vm.swappiness=10"


4. Remove some unneccessary TTY’s

# sudo vim /etc/default/console-setup


Edit:

ACTIVE_CONSOLES="/dev/tty[1-3]"


5. Get rid of kinit if you don’t use hibernate and sleep functions

# sudo vim /etc/initramfs-tools/conf.d/resume

Edit:
Comment (Put # in front of) RESUME=XXX...

6. Use "apt-fast"

Apt-fast is a simple command line utility that can make installation and upgrading of softwares in Ubuntu/Debian much faster.

Apt-fast make use of Axel app which accelerates HTTP/FTP downloads by using multiple sources for one file. Author claims that, apt-fast could make your installations and upgrades up to 26x faster! Do the following in Terminal to install it.


# sudo add-apt-repository ppa:tldm217/tahutek.net

# sudo apt-get update

# sudo apt-get install apt-fast


Close and re-open terminal once again and try to use 'apt-fast' instead of 'apt-get'. You will

see the difference.