Shells!

Shells!

Post by Karl Kruko » Thu, 06 Jan 2000 04:00:00



I just (for the first time ever) installed FreeBSD  (3.4-stable).
That went pretty well, I even got multibooting with NT working.
Then I wanted to install a new shell ( I think default was csh ). I decided
to go with bash, so I got a tar-ball  with the source and compiled  it. That
went ok, but then I had to install the shell...
I added the shell to
/etc/shells
and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
where I though bash was - thats where I compiled it.
"Fine" I thought, and rebooted....

But when I try and login it says that it cannot find
/usr/bash/bash-2.03/bash
and  goes  back to the login-prompt.
So in effect I cannot login now !

Anyway, there are a couple of answers I need..

a) I there a smart way of fixing this

b) if no, then what is the name of the file that chsh edits? That is, which
config-files tells what the default shell is - I wanna change this back to
/bin/chsh for now

c) I tried to boot with the fixit-floppy which lets me boot into the system,
where I can change files, but when I tried to run chsh I says that a
"shared-resource" is missing. How do I share a resource?
It was called lib???.so.2 or something.

Thank you
- Karl Krukow

 
 
 

Shells!

Post by annel.. » Thu, 06 Jan 2000 04:00:00



> I just (for the first time ever) installed FreeBSD  (3.4-stable).
> That went pretty well, I even got multibooting with NT working.
> Then I wanted to install a new shell ( I think default was csh ). I decided
> to go with bash, so I got a tar-ball  with the source and compiled  it. That
> went ok, but then I had to install the shell...

The easy way to do it is go to /usr/ports/shells/bash (I think you have
a choice of two versions of bash) and (as root) type

make install

That gets the source, builds it, installs it, and adds it to /etc/shells.
All you need, then, is an initialization file (.bashrc or whatever) in
your home directory.  Installed binaries usually (except for X bins) go
in /usr/local/bin.

Quote:> I added the shell to
> /etc/shells
> and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
> where I though bash was - thats where I compiled it.
> "Fine" I thought, and rebooted....

The location of bash, where you put it, is not in the path of binaries
searched.  It's totally non-standard for FreeBSD.

If you do it by hand (rather than using the ports mechanism) you need to
get the same, correct path in master.passwd, which you can do with chsh,
and in /etc/shells.

Quote:> But when I try and login it says that it cannot find
> /usr/bash/bash-2.03/bash
> and  goes  back to the login-prompt.

You should be able to log in as root and edit what you need to edit.
If you can't log in as root, you can boot (with boot -s as the boot
process begins), or possibly boot /kernel -s, or boot -s /kernel
(sorry I don't remember exactly what it is for that version) into
single-user mode.
Then do mount -u / to mount the root partition read-write, mount -a
to mount everything else and get access to ee or vi or pico or whatever
you use as an editor.

Quote:> So in effect I cannot login now !
> Anyway, there are a couple of answers I need..
> a) I there a smart way of fixing this

As root mv /usr/bash/bash-2.03/bash /usr/local/bin, hash or rehash to
get binaries in path reread, put /usr/local/bin/bash in /etc/shells,
use vipw (yes, do it!) to edit master.passwd and have the data base
rewritten, and put your shell in there as /usr/local/bin/bash.  

Quote:> b) if no, then what is the name of the file that chsh edits? That is, which
> config-files tells what the default shell is - I wanna change this back to
> /bin/chsh for now

To /bin/csh, you mean.  You really have to be careful with this stuff or
it doesn't work. :)  But don't go back; csh is a poor shell for command
line work and worse for scripts. bash is good for both.

Do not replace csh or sh in /bin with bash.  bash is not statically
linked and won't run in single user mode, so you need those shells there.

Quote:> c) I tried to boot with the fixit-floppy which lets me boot into the system,
> where I can change files, but when I tried to run chsh I says that a
> "shared-resource" is missing. How do I share a resource?
> It was called lib???.so.2 or something.

again, just type vipw   It will let you edit the password file directly,
which is the file chsh edits.

And set up another user able to su to root so that if you get in this
situation again, you have an easier way out.  This would work remotely
as well, since you can't by default telnet into a system and log in as
root (major security problem there).  The adduser program lets you set
some defaults, but you can give a user any valid shell.

Quote:> Thank you
> - Karl Krukow

Annelise

 
 
 

Shells!

Post by Mark W J Reddin » Thu, 06 Jan 2000 04:00:00


Quote:> I added the shell to
> /etc/shells
> and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
> where I though bash was - thats where I compiled it.
> "Fine" I thought, and rebooted....

