I have come across a video where for best practice one should put their login credentials in .bash_profile. However I can't seem to find this on the Raspberry Pi.

And to retrieve this information one should:

import os

USER = os.environ.get('USER_DETAILS')
PSWD = os.environ.get('PSWD_DETAILS')


Which file do I have edit to pass on my email/sql/etc. credentials so I can later call them from with the os.environ.get() ie os.environ.get("SQL_USER")?

  • Anyone who uses a video to "explain" how to configure a text file must be immediately suspect. You can't find it because it generally doesn't exist, and it is unclear what exactly you are trying to "hide" or from whom – Milliways Feb 22 at 7:45
  • 1
    @Milliways suspect what? I'm trying to learn best practice... Is this not best practice? – 3kstc Feb 22 at 7:48
  • We obvious have a semantic dissonance - my usage of the word is not a verb. – Milliways Feb 22 at 7:51
  • @Milliways perhaps, if you had obviously used correct grammar, one would not have any semantic dissonance – 3kstc Feb 22 at 8:12
  • Best practice is to explain the question and not to refer to external sources to understand the question: What's wrong with “I followed this tutorial” kind of questions? – Ingo Feb 22 at 9:22

It is unclear what the video you reference says, but Raspbian configures the login shell using ~/.profile

You can include extra environment variables in this file.
NOTE this won't "hide" anything as it is readable by all users.

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then

export MAILTO=""
| 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.