Demonstration of running a Jupyter notebook with sudo rights

Without sudo rights

The next cells were first ran when Jupyter was not running with sudo rights.


In [5]:
!apt update


Lecture des listes de paquets... Fait
E: Le répertoire /var/lib/apt/lists/partial pour les listes n'existe pas. - Acquire (13: Permission non accordée)
W: Problème de suppression du lien /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission non accordée)
W: Problème de suppression du lien /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission non accordée)

In [6]:
!sudo apt update


[sudo] Mot de passe de lilian : 

As we see here, using sudo ... asks for a password, but it doesn't work from Jupyter.

With sudo rights

The next cells were then ran when Jupyter was running with sudo rights.


In [6]:
!apt update


Réception de:1 http://archive.canonical.com/ubuntu bionic InRelease [10,2 kB]  m
Réception de:2 http://ppa.launchpad.net/audio-recorder/ppa/ubuntu bionic InRelease [15,9 kB]
Réception de:3 http://archive.canonical.com/ubuntu bionic/partner Sources [1 904 B]3mm
Réception de:4 http://archive.canonical.com/ubuntu bionic/partner i386 Packages [2 300 B]
Réception de:5 http://archive.canonical.com/ubuntu bionic/partner amd64 Packages [2 304 B]
Réception de:6 http://archive.canonical.com/ubuntu bionic/partner Translation-en [1 272 B]
Réception de:7 http://ppa.launchpad.net/costales/anoise/ubuntu bionic InRelease [15,4 kB]
0% [Connexion à fr.archive.ubuntu.com] [Attente des fichiers d'en-tête] [7 Inm^C

It works!

Conclusion

It works!