I find it more useful to copy bash into the /bin directory, add that
copy of bash to /etc/shells and then edit using vipw to set the root
shell /bin/bash. This has the added advantage of working even if
mounting of other filesystems (/usr or /usr/local) fails, as /bin should
be part of the your root partition.

Quote:> a) I there a smart way of fixing this

boot the system into single user mode but interrupting the boot process
(as soon as you get beyond the BIOS messages) and typing :-

-s

When single user mode comes up you should be able to remount the root
partition as read-write with

mount -u /

from that point you can mount the other partitions and then copy bash as
I described about and then edit /etc/shells and use vipw to change the
root shell to /bin/bash.

<LECTURE>
It is often better to not use root directly, rather create a user
account and give it access to the wheel group and do not touch root
without first proving any changes using this other account. (as I've
learned from past experience).
</LECTURE>

--

Mark W J Redding

 
 
 

Shells!

Post by Donn Mille » Thu, 06 Jan 2000 04:00:00



Quote:> I find it more useful to copy bash into the /bin directory, add that
> copy of bash to /etc/shells and then edit using vipw to set the root
> shell /bin/bash. This has the added advantage of working even if
> mounting of other filesystems (/usr or /usr/local) fails, as /bin should
> be part of the your root partition.

Of course, you should compile bash with the option --static-link or
--enable-static-link.  ./configure --help says which option this is.

$ ldd /bin/bash
ldd: /bin/bash: not a dynamic executable

$ ldd /usr/local/bin/bash
/usr/local/bin/bash:
        libncurses.so.5 => /usr/lib/libncurses.so.5 (0x280c7000)
        libc.so.4 => /usr/lib/libc.so.4 (0x28107000)

I've got bash as both a root shell and a normal user shell.  The shared
libs are on /usr, so you can see why the root shell has to be static
linked.

- Donn

 
 
 

Shells!

Post by Alan Strassbe » Thu, 06 Jan 2000 04:00:00




Quote:>> I added the shell to
>> /etc/shells
>> and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
>> where I though bash was - thats where I compiled it.
>> "Fine" I thought, and rebooted....

>I find it more useful to copy bash into the /bin directory, add that
>copy of bash to /etc/shells and then edit using vipw to set the root
>shell /bin/bash. This has the added advantage of working even if
>mounting of other filesystems (/usr or /usr/local) fails, as /bin should
>be part of the your root partition.

        Be sure to build bash not to use shared libs if you do this, e.g.
        ./configure --enable-static-link

        See bash's INSTALL file.

                        alan
--

 
 
 

Shells!

Post by Karl Kruko » Thu, 06 Jan 2000 04:00:00


Thank you !



> > I just (for the first time ever) installed FreeBSD  (3.4-stable).
> > That went pretty well, I even got multibooting with NT working.
> > Then I wanted to install a new shell ( I think default was csh ). I
decided
> > to go with bash, so I got a tar-ball  with the source and compiled  it.
That
> > went ok, but then I had to install the shell...

> The easy way to do it is go to /usr/ports/shells/bash (I think you have
> a choice of two versions of bash) and (as root) type

Yes but I haven't got a working network-connection yet :-)

Quote:> make install

> That gets the source, builds it, installs it, and adds it to /etc/shells.
> All you need, then, is an initialization file (.bashrc or whatever) in
> your home directory.  Installed binaries usually (except for X bins) go
> in /usr/local/bin.

> > I added the shell to
> > /etc/shells
> > and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
> > where I though bash was - thats where I compiled it.
> > "Fine" I thought, and rebooted....

> The location of bash, where you put it, is not in the path of binaries
> searched.  It's totally non-standard for FreeBSD.

Ok.
Could you  redirect me to an URL with "standards" for the different
directories in FreeBSD?

Quote:> If you do it by hand (rather than using the ports mechanism) you need to
> get the same, correct path in master.passwd, which you can do with chsh,
> and in /etc/shells.

> > But when I try and login it says that it cannot find
> > /usr/bash/bash-2.03/bash
> > and  goes  back to the login-prompt.

> You should be able to log in as root and edit what you need to edit.
> If you can't log in as root, you can boot (with boot -s as the boot
> process begins), or possibly boot /kernel -s, or boot -s /kernel
> (sorry I don't remember exactly what it is for that version) into
> single-user mode.
> Then do mount -u / to mount the root partition read-write, mount -a
> to mount everything else and get access to ee or vi or pico or whatever
> you use as an editor.

Great, thank you.  That worked.  I booted with # boot /kernel -s
then I did what you said and it worked fine.
:-)

Quote:> > So in effect I cannot login now !

 -  Now I can.

Quote:> > Anyway, there are a couple of answers I need..

> > a) I there a smart way of fixing this

