Change default shell

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change default shell
# 1  
Change default shell

Hi all
I am a total newbie at anything to do with shells or any form of scripting Unix/Linux etc.

I have been trying to run through a tutorial on scripting but it requires the use of sh.
My FreeNAS(FreeBSD) test box running the latest nightly build as an embedded install on CF card has csh as default.

I have been told:
FreeNAS has implemented the following shell's: sh, csh, tcsh and the latest FreeNAS 0.69b4 include bash.
The default shell for FreeNAS(FreeBSD) is csh.
For portability I'll suggest to use sh (take a look at scripts in /etc/rc.d/ directory), however bash is more advanced.

I have seen a few threads on here that suggest changing the 7th item of the relevant user in etc/passwd to the required shell.
I have edited it, saved and logout out as root and back in as the user.
If I then do
echo $shell
I get

So it does not appear to have changed

Tried chsh, but get
Command Not Found

Have also tried one other approach, but cant seem to find the thread again, to let you know what that was, but that also gave a Command not found

I had thought of rebooting, but if I do this, as it is and embedded system, the changes get lost.

Can any one give me any pointers.


# 2  
It's not crucial that it's your login shell; you can limp along anyway. As a workaround, just exec bash immediately after you log in.
# 3  
Thanks, I am sure that is true, but as I am just starting out, and wanted to run through this tutorial:
UNIX / Linux Bourne / Bash Shell Scripting Tutorial [ ]

which is written with the bourne shell in mind. It is easier for me if I start from the correct shell.

That way at least I know that when something goes wrong, it is something I have done rather than a difference between the tutorial (sh) and the shell I am using (csh)

The very first line in the tutorial gets you to change the prompt to $.

The command given failed and I assumed I must have been doing something wrong. Turns out that it was the shell differences. I needed to use set prompt="$ " and not what the tutorial gave.

Since I first posted, I managed to edit the passwd file and save it to the local HDD, and using the post init command section of the FreeNAS WebGUI, managed to get it to copy across on boot up.

Still did not change the user shell though, although the edited and copied version is in /etc.

I did forget to mention that I am accessing the box remotely on the local network using PuTTy.

I tried using:
exec bash
It just closed the Putty window down immediately on hitting the RETURN key...but if it had worked, would that not have put me in a bash shell rather than sh?

Last edited by npaisnel; 10-08-2008 at 04:35 PM..
# 4  
On System|Advanced|Command scripts add the following command as POST:
echo bash >> /root/.cshrc

Note: This is strictly FreeNAS embedded solution/workaround.
# 5  
I don't know much specifically about freeNAS, but whatever your login shell is doesn't matter as long as you declare the proper shell at the beginning of the script.
MY login shell can be sh, but if I write a korn shell script, as long as the first line in the script is #!/usr/bin/ksh, the script will be executed in korn (as long as ksh is in /usr/bin, of course).
# 6  
Tried that Dan
now when logging in via Putty as root I get

bash: Command not found

test being the name of the box

I did post another post earlier, but it did not appear, I have tried other methods, also with no result.

It now seems to have appeared after

Last edited by npaisnel; 10-08-2008 at 04:12 PM..
# 7  
You need 0.69b4 +, check if you have /bin/bash
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #608
Difficulty: Easy
Python does not need compilation to binary to run.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change default shell of a specific user with awk

I would like to replicate the functionality of chsh (or passwd -e) by awk. This is what I got so far, but I think there should be an easier way to search and replace field $7 only for lines beginning with user_name: awk -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name {... (2 Replies)
Discussion started by: nomad84
2 Replies

2. Shell Programming and Scripting

Shell script to change the ip

I am writing a simple DHCP server application that gets ip from a server at boot up ! i wrote a shell script to run the java program that obtains ip from server on another machine... The problem is when i have obtained the ip i store it in a file ! using awk i retrieve the... (1 Reply)
Discussion started by: dinesh17
1 Replies

3. Shell Programming and Scripting

command to change the shell

Hi, I want to change the shellrite now I am in ksh shell , I want to switch to bash shell I have tried the command ... $ chsh -s /bin/bash but it is showing error .... -ksh: chsh: not found (1 Reply)
Discussion started by: rahul125
1 Replies

4. Solaris

Can't change default shell

Hello, I've changed the shell for user jack in /etc/passwd to ksh but when I log in it's still saying the shell is bash. Any help much appreciated (4 Replies)
Discussion started by: Grueben
4 Replies

5. UNIX for Dummies Questions & Answers

How to change display in shell

Hi The line for input of my shell currently looks like in the image attached. What I wanted is for the line where I input, it showed in last, the folder I'm in (in the attached images is "Documents") and not my user name "Pedro_Gordo". How do I do this? My OS is Mac OS X 10.6. Thanks in... (7 Replies)
Discussion started by: tirwit
7 Replies

6. UNIX for Dummies Questions & Answers

How to change Default Shell for any user?

Hi, I am new for solaris... how can we change default shell for any user and how to check that which shall currently we are in...... (1 Reply)
Discussion started by: lalit21984
1 Replies

7. Shell Programming and Scripting

how to change default shell in linux?

currently the default shell in my linux enviornemnt is ksh. how to change the default shell to bash? thanks! (8 Replies)
Discussion started by: princelinux
8 Replies

8. Shell Programming and Scripting

How to change your default login shell.

I am new to UNIX hence the question. Most of the time when I have an environment set up for me to develop my systems, I have had my ID logon and I can edit the .profile for my account and it understand commands korn shell. It seems this machine, a new SUN machine, was setup with users getting the... (3 Replies)
Discussion started by: klarue7
3 Replies

9. UNIX for Dummies Questions & Answers

Change the default shell from bash to ksh

Currently my default shell is bash.How can i change itto ksh... (2 Replies)
Discussion started by: dr46014
2 Replies

10. Shell Programming and Scripting

How can I change my default shell

hi ; Right now my default shell on our school system is : /bin/ksh but i want to change it to another shell. There is also bash shell installed in the system as : /bin/bash So, how can I change my default shell to bash shell? Or maybe any other shell? (17 Replies)
Discussion started by: milhan
17 Replies

Featured Tech Videos