Archive for Linux

Linux server remembering last used folder

I’m administrating many servers – usually each for different purpose.

When I log to a server very often I need to work at last folder where I was last time – 80% cases. But Linux kicks me to my home directory, which is the last one where I want to be.

Following script will remember where you was and after login it will move you back to that folder. Put it into ~/.bashrc or /etc/bashrc

function mycd() {
 cd $1
 pwd > ~/.pwd
alias switch="cd $(cat ~/.pwd)"
alias cd='mycd'


How it works:

1) function mycd must be defined at bashrc file to so the command cd will apply to your shell. If you will create small script and call it, it will not work.

2) at the function mycd you execute cd and the you store actual path to file ~/.pwd

3) at the start of the bash, you first restore your path by loading content of ~/.pwd and then you replace cd command with mycd.


It’s so simple, but it saves time.


Sharing one port between SSL, SSH and OpenVPN

As I’m running many different Linux servers I’m always looking for new features.

Just today I found an article about SSLH. It allows you to run different services at one port, by identifying the data sent at the request.

This is a technique that I’m already using at my JAVA server where I run at one port HTTP server and my own protocols, because each of them identify it self by different but constant header.

It also looks to me as very simple way how to mask there there is actually running SSH or OpenVPN client at the server.

Read more