keeping your programs active even after remote session is closed

A very common scenario when we execute some code on a remote machine using a ssh session is the when the connection terminates the program or script is also killed. A very simple solution is using a utility program called screen. On Ubuntu you can install screen using

$ sudo apt-get install screen

Now all you need to do is to start  a screen session on the remote machine. Just type in


in terminal. This will start a new screen session.

Now like what you do in a normal terminal session just run your script say your tensorflow code

$ python

Every screen session is assigned an ID which we will use later. Now say while your model is learning you want to exit the remote connection. One important thing to do just before exiting is detaching from the screen session

Simply type in ‘ctrl+a‘ followed by ‘d‘, ‘ctrl+a‘ is for entering screens command line mode and ‘d‘ is simply to detach from the current session.  Now you can safely exit.

Next time you login typein

$ screen -ls

this will list active screen sessions along with their IDs. To enter a particular session simply typein

$ screen -r ID


$ screen -r 20873.tty2.amitn

which takes you to the selected screen session and voila you have your code running.


swapping cmd/super and ctrl keys on linux

This post is for people switching from mac to linux. The most frustrating part of the transition which i face was getting accustomed to keyboard shortcuts. In mac world most things are cmd + X but with linux/windows it’s ctrl + X. So just swapping super/cmd with ctrl seems to be the easiest way to make things better. Here are steps to do the same

  1. fire up terminal and modify the file /usr/share/X11/xkb/symbols/pc using your favorite editor
    sudo xed /usr/share/X11/xkb/symbols/pc
  2. file looks something like this swapkeys
  3. notice the lines key <LCTL> and key <LWIN> modify them to looks as in image above do the same for RCTL and RWIN.
  4. logout and you’re done.