Adding a Startup Script in Ubuntu

Comments Off

Sometimes there is a script which you wrote that you want to be run each time your system boots up. This was the case when I installed the GNU HTTP Tunnel server to allow SSH through HTTP Proxies for my server.

The easiest way would probably be adding the script the /etc/rc.local file which works simililary to the Windows autoexec.bat file.

But if you want to use best practices then it’s recommend that you put the script in the /etc/init.d directory and run the update-rc.d command against it. A template is also available /etc/init.d/skeleton which you can use to get started.

$ cd /etc/init.d
$ cp skeleton myscript
$ chmod 755 myscript
$ update-rc.d myscript defaults

To remove the start up script in Ubuntu execute the following:

$ update-rc.d myscript remove

Restricting Shell Users to their Home Directory

, Comments Off

The “easiest way” to lock down users to their home directory is to switch their shell account to rbash (restricted bash).  The rbash shell behaves like the bash shell, but some functions are disallowed e.g. change directory with cd.

For more information refer to the man pages for rbash.

$ man rbash

To change the user’s shell modify the file /etc/passwd

$ nano /etc/passwd

and replace /bin/bash with /bin/rbash e.g.

guest:x:100:100::/home/guest:/bin/rbash

Restricting Shell for only SCP/SFTP

, , Comments Off

If you have a server, but only want to allow users to copy files via sFTP without providing shell access. This can be done with rssh, a restricted shell for use with OpenSSH that allows only scp and/or sftp.

To install rssh

$ apt-get install rssh

By default rssh doesn’t allow anything, to allow only sftp modify the rssh.conf file.

$ nano /etc/rssh.conf

Uncomment the line for allowsftp and other transfer protocols you want to enable.

#allowscp
allowsftp
#allowcvs
#allowrdist
#allowrsync

To restrict a user to only allow sftp access, modify the /etc/passwd file

$ nano /etc/passwd

For example

ftp:x:100:100::/home/ftp:/usr/bin/rssh

Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04

, , , Comments Off

Normally when I build a web application that connects to a MySQL database, I would place the mysql-connector-java-bin.jar file into the WEB-INF/lib of the web application.

However, when I deployed the application on Tomcat 5.5 on Ubuntu 8.04 I got an exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I couldn’t find the reason which caused the exception, so I did a quick fix by placing the jar file into the Tomcat’s common lib directory.

$ cp mysql-connector-java-bin.jar /usr/share/java
$ cd /usr/share/tomcat5.5/common/lib
$ ln -s ../../../java/mysql-connector-java-bin.jar mysql-connector-java-bin.jar

Open RAR Files in Ubuntu

Comments Off

RAR is a file format developed by Eugene Roshal, and one of the most popular format used for data compression and archiving next to the ZIP file format. By default, Ubuntu doesn’t have any support for extracting RAR files, however there is an available Linux freeware unrar for downloading.

To install unrar in Ubuntu

$ apt-get install unrar

The drawback with this utility is that it only supports the RAR and RAR2 format, but not the RAR3 format which can only be extract by RARLAB’s UnRAR which is not free.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in