> As root mv /usr/bash/bash-2.03/bash /usr/local/bin, hash or rehash to
> get binaries in path reread, put /usr/local/bin/bash in /etc/shells,
> use vipw (yes, do it!) to edit master.passwd and have the data base
> rewritten, and put your shell in there as /usr/local/bin/bash.

Question:

1) What is hash(ing)/rehash(ing) and why is it needed?

2) What is vipw and what does it do?

Quote:> > b) if no, then what is the name of the file that chsh edits? That is,
which
> > config-files tells what the default shell is - I wanna change this back
to
> > /bin/chsh for now

> To /bin/csh, you mean.  You really have to be careful with this stuff or
> it doesn't work. :)  But don't go back; csh is a poor shell for command
> line work and worse for scripts. bash is good for both.

whoops :-)

Quote:> Do not replace csh or sh in /bin with bash.  bash is not statically
> linked and won't run in single user mode, so you need those shells there.

Ok.

Quote:> > c) I tried to boot with the fixit-floppy which lets me boot into the
system,
> > where I can change files, but when I tried to run chsh I says that a
> > "shared-resource" is missing. How do I share a resource?
> > It was called lib???.so.2 or something.

> again, just type vipw   It will let you edit the password file directly,
> which is the file chsh edits.

> And set up another user able to su to root so that if you get in this
> situation again, you have an easier way out.  This would work remotely
> as well, since you can't by default telnet into a system and log in as
> root (major security problem there).  The adduser program lets you set
> some defaults, but you can give a user any valid shell.

Yeah I will !
Guess I've just gotten used to logging in as Administrator in NT.

Quote:> > Thank you

> > - Karl Krukow

> Annelise

Isn't that a danish name?

Thank you.
-Karl

 
 
 

Shells!

Post by Karl Kruko » Thu, 06 Jan 2000 04:00:00


Thanx for your reply.
I'm up and running again :-)



Quote:> > I added the shell to
> > /etc/shells
> > and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
> > where I though bash was - thats where I compiled it.
> > "Fine" I thought, and rebooted....

> I find it more useful to copy bash into the /bin directory, add that
> copy of bash to /etc/shells and then edit using vipw to set the root
> shell /bin/bash. This has the added advantage of working even if
> mounting of other filesystems (/usr or /usr/local) fails, as /bin should
> be part of the your root partition.

> > a) I there a smart way of fixing this

> boot the system into single user mode but interrupting the boot process
> (as soon as you get beyond the BIOS messages) and typing :-

> -s

> When single user mode comes up you should be able to remount the root
> partition as read-write with

> mount -u /

> from that point you can mount the other partitions and then copy bash as
> I described about and then edit /etc/shells and use vipw to change the
> root shell to /bin/bash.

> <LECTURE>
> It is often better to not use root directly, rather create a user
> account and give it access to the wheel group and do not touch root
> without first proving any changes using this other account. (as I've
> learned from past experience).
> </LECTURE>

Yeah, I've learned my lesson here...

The "wheel" group is the group that has "root-privileges" ?
How do I add a user with access to the wheel-group?

- Show quoted text -

Quote:> --

> Mark W J Redding

 
 
 

Shells!

Post by Karl Kruko » Thu, 06 Jan 2000 04:00:00


Quote:> > You should be able to log in as root and edit what you need to edit.
> > If you can't log in as root, you can boot (with boot -s as the boot
> > process begins), or possibly boot /kernel -s, or boot -s /kernel
> > (sorry I don't remember exactly what it is for that version) into
> > single-user mode.
> > Then do mount -u / to mount the root partition read-write, mount -a
> > to mount everything else and get access to ee or vi or pico or whatever
> > you use as an editor.

> Great, thank you.  That worked.  I booted with # boot /kernel -s
> then I did what you said and it worked fine.
> :-)

Another question.
I understand that mount -u /  mounts   the root-partition.
But what does mount -a do to make stuff accessible ?
 
 
 

Shells!

Post by Mark W J Reddin » Thu, 06 Jan 2000 04:00:00


Quote:

> Of course, you should compile bash with the option --static-link or
> --enable-static-link.  ./configure --help says which option this is.

> $ ldd /bin/bash
> ldd: /bin/bash: not a dynamic executable

> $ ldd /usr/local/bin/bash
> /usr/local/bin/bash:
>         libncurses.so.5 => /usr/lib/libncurses.so.5 (0x280c7000)
>         libc.so.4 => /usr/lib/libc.so.4 (0x28107000)

> I've got bash as both a root shell and a normal user shell.  The shared
> libs are on /usr, so you can see why the root shell has to be static
> linked.

