I want to run lots of terminal commands without having to place sudo in front of every command. I am running in macOS 10.10.5 in terminal.
I do sudo bash, but I'm getting lots of errors in my .bashrc script.
Here is my .bashrc file
mac $ cat .bashrc#! /bin/bash# ~/.bashrc: eyecuted by bash(1) for non-login shells.# see /usr/share/doc/bash/eyamples/startup-files (in the package bash-doc)# for eyamplesecho "in .bashrc but claims to be $0"/usr/bin/idwhich idecho "the path is $(pwd)"echo "\$PS1 variable is ${PS1}"echo "\$SHELL variable is ${SHELL}"echo -e "the path is: \n $PATH"echo $USERecho "end of this script."# how to display an existing function# declare -f highlightExitCodehighlightExitCode() { exit_code=$? if [ $exit_code -ne 0 ] then echo -en " RC=${exit_code} "'\xf0\x9f\x98\xb1\x20' else echo -en "" fi }mac $
output form running "sudo bash. I have the feeling that bash isn't the running shell. When I have a case statement in .bashrc, I got error messages about the case statement. Why in the world cannot the /usr/bin/id command be found? :...
mac $ sudo bashin .bashrc but claims to be bash: No such file or directorythe path is /Users/mac$PS1 variable is \u$(highlightExitCode) \$ $SHELL variable is /bin/bashthe path is: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Developer/Tools:/Users/mac/.nexustoolsrootend of this script.: command not found: command not found'ash: /Users/mac/.bashrc: line 18: syntax error near unexpected token `'ash: /Users/mac/.bashrc: line 18: `highlightExitCode()bash: highlightExitCode: command not foundroot #
I get the same results with "sudo -s":
sudo -sPassword:in .bashrc but claims to be /bin/bash: No such file or directorythe path is /Users/mac$PS1 variable is \u$(highlightExitCode) \$ $SHELL variable is /bin/bashthe path is: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Developer/Tools:/Users/mac/.nexustoolsrootend of this script.: command not found: command not found'ash: /Users/mac/.bashrc: line 18: syntax error near unexpected token `'ash: /Users/mac/.bashrc: line 18: `highlightExitCode()bash: highlightExitCode: command not foundroot #