This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Exit Bash Mode?
Every time I enter my server I am now in Bash mode.
I don't want to be in bash mode because in it I don't have my current path on my left.
This question has already been asked here:
Exit Bash Mode?
but OP accepted an answer that isn't really an answer.
I have already tried 'reset' and removing my .bashrc file.
Try "chsh -s /bin/sh" if you want to use sh. To see what your available shells are, "cat /etc/shells". You can also see what your current shell is by "echo $0" and simply "exec /bin/sh" will change shell for your session (not perm).
Changing default shell - /etc/passwd - for your unix account:
username:x:1000:1000:,,,:/home/username:/bin/bash
^^^^^^^^^
Related
This question already has answers here:
How can I debug a Bash script? [closed]
(12 answers)
Closed 2 years ago.
I'm not sure I address this problem correctly, but I've search and search over the net and found nothing, yet.
I'm writing a bash script and I want to see what the script is really doing when being executed, like a log of all the commands, one by one, what are executed - this way, I'll be able to see why my script is falling.
Note : I've post similar question in the past, someone told me I run my bash script with sh -xe script.sh but it doesn't give me enough information to debug properly.
Please advise. Thanks!
Adding set -x at the beginning of the script displays, in the terminal, all the commands sent by the script as the terminal received it. It was exactly what I needed and it working perfectly.
This question already has an answer here:
Bash how do you capture stderr to a variable? [duplicate]
(1 answer)
Closed 3 years ago.
I am trying to automate the installation of nginx on multiple servers, and I have a shell script. It runs a version check if nginx is already installed and its version.
Trying to assign TMP=$(nginx -v), and instead of storing it in the variable it prints the results to console. printf "$TMP" prints an empty string
The problem is that your command does not print to STDOUT but to STDERR.
Using:
TMP=$(nginx -v 2>&1)
will solve your issue, see here for more details.
This question already has answers here:
What are the uses of the exec command in shell scripts? [closed]
(2 answers)
Closed 3 years ago.
Just editing a bash script and the last line is:
exec <&-
Hoping someone can explain. I'm guessing it has to do with the exit code of the previous command?
exec <&- closes standard input (filedescriptor 0).
exec with just redirections but not other argument applies the redirections to the current process.
A redirection to or from &- means close.
With numerical descriptors it doesn't matter if you do 0<&- or 0>&- — either version will close filedescriptor 0 (standard input). If you ommit the number > redirection means "use fildescriptor 1and<` means "use filedescriptor 0".
This question already has answers here:
How do create an alias in shell scripts? [duplicate]
(3 answers)
Closed 5 years ago.
I have a simple bash script.
alias myls=ls
myls
If I execute this script, I get an error.
$ bash foo.sh
foo.sh: line 2: myls: command not found
Why does the alias not work in the script?
Does this behavior conform to POSIX?
If it is indeed not supposed to work, could you please point me to an authoritative documentation that stays this?
See man bash:
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt
This question already has answers here:
How does the #! shebang work?
(3 answers)
Closed 5 years ago.
while following this tutorial I found a command
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
I don't understand the meaning of #!/bin/sh. I tried to search it but google removes the ! symbol from search results.
What does #!/bin/sh mean here?
Please help.
#! specifies the program with which the script should be executed if you not explicitly call it which any
in your case, if you call your script with: <scriptname.sh> Linux will execute it as /bin/sh <scriptname.sh>