Changing from tcsh to bash? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am having difficulty with some shell commands and think that it is due to a failure of my shell being set to BASH.
The following commands solve my problem:
bash --login
Or simply by typing
bash
Therefore it seems that I need to reconfigure my shell to bash which should be simple. My default $SHELL variable is /bin/bash
I think it is due to the following setting under my terminal preferences:
run a custom command instead of my shell
/bin/tcsh/
Why should my shell preferences be set to this, what is the advantage/use of tcsh over bash?
Also, how should I overcome this issue while still retaining use of any of the features which may rely upon this default terminal preference (/bin/tcsh)
Here is some of my system information:
Ubuntu 14.02
$SHELL
/bin/bash
$BASH_VERSION
undefined variable
I have previously used the following command to change from DASH to BASH:
sudo dpkg-reconfigure dash
I have also previously used the following command:
sudo apt-get install csh

I suspect that you have /bin/bash already set, but to help you change it if not:
The default shell for an user is set inside /etc/passwd (usually).
You could see which is set for you by doing:
grep "user" /etc/passwd
Where user is your username in the system. The last value (after the last ":") is the value of shell set for you to use. You could change it in two ways, either by editing the file, or easier, by executing "chsh" (which means: "change login shell"):
$ chsh
It will ask for your password and then will ask for the shell you want to use, just write "/bin/bash".
Done. To make the changes apply to all the programs, just log-out and log-in again.
A second level of configuration belongs to the window that contain the console. I suspect that you are using gnome-terminal (the usual for Ubuntu). If not, then it may be konsole (for a KDE desktop). In any one of those, check that the configuration is not set to call "tcsh". Say which console/terminal you are using to give tips if you need them.

Related

