I'm quite impressed of emacs' org-mode. So I want to use it for note-taking during lectures. To use it "distraction-free" my idea is the following:

I want to register a bash-command, which swaps the x-server session with tty2 and starts emacs with its org-mode. Is it possible to pass my credentials from the x-server session to tty2 (optional)?


By default tty2 is occupied by init for getty. You can probably change this by removing /etc/init/tty2.conf, but that was too adventurous for me and the instructions here are for tty9 instead (which is by default unallocated).

First, put these commands to ${HOME}/bin/orgmode.sh or other file:



/usr/bin/sudo chown ${USER}.tty ${TTY}
/usr/bin/sudo chmod 620 ${TTY}
( /usr/bin/sudo -u ${USER} /usr/bin/emacs -t ${TTY} -nw ) &
/usr/bin/sudo chvt 9

(Use a different value for USER as necessary.)

Then, execute this bash command (not sure what you meant by register):

sudo time getty -n -l "${HOME}/bin/orgmode.sh" tty9 230400

Some caveats:

  • The time command (or a similar dummy) is needed to prevent sudo terminal rearrangements from placing emacs on your current terminal
  • The speed value of 230400 is there only because getty requires it, other values probably work also
  • If sudo needs to ask your password and that messes up things, you can first run sudo echo and then the above command.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.