permissions in terminal

Description

For some strange reason if I run the same code in terminal through ssh on my Ubuntu machine and on JupyterLab terminal everything goes fine, but when I run JupyterLab within JupyterHub something changes, I don’t get enough permissions…

Expected behaviour

Here are the commands and response in ssh terminal and in JupyterLab terminal

bioinfo@bioinfo:/var/www/html/scripts$ whoami
bioinfo
bioinfo@bioinfo:/var/www/html/scripts$ groups bioinfo
bioinfo : bioinfo adm cdrom sudo dip plugdev users lpadmin sambashare webmaster fs13-mount-rw
bioinfo@bioinfo:/var/www/html/scripts$ ls -la
total 8
drwxrwxr-x 2 root webmaster 4096 авг  1 18:32 .
dr-xrwxr-x 4 root webmaster 4096 авг  1 18:10 ..
bioinfo@bioinfo:/var/www/html/scripts$ touch 1
bioinfo@bioinfo:/var/www/html/scripts$

Actual behaviour

But under JupyterHub things change:

bioinfo@bioinfo:/var/www/html/scripts$ whoami
bioinfo
bioinfo@bioinfo:/var/www/html/scripts$ groups bioinfo
bioinfo : bioinfo adm cdrom sudo dip plugdev users lpadmin sambashare webmaster fs13-mount-rw
bioinfo@bioinfo:/var/www/html/scripts$ ls -la
total 8
drwxrwxr-x 2 root webmaster 4096 Aug  1 18:32 .
dr-xrwxr-x 4 root webmaster 4096 Aug  1 18:10 ..
bioinfo@bioinfo:/var/www/html/scripts$ touch 1
touch: cannot touch '1': Permission denied

But I don’t get the thing: I’m running commands under the same user, in the same folder. Why would I have different permissions?

Your personal set up

I installed JupyterHub/Lab through pip3.

  • OS: Linux bioinfo 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  • Version(s): jupyterhub 1.4.2, python 3.8

  • Full environment
