Automatically set the DISPLAY environment variable in SSH connection

14. January 2012 10:32

 

This is a quick tip if you use an xserver that is running remotly and you want to set the DISPLAY enviroment variable when you login to the machine using ssh. It is actually very simple to do.

 

When you use ssh it will automatically set the SSH_CLIENT enviroment variable to contain the client connection details eg the ip address port number etc.. to get this to work you will need to paste the following into your .bashrc file.

 

 

if [ ! $DISPLAY ] ; then
	if [ "$SSH_CLIENT" ] ; then
		export DISPLAY=`echo $SSH_CLIENT|cut -f1 -d\ `:0.0
	fi
fi

 

 

the above will check that the DISPLAY enviroment variable is not currently set and that the SSH_CLIENT variable is set. It will then extract the ip address from SSH_CLIENT

E-mail Kick it! DZone it! del.icio.us Permalink


Removing the kernel to save space

11. January 2012 11:46

I heard this from a fellow sysadmin friend.  My friend was forced to work with some sysadmins who didn't have their act together.  One day, one of them was "cleaning" the filesytem and saw a file called "vmunix" in /. "Hmm, this is taking up a lot of space - let's delete it".  "rm /vmunix".

 

My friend had to reinstall the entire OS on that machine after his coworker did this "cleanup".  Ahh, the hazards of working with sysadmins who really shouldn't be sysadmins in the first place. When this happened to a colleague (when I worked somewhere else) he restored vmunix by copying from another machine.

 

Unfortunately, a 68000 kernel does not run very well on a Sparc...

E-mail Kick it! DZone it! del.icio.us Permalink


Adding emergency swap space to linux

6. January 2012 06:00

 

This is a quick guide to adding emergancy swap space to linux. Which is useful when you know a machine is going to run out memory. Or you need a lot of memory for a single task that cannot be completed without the extra memory.

 

Step 1

 

Login as root

 

Step 2

 

Create a new file of the size that you want to add using the following command. In this case 512 mbytes of space.

 

dd if=/dev/zero of=/extraswap1 bs=1024 count=512k

 

Step 3

 

Fix the permissions on the file so that only the creator can read / write to it.

 

chmod 0600 /extraswap1

 

Step 4

 

Turn it into a swap file and tell linux to turn on the extra space

 

mkswap /extraswap1

swapon /extraswap1

 

Step 5

 

If you want the swap to be enabled after the next reboot of the machine you will need to add the following line to /etc/fstab

 

/extraswap1 swap swap defaults 0 0

 

Finally

 

You can verify that it is working by either using free or by looking directly at the proc filesystem using cat /proc/swaps

E-mail Kick it! DZone it! del.icio.us Permalink


More Updates

5. January 2012 21:50

 

I have just added / updated some more software to the site.

 

 

E-mail Kick it! DZone it! del.icio.us Permalink


Getting sudo to work without a password

4. January 2012 21:26

 

I started working with linux for development work again after a break for a few years. I have ended up working on a project that requires a lot of mixed access from the normal user account to root or to other accounts. The simple way todo this without having to type a password a million times a day is to use sudo.

This is a quick guide to how I went about configuring it in such a way they you can also have support for multiple users on the same machine that may require root. You will need to be root of course for this to work.

 

First of all add a new group.

 

root@linux:~# addgroup sudoers
Adding group `sudoers' (GID 1001) ...
Done.

 

 

Then add your self to the group and repeat for each of the other users you need to have access.

 

 

root@linux:~# adduser james sudoers
Adding user `james' to group `sudoers' ...
Adding user james to group sudoers
Done.

 

Then make sure the following line exist in the /etc/sudoers config file.

 

 

%sudoers ALL=NOPASSWD: ALL

 

 

Then to test it you will need to logout and in again to allow the group change to be visible and then run something like "sudo bash" to get a root shell. Now you don't need to type a password a million times a day.

 

I should probably point out that there are security considerations on this and bear in mind that I use it on a development box which only has extremly limited access.

E-mail Kick it! DZone it! del.icio.us Permalink