Thank you for that, I'll rebuild it as a static exe tonight.

--

Mark W J Redding

 
 
 

Shells!

Post by Chris Costell » Thu, 06 Jan 2000 04:00:00



> Another question.
> I understand that mount -u /  mounts   the root-partition.
> But what does mount -a do to make stuff accessible ?

   From the mount(8) man page:

     -a      All the filesystems described in fstab(5) are mounted.  Excep-
             tions are those marked as ``noauto'', excluded by the -t flag
             (see below), or if they are already mounted (except the root
             filesystem which is always remounted to preserve traditional sin-
             gle user mode behavior).

   Try ``man mount'' as well.


 
 
 

Shells!

Post by Christian Weisgerb » Fri, 07 Jan 2000 04:00:00



> Could you  redirect me to an URL with "standards" for the different
> directories in FreeBSD?

hier(7)

Quote:> Question:

> 1) What is hash(ing)/rehash(ing) and why is it needed?

When you call a command for the first time, the shell searches
through all the directories in your PATH. Since checking hundreds
of directories entries is an expensive operation, the shell stores
the command name and the looked-up path for future use. Typically
the data structure used to save this information is a hash table.
(See any introductory computer science book on data structures.)

Now when you move the executable to a different place or add a new
executable by the same name that should be found first, the remembered
path will be wrong. You need to tell the shell to recreate the
entry for this command in its hash table. The various shells differ
in their hashing behavior and in the commands they offer to the
user to manipulate the table. See the man page of the particular
shell you are concerned with for details.

Quote:> 2) What is vipw and what does it do?

That is clearly explained in the vipw(1) man page.

--

 
 
 

Shells!

Post by Christian Weisgerb » Fri, 07 Jan 2000 04:00:00



> The "wheel" group is the group that has "root-privileges" ?

No. Membership in the wheel group generally offers the single
privilege of being allowed to su(1) to root.

Quote:> How do I add a user with access to the wheel-group?

The question should rather be phrased "how do I add a given user
to the wheel group?". Add the user name to the final field of the
respective group in the /etc/group file. See group(5). You can do
this directly with any text editor. NB: Group membership for a
login session is set at login time only. In order for a changed
group membership to become active, the respective user needs to
login anew.

--

 
 
 

Shells!

Post by annel.. » Sat, 08 Jan 2000 04:00:00



> I added the shell to
> /etc/shells
> and ran chsh and changed the variable shell to /usr/bash/bash-2.03/bash
> where I though bash was - thats where I compiled it.
> "Fine" I thought, and rebooted....
> But when I try and login it says that it cannot find
> /usr/bash/bash-2.03/bash
> and  goes  back to the login-prompt.
> So in effect I cannot login now !

Just for the record....although this is non-standard, if you
put bash in that location and get the path right in /etc/shells,
and add a user with that shell (using adduser) and thus get the path
right in the master.passwd file (or do so with vipw), it will work.

The master.passwd file points to the location of the shell, which
must be in /etc/shells. This confirms my suspicion that the vast
majority of problems with shells are caused by typos.

        Annelise

 
 
 

1. Bourne Shell compatible shells (was: Request: which shells)


Me too :-)

I also had some problems with smail and make depend. Don't remember how I
fixed them.

I also detected two other problems with bash 1.12:

 - it wouldn't run the Configure script of trn 3.0 (beta). This will be
   fixed in bash 1.13, but the Configure script has already changed so that
   it works with bash 1.12 too.

 - it does something wrong with passing $* from other shell scripts which are
   included by the `.' command. I detected this when INN 1.4 rejected all
   newgroup messages.

The pdksh I have (4.7) is absolutely unuseable for running Configure
scripts. Try the following script with pdksh 4.7 with two or more parameters:

        #!/bin/ksh

Zsh gives also problems with Configure scripts.

I use tcsh as interactive shell and bash as /bin/sh substitute because bash
is the more-or-less Bourne shell compatible shell which runs most of the
(Configure) scripts I have.  Running Configure scripts (sometimes >100Kb) is
a real good test for testing /bin/sh compatibility of shells.

Arjan

--


2. mosfet.org?

3. shells shells shells

4. MX Records using sendmail 8.8.8

5. handling SIGINT in shell scripts when executing another shell script.

6. SMC Etherpower PCI

7. UNIX shell differences and how to change your shell (Monthly Posting)

8. HELP : vi +<lin num> <File Name> in a for loop ?

9. killing a shell that has a running child shell

10. Changing from the Bourne shell to C-shell

11. UNIX shell differences and how to change your shell (Monthly Posting)

12. Trying to run nohup from Korn shell but getting Bourne shell errors