Terminate/Kill unused guest sessions in linux

Problem

You have started a couple of guest linux sessions on your pc, that you do not need anymore (ie giving access to your children while on holiday 🙂 ), and you want to close them from your own session.

Solution

Find out about the guest users by using who:

who
...
guest-kk9tnS :2           2015-08-09 17:39 (:2)
guest-kk9tnS pts/21       2015-08-09 17:40 (:2)

and then kill the sessions using pkill:

sudo pkill -9 -u guest-kk9tnS

Password protect a pdf file in linux using pdftk

Problem

You have a pdf file with sensitive information and you want to protect it with a password.

Solution

Install the pdftk if you haven’t already in your system:

sudo apt-get install pdftk

And then run the following to prompt for a password before opening the file:

pdftk original.pdf output pswd_protected.pdf user_pw PROMPT

Resetting the web-gui dd-wrt password with telnet

Problem

You have forgotten your web-gui credentials to login into your dd-wrt router but you have still telnet access to it.

Solution

Login with telnet to your router and then run the following two commands to reset the web interface:

nvram set http_passwd=
nvram commit

and then go to your Web interface to set a new one.

* Based on this post

Redirecting postfix email to a different email account

Problem

You have setup your Rails app to send out emails using postfix, but you also want to redirect the incoming emais to a different account.

Solution

Edit the postfix configuration file vi /etc/postfix/main.cf and add the following two lines at the bottom:

virtual_alias_domains = outgoing_domain.com
virtual_alias_maps = hash:/etc/postfix/virtual

And then add the redirections to the virtual file with vi /etc/postfix/virtual:

outgoing_email@outgoing_domain.com           other_account@other_domain.com
@outgoing_domain.com                         other_account@other_domain.com

Then run the following two commands to restart postfix:

postmap /etc/postfix/virtual
postfix reload

* Based on the post here