Wednesday, December 24, 2008

The best putty package available

Bored of Black screened Task bar filling putty? Issues with porting Saved sessions from machine to machine? Do you like tabbed SSH sessions?

Start using portaputty instead of normal putty and link it with puttycm.

Puttycm supports sessions to be saved in its own Database files. You can use the Putty sessions you have saved already right inside putty.
You can have any number of databases which allow you to arrange Remote servers in folders and convenient namings.

I personally recommend creating Database with puttycm rather than using the sessions saved in putty which doesn't offer any option to create folders and saving sessions under that directory tree.
You can even save username/password to get it logged automatically and there is an option to pass commands to be run soon after login. I can't recommend this since some bug was found with these options.

Portaputty is a variant of putty which stores all the Configuration data in text files instead of MS Windows Registry entries thereby making customization and portability much easier than ever. For example you can set the default colour behaviour to set "Use system colours" just by editing the entry UseSystemColours=1 in .putty\sessions under the directory from where you are running portaputty.

puttycm is the Putty Connection Manager that gives a user interface where we can open multiple putty sessions in tabs and store sessions in a hierarchical directory tree structure. The saved sessions are being stored in DB files and the same can be exported to XML and can be transferred.
Both puttycm and portaputty are standalone executable. No more setup is required. Only thing is mention the full path to putty(here portaputty in our case) at first run of puttycm. Download portaputty here and puttycm can be downloaded from here

A typical Putty screen will appear as below with these PuttyCM and PortaPutty

Wednesday, December 10, 2008

screen for Remote assistance and chat

screen is a UNIX utility for giving remote assistance/administration. Suppose an unskilled colleague of your own is struggling with a server at some remote location with no idea of troubleshooting a problem.
If you are able to solve that with keeping your colleague to watch how you are sorting out the issues you can use screen.

First of all ask your colleague for the username which he used to login into that remote machine. Now you can login to that remote machine as the same user. Imagine username is engineer and IP of the remote machine is 192.168.1.1. Try the below
# ssh engineer@192.168.1.1
Then after getting logged in run the screen command to set a session named myscreen
$ screen -S myscreen
Now tell your colleague to type the below for attaching his screen to your screen.
$ screen -x myscreen
Thats it. Now he can watch whatever you type and vice versa.

Monday, December 8, 2008

Run X11 programs after SSH and switch to another user

This issue arises when you are logging in as root and trying to launch some X11 programs after doing a switch to user oracle.
One solution is to login directly as the user as which you want to run thos X11 programs.
One more workaround is there.Here you can login as a different user. Thereafter run the below command
xauth list | grep "`hostname`/"| grep `echo $DISPLAY | cut -f2 -d: | cut -f1 -d.`

Copy the output. Then switch to second user and run xauth add as this output as an argument as below
xauth add training/unix:13 MIT-MAGIC-COOKIE-1 57f03bee06be924299b0bedde6499bd1

Now run any X11 programs.

Tuesday, November 25, 2008

BASH script to delete older files

# BASH Script to find files having Modification time older than 7 days and to remove.
# A provisional confirmation before deletiion has been included
# System files starting with "." in their names are excluded from deletion
# And exclusive files that are specifies in the exclusion list are prevented from being deleted

#!/bin/bash
DIR=/home/hari
LIST=/home/hari/DELETE_LIST
EXCLUSIONS=/home/hari/EXCLUSIONS

# Simply the below command will do it
# find $DIR -type f -mtime +7 | grep ^./ | grep -v -f $EXCLUSIONS -exec rm {} \;
# But for the time being it run on a CONFIRMATION before deleting the files.

#Declaration for CONFIRM()
CONFIRM()
{
echo "Going to remove $1"
echo "Do you want to Continue? -y/n"
read CHOICE
if [ $CHOICE = 'y' ]
then
rm -f $1
elif [ $CHOICE = 'n' ]
then
exit
else
echo Invalid choice
exit
fi
}
# Function FIND_FILES
FIND_FILES()
{
cd $DIR
find -type f -mtime +7 | grep ^./ | grep -v -f $EXCLUSIONS > $LIST
for i in `cat $LIST`
do
CONFIRM $ENTRY
done
}


# Call to main function FIND_FILES()
FIND_FILES
exit

Saturday, November 22, 2008

Install Linux from a remote machine

This comes into picture when one Admin doesn't have physical access to a system in which Linux needs to be installed. Here we need help from one person who is having physical access to that remote machine to get it booted from bootable media and to type the command shown below command at boot prompt.


Now anaconda will start to run and will pause at a particular moment showing the below message


Now try to telnet to this IP from a remote machine and proceed with installation steps as usual as we do as shown below

Monday, September 22, 2008

How to disable a specific command(s) for a certain user.

Please follow the below steps to disable a specific command(s) for a certain user.

# su - hari
$ which rm (Here rm command as an example)
$ mkdir ~/bin
$ ln -s /bin/* ~/bin/ (/bin is the PATH for rm)
$ rm -rf ~/bin/rm

Take the output of $PATH for this user

$ echo $PATH > MyPATH.txt
Edit this file and replace /bin with ~/bin

Login as root

$ su -
# cat /home/hari/MyPATH.txt >> /home/hari/.bashrc

Change the permission of /home/hari/.bashrc
# chmod 444 /home/hari/.bashrc
# chattr +i /home/hari/.bashrc


That's all.
But the user can reset the PATH variable anytime to overcome this.
Please comment with alternatives for this.

Monday, July 28, 2008

Disable Media Check for cdrom

Grub.conf
dma=off apci=off apm=off

/etc/hdparm.conf
command_line {
hdparm -d1 /dev/cdrom
}

command_line {
hdparm -d1 /dev/cdrom1
}

sysctl.conf
dev.cdrom.check_media = 0

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...