What To Do: Users Still Wants Telnet

Posted on in Categories CentOS, fedora linux, GNU/Open source, High performance computing, Howto, Linux, package management, RedHat/Fedora Linux, Security, Ubuntu Linux, UNIX last updated August 26, 2008

TELNET (TELecommunication NETwork) is a network protocol used on the Internet or local area network (LAN) connections. It was developed in late 60s with RFC 15. Telnet is pretty old for login into remote system and it has serious security problem. Most admins will recommend using Open SSH (secure shell) for all remote activities. But you may find users who are still demanding telnet over ssh as they are comfortable with Telnet. Some users got scripts written in 90s and they don’t want to change it. So what do you do when users demands telnet?

BASH shell scripting tip: Set default values for variable

Posted on in Categories Howto, Linux, Shell scripting, Tips, UNIX last updated May 23, 2007

A shell variable may be assigned to by a statement using following syntax:
var=value

If value is not given, the variable is assigned the null string. In shell program it is quite useful to provide default value for variables. For example consider rsync.sh script:
#!/bin/bash
RSRC=$1
LOCAL=$2
rsync -avz -e ‘ssh ‘ [email protected]:$RSRC $LOCAL

This script can be run as follows:
$ ./rsync.sh /var/www .
$ ./rsync.sh /home/vivek /home/vivek

It will sync remote /home/vivek directory with local /home/vivek directory. But if you need to supply default values for a variable you can write as follows:

#!/bin/bash
RSRC=$1
LOCAL=$2
: ${RSRC:="/var/www"}
: ${LOCAL:="/disk2/backup/remote/hot"}
rsync -avz -e 'ssh ' [email protected]:$RSRC $LOCAL

: ${RSRC:=”/var/www”} ==> this means if the variable RSRC is not already set, set the variable to /var/www. You can also write same statement with following code:

if [ -z "$RSRC" ]
then
   RSRC="/var/www"
fi

You can also execute a command and set the value to returned value (output). For example if the variable NOW is not already set, execute command date and set the variable to the todays date using date +”%m-%d-%Y”:

#!/bin/bash
NOW=$1
....
.....
: ${NOW:=$(date +"%m-%d-%Y")}
....
..

HowTo: Tunneling VNC Connections Over SSH

Posted on in Categories FAQ, Howto, Linux last updated May 8, 2006

Virtual Network Computing (VNC) is a desktop sharing system which uses the RFB (Remote FrameBuffer) protocol to remotely control another computer. It transmits the keyboard presses and mouse clicks from one computer to another relaying the screen updates back in the other direction, over a network.

Moving /home Data From Old System To a New Linux System

Posted on in Categories Howto, Linux last updated May 1, 2006

Recently a friend of mine, brought a new Laptop. He installed Red Hat Enterrpise Linux workstation 4.0. However, after installation he realized that he lost all his Mozilla thunderbird emails and Firefox bookmarks, chat client logs and other files.

I told him just copy all old files from /home/$you to a new system /home/$you directory. He was trying some age-old tutorial from net, which explains how to copy files using tar and restore it back to new system. During this procedure, he was messing up with file system permission.

nohup Execute Commands After You Exit From a Shell Prompt

Posted on in Categories CentOS, Debian Linux, FreeBSD, Gentoo Linux, GNU/Open source, Howto, Linux, Linux desktop, Networking, RedHat/Fedora Linux, Shell scripting, Solaris, Suse Linux, Tips, Tuning, UNIX last updated January 4, 2006

Most of the time you login into remote server via ssh. If you start a shell script or command and you exit (abort remote connection), the process / command will get killed. Sometime job or command takes a long time. If you are not sure when the job will finish, then it is better to leave job running in background. But, if you log out of the system, the job will be stopped and terminated by your shell. What do you do to keep job running in the background when process gets SIGHUP?