How can I remove scripts that run by default when I open the Linux terminal? (WSL) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I accidentally created a script that runs automatically when I open the linux terminal on windows.
I completely forgot where I created these files and now I am stumped on how to remove them.
Is there anyway I can remove these scripts or have the Linux terminal be reset to default settings?
I am using Bash on Ubuntu on Windows.
Terminal with automatic scripts
What you are asking is how to find-out-what-scripts-are-being-run-by-bash-on-startup. That link answers that question but here is the short of it:
To find all of them you could run:
echo exit | strace bash -li |& grep '^open'
(-li means login shell interactive; use only -i for an interactive non-login shell.)
This will show a list of files which the shell opened or tried to open. On many systems, they are as follows:
Also it's good to know that by default the following are usually run:
/etc/profile
/etc/profile.d/* (various scripts in /etc/profile.d/)
/home/<username>/.bash_profile
/home/<username>/.bash_login
/home/<username>/.profile
/home/<username>/.bashrc
/home/<username>/.bash_history (Not a script. Simply enables history command)
/usr/share/bash-completion/bash_completion
/etc/bash_completion.d/*
/etc/inputrc (defines key bindings; this is not a script)
FYI: /home/<username>/ is the same as ~ on most systems
For each of the scripts mentioned above you may want to check if they are calling yet another script... An easy way to do that is to grep all of those scripts for keywords implying they are calling another script (although strace will already show that)
You may want to:
cat <script_name> | grep -e 'bash' -e 'source' -e '\.\/'
In the WSL terminal, I would try to check if you are calling a startup file in ~/.bashrc or ~/.bash_profile. These are typical dotfiles that are called when a new BASH session is started. In your case, look for a call to /bin/brew (or a line that may potentially call brew) in these files.

Why is the -i argument to supervisor important to get an interactive shell? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
in order to impersonate as superuser1 I need to run command like this
sudo -u superuser1 -i
I did try sudo -u superuser1 which means switch to superuser1 and its totally making sense, but it doesn't work
I also read about the sudo man page -i option
-i, --login
Run the shell specified by the target user's password database entry
as a login shell. This means that login-specific resource files such
as .profile or .login will be read by the shell. If a command is
specified, it is passed to the shell for execution via the shell's -c
option. If no command is specified, an interactive shell is executed.
sudo attempts to change to that user's home directory before running
the shell. The command is run with an environment similar to the one a
user would receive at log in. The Command environment section in the
sudoers(5) manual documents how the -i option affects the environment
in which a command is run when the sudoers policy is in use.
I can see, it puts the command into interactive mode, but it doesn't explain why
sudo -u superuser1 doesn't work.
can any one explain what exactly -i does, and why without it doesn't work
This is given, explicitly, in the man page content you quoted in the question itself:
If no command is specified, an interactive shell is executed.
That's behavior specific to sudo -i. If you want an interactive shell, then, you need to either run sudo -i, or something like sudo -u user1 -- bash -i -l.
As you can see from the man page, the -i option, not only puts the command into interactive mode but also execute the content of .profile and presumably .bashrc. I imagine that to run your command you must specify some environment variable that is automatically loaded when you use the "-i" option.

changes in bash_profile not getting reflected linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Below is the .bash_profile file that I have edited. The changes I make here are not getting reflected when I use echo $JAVA_HOME or echo $PATH.
When I use $PATH, I get /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin which is not found in any of the .bash_profiles or .bash_rcs.
How can I make my .bash_profile work?
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH=/sbin/:$PATH
export PATH=$PATH:$HOME/bin
export JAVA_HOME=/export/home/lg199447/dev/jdk1.7.0_51/bin/java
export PATH=$PATH:/export/home/lg199447/dev/jdk1.7.0_51/bin
Note:
I am trying to login to a server from an OS X terminal using ssh and once I'm logged in my terminal was showing $ followed by my cursor. I was unable to use my arrow keys and tab. So I manually stared bash by executing bash in /bin directory. This changed my terminal as lg199447#VDCALD564 /]$ and I was able to use terminal in a normal way I use in mac.
This sounds like you login shell on the linux machine is not bash, but some other shell variant. ~/.bash_profile is only sourced for bash login shells, so if you just execute bash, it's not.
Either make /bin/bash your login shell (using the command chsh -s /bin/bash), or start bash using bash -l, then it should work.
Another option would be to place your startup code in ~/.bashrc, which is sourced for for all interactive bash sessions (except if explicitly disabled with the --norc option).

sudo E option does not work? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Seems to me that if I write a shell script in $HOME/path/to/script/myscript, and export PATH=$PATH:$HOME/path/to/script/ then sudo -E myscript should run the script right?
From sudo man page:
‑E
The ‑E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the ‑E option is specified and the user does not have permission to preserve the environment.
But sudo -E script can't find the command. I know I can just add /absolute/path/to/script/ to the files that determine the PATH variable for sudo env, but that's not the approach I want to take.
To address the comments:
#H2CO3: I have seen sudo sudo floating around the net, and it bugs me tremendously, it's literally saying "Give me superuser permissions to run superuser". I don't know if it would solve the problem, but it seems like a fundamentally flawed approach. Then again I started using linux/bsd systems back in the mid 90's so I take issue with just the sudo command itself.
#rici: The script does have executable permissions, but that's definitely something to check whenever something doesn't run in *nix systems =)
/etc/sudoers by default has a setting to reset the environment. And also defines a default secure_path which is in effect when you run sudo -E [cmd].
You will need to edit the /etc/sudoers file and add 'env_keep' and mention the variables you want to preserve.
Default env_keep += "PATH"
but before this comment out the secure_path line. Then try your command via sudo -E.

How to change Linux shell in a remote computer that does not support ypchsh [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How do I change shell in a remote PC? I am logged into a cluster with a Bash and the output I see is
elan#l01:~ $ chsh
chsh: can only change local entries; use ypchsh instead.
elan#l01:~ $ ypchsh
-bash: ypchsh: command not found
Since I have no root privilege there, I can not install ypchsh in the cluster. Is there any other way to change shell without invoking ypchsh?
Note 1:
Browsing, it looks like another user who installed the same software (currently not available for questioning) has .cshrc in his directory, with the right settings. His .bashrc is minimal and has no redirections.
The /etc/passwd has no entry for either of us.
getent passwd
shows entry for both of us, but shows only /bin/bash for both.
Note 2:
The sofware has been developed with autotools, and using bash instead of tcsh is known to have created wrong builds. (I am not changing shell because I fancy it.)
Thank you,
Elan
In your .bashrc, put exec tcsh last.
Once you're in bash in the cluster, why don't you just type tcsh? And if that works, why not just add it as the last line of .bashrc?

Resources