index all rss twitter github linkedin email

Álvaro Ramírez

24 November 2018 Execute org blocks as root

Been saving admin code snippets in my own org source blocks, some requiring root access. Handy for keeping tiny self-documented scripts to easily bootstrap other machines. TIL org source block's :dir argument can be used to run block as root by using tramp syntax: :dir /sudo::

As user:

#+BEGIN_SRC sh
  whoami
#+END_SRC

#+RESULTS:
: user

As root:

#+BEGIN_SRC sh :dir /sudo::
  whoami
#+END_SRC

#+RESULTS:
: root