Change default shell | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Change default shell

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-08-2008
npaisnel npaisnel is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 10 October 2008, 9:55 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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
/bin/tcsh

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.

Thanks

Neil
Sponsored Links
    #2  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks: 0
Thanked 10 Times in 8 Posts
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.
Sponsored Links
    #3  
Old 10-08-2008
npaisnel npaisnel is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 10 October 2008, 9:55 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 [ steve-parker.org ]

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 02:35 PM..
    #4  
Old 10-08-2008
danmero danmero is offline Forum Advisor  
 
Join Date: Nov 2007
Last Activity: 12 October 2014, 10:11 AM EDT
Location: H3X
Posts: 2,151
Thanks: 10
Thanked 117 Times in 110 Posts
On System|Advanced|Command scripts add the following command as POST:

Code:
echo bash >> /root/.cshrc

Note: This is strictly FreeNAS embedded solution/workaround.
Sponsored Links
    #5  
Old 10-08-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
 
Join Date: May 2006
Last Activity: 4 May 2012, 3:37 PM EDT
Location: Tau Ceti V
Posts: 558
Thanks: 0
Thanked 7 Times in 6 Posts
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).
Sponsored Links
    #6  
Old 10-08-2008
npaisnel npaisnel is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 10 October 2008, 9:55 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Tried that Dan
now when logging in via Putty as root I get

bash: Command not found
test:~#

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 02:12 PM..
Sponsored Links
    #7  
Old 10-08-2008
danmero danmero is offline Forum Advisor  
 
Join Date: Nov 2007
Last Activity: 12 October 2014, 10:11 AM EDT
Location: H3X
Posts: 2,151
Thanks: 10
Thanked 117 Times in 110 Posts
You need 0.69b4 +, check if you have /bin/bash
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can't change default shell Grueben Solaris 4 02-19-2011 06:04 PM
How to change Default Shell for any user? lalit21984 UNIX for Dummies Questions & Answers 1 03-10-2010 04:15 AM
how to change default shell in linux? princelinux Shell Programming and Scripting 8 05-07-2009 09:31 AM
Change the default shell from bash to ksh dr46014 UNIX for Dummies Questions & Answers 2 11-22-2008 07:13 AM
How can I change my default shell milhan Shell Programming and Scripting 17 07-13-2004 04:15 PM



All times are GMT -4. The time now is 12:29 PM.