# paste output of `pip freeze`
$ pip freeze
aiogram==2.14.3
aiohttp==3.7.4.post0
alembic==1.6.5
anyio==3.3.0
APScheduler==3.7.0
apturl==0.5.2
argon2-cffi==20.1.0
async-generator==1.10
async-lru==1.0.2
async-timeout==3.0.1
attrs==21.2.0
Babel==2.9.1
backcall==0.2.0
bcrypt==3.1.7
beautifulsoup4==4.8.2
biopython==1.79
bleach==3.3.1
blinker==1.4
Brlapi==0.7.0
cairocffi==1.2.0
CairoSVG==2.5.2
certifi==2021.5.30
certipy==0.1.3
cffi==1.14.6
chardet==3.0.4
chartkick==0.5.0
cheroot==8.3.0
CherryPy==8.9.1
click==8.0.1
colorama==0.4.3
colour==0.1.5
command-not-found==0.3
ConfigArgParse==0.13.0
cryptography==3.4.7
cssselect2==0.4.1
cupshelpers==1.0
cycler==0.10.0
dbus-python==1.2.16
debugpy==1.4.1
decorator==5.0.9
defer==1.0.6
defusedxml==0.7.1
dill==0.3.4
distro==1.4.0
distro-info===0.23ubuntu1
dnspython==1.16.0
drawSvg==1.8.2
duplicity==0.8.12.0
entrypoints==0.3
et-xmlfile==1.1.0
fasteners==0.14.1
feedparser==5.2.1
filelock==3.0.12
Flask==2.0.1
future==0.18.2
gpg===1.13.1-unknown
gurobipy==9.1.2
html5lib==1.0.1
httplib2==0.14.0
humanfriendly==4.18
humanize==3.10.0
idna==2.8
imageio==2.9.0
ipykernel==6.0.3
ipython==7.25.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
itsdangerous==2.0.1
jaraco.functools==2.0
jedi==0.18.0
Jinja2==3.0.1
joblib==1.0.1
json5==0.9.6
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.12
jupyter-console==6.4.0
jupyter-contrib-core==0.3.3
jupyter-contrib-nbextensions==0.5.1
jupyter-core==4.7.1
jupyter-highlight-selected-word==0.2.0
jupyter-latex-envs==1.4.6
jupyter-nbextensions-configurator==0.4.1
jupyter-server==1.10.1
jupyter-telemetry==0.1.0
jupyterhub==1.4.2
jupyterlab==3.0.16
jupyterlab-pygments==0.1.2
jupyterlab-server==2.6.1
jupyterlab-widgets==1.0.0
keyring==18.0.1
kiwisolver==1.3.1
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
lockfile==0.12.2
logomaker==0.8
louis==3.12.0
lxml==4.5.0
macaroonbakery==1.3.1
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==2.0.1
matplotlib==3.4.2
matplotlib-inline==0.1.2
# Editable install with no version control (misc==0.0.0)
-e /home/bioinfo/lib/misc
mistune==0.8.4
monotonic==1.5
more-itertools==4.2.0
multidict==5.1.0
nbclassic==0.3.1
nbclient==0.5.3
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
netifaces==0.10.4
nodejs==0.1.1
notebook==6.4.0
npm==0.1.1
Nuitka==0.6.16.2
numpy==1.21.1
oauthlib==3.1.0
olefile==0.46
onboard==1.4.1
openpyxl==3.0.7
optional-django==0.1.0
packaging==21.0
padme==1.1.1
pamela==1.0.0
pandas==1.3.1
pandocfilters==1.4.3
paramiko==2.6.0
parso==0.8.2
pexpect==4.6.0
pickleshare==0.7.5
Pillow==7.0.0
prometheus-client==0.11.0
prompt-toolkit==3.0.19
protobuf==3.6.1
psutil==5.5.1
ptyprocess==0.7.0
pyaes==1.6.1
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycairo==1.16.2
pycparser==2.20
pycrypto==2.6.1
pycups==1.9.73
pycurl==7.43.0.2
Pygments==2.9.0
PyGObject==3.36.0
PyJWT==1.7.1
pylibacl==0.5.4
-e git+git@github.com:lapotok/pymabs.git@c9c1c29ceb0c6df6756d7fd479f74374939a1a22#egg=pymabs
pymacaroons==0.13.0
-e git+git@github.com:lapotok/pymolbiol.git@71b8bf3ec8a7fc27c8d17d58d3f3b72e3ebfe4f3#egg=pymolbiol
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyparsing==2.4.6
pyRFC3339==1.1
Pyrogram==1.2.9
pyrsistent==0.18.0
PySocks==1.7.1
pyTelegramBotAPI==3.8.2
python-apt==2.0.0+ubuntu0.20.4.5
python-dateutil==2.7.3
python-debian===0.1.36ubuntu1
python-editor==1.0.4
python-json-logger==2.0.2
python-ldap==3.2.0
pytz==2019.3
pyxattr==0.6.1
pyxdg==0.26
PyYAML==5.3.1
pyzmq==22.1.0
qtconsole==5.1.1
QtPy==1.9.0
rdiff-backup==2.0.0
rdiffweb==2.3.0
regex==2021.7.6
reportlab==3.5.34
repoze.lru==0.7
requests==2.22.0
requests-file==1.5.1
requests-unixsocket==0.2.0
Routes==2.4.1
ruamel.yaml==0.17.10
ruamel.yaml.clib==0.2.6
SecretStorage==2.3.1
selenium==3.141.0
selenium-requests==1.3
Send2Trash==1.7.1
simplejson==3.16.0
six==1.14.0
sniffio==1.2.0
soupsieve==1.9.5
SQLAlchemy==1.3.12
ssh-import-id==5.10
system-service==0.3
systemd-python==234
terminado==0.10.1
testpath==0.5.0
TgCrypto==1.2.2
tinycss2==1.1.0
tldextract==3.1.0
tornado==6.1
torpy==1.1.6
traitlets==5.0.5
typing-extensions==3.10.0.0
tzlocal==2.1
ubuntu-advantage-tools==27.0
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
unity-scope-calculator==0.1
unity-scope-devhelp==0.1
unity-scope-manpages==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-zotero==0.1
urllib3==1.25.8
usb-creator==0.3.7
wadllib==1.3.3
wcwidth==0.2.5
webencodings==0.5.1
WebOb==1.8.5
websocket-client==1.1.0
Werkzeug==2.0.1
widgetsnbextension==3.5.1
WTForms==2.2.1
xdiagnose==3.8.9
xkit==0.0.0
XlsxWriter==1.1.2
yarl==1.6.3
bioinfo@bioinfo:/var/w
  • Configuration
# grep -v '\(^#\|^[[:space:]]*$\)' jupyterhub_config.py
c.Spawner.cmd = ["jupyter-labhub"]
c.Spawner.default_url = '/lab'

Thank you in advance!

Have you checked your system logs around the time of the error? Do you have any security hardening software running such as AppArmor that might prevent a write which originates from a web server?

Do you have the same problem in other directories, or only this one? For example if you create a directory with the same owner and permissions but under your home directory do you also see the same error?

Note that the JupyterLab terminal does not start its terminals as login shells, but as interactive non-login shells (see this explanation of the difference). This means that .bash_profile is not executed for you in the JupyterLab terminal.

Is it possible that some of the configuration that you expect is being loaded by .bash_profile? You can test that by running source ~/.bash_profile in the JupyterLab terminal; if that fixes the problem, then you’ll need to rethink how you lay out your relationship between .bashrc and .bash_profile so that you get the behavior you want in all non-login shells…

2 Likes