Tuesday 21 December 2010

Visudo editing

Visudo is a command that opens /etc/sudoers file for editing. Editing sudoers file is essensial if for some reason user needs to be able to execute superuser commands via sudo command. Simple example line to put in /etc/sudoers file might be:

user ALL=(ALL) ALL


Here, user is the username of the user that is being assigned the privilege. For this to apply to a group of users on the machine you would prefix the name with a % (%user). First ALL entry represents the hosts that these permissions apply to. ALL option is always safe to use if the system is local. Second ALL entry in brackets defines what user the first user is applying the command as. In this example ALL option means that user can execute commands as any other user on system. Last ALL entry is a comma separated list of commands that the user will have access to. ALL means that user can execute any command that is privileged to user listed in second entry. Overall, this line is saying user can execute any command as any user on every host on the system simply by providing its password.

Personally, I use the above line on my system, simply because i'm the only user on it and it saves me time, but it isn't really safe on multiuser systems. Another example can be:

user ALL=(root) /usr/bin/apt-get, /sbin/halt


Here, the user can only use apt-get and halt commands as root user using sudo.

Saturday 7 August 2010

Using 'checkinstall' tool with python source packages

Most python modules can be installed using a package management program. Important thing is, this modules can easily be uninstalled the same way. But if a module is only available as gzipped tar file (.tar.gz) source, installation is done using:

$ sudo python setup.py install


But there is no uninstall option and the manual removal of the files seems the only way.
Today I stumbled on the checkinstall tool. Here's what the manual say:

checkinstall is a program that monitors an installation procedure (such as make install, install.sh), and creates a standard package for your distribution (currently deb, rpm and tgz packages are supported) that you can install through your distribution's package management system (dpkg, rpm or installpkg).

Good thing it can also be used on python source packages, and it's really easy:

$ sudo checkinstall python setup.py install


This will prompt user for some answers and best thing is to use the default ones (in other words, just press enter). After this checkinstall will create a standard package file, and install it, in my case a .deb package. The module can now be uninstalled easily with a package management program.

Thursday 5 August 2010

Debian: Setting Up JAVA - 'update-alternatives'

Got back to using Linux for a while now and I came up with some new stuff to put here. So this will be some kinda comeback to blogging since 2008.
This post will be adition to my last one about using update-alternatives command to setup which java VM your Debian system should use. Using this method is sometimes good enough, but for manual installation of java it won't work.
Let's say the java VM is unpacked as:

/opt/jdk1.5.0_09/


To succesfully use this version as default one the java command needs to be installed as a alternative first:

sudo update-alternatives --install /usr/bin/java java /opt/jdk1.5.0_09/bin/java 500


The last argument in the command is priority and it is mandatory. Priority is used when automatic mode for the link group is set. Any random number will do, for example '500'. Personally I don't know much about this so I won't go any further.

Last thing to do is executing one of this commands to use freshly installed java as default:

sudo update-alternatives --set java /opt/jdk1.5.0_09/bin/java
sudo update-alternatives --config java


That's all from me. Hope it helped someone.