0

I have a Dev-Install environment setup on my Chromebook.

Whenever I use it through crosh, I immediately switch to the root user using sudo -i. The reason that sudo -i is used instead of sudo su is so the environment variables that enable the use of Dev-Install's things are kept.

After running sudo -i, I then run:

. ${SOURCE_THIS_FILE}

${SOURCE_THIS_FILE} is just a placeholder which defines/redefines several aliases, functions, and variables.

Typing out the path to ${SOURCE_THIS_FILE} is kind of annoying, so I was wondering if there was anyway I could combine sudo -i and . ${SOURCE_THIS_FILE} such that the latter will be run immediately after switching to root?

I can then put that line in the .bashrc that is run by crosh so I'd immediately switch to a root shell upon opening the terminal in Chrome.

  • you can pass a flag to sudo so that it passes the environment variables.. I believe it's -e – Charles Addis Jul 19 '17 at 3:00
  • do you want the sourcing to happen only if you've run sudo -i, or can it happen every time root gets a bash shell? – Jeff Schaller Jul 19 '17 at 11:00

Your Answer

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

Browse other questions tagged or ask your own question.