LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   symlinking /bin/sh to bash question (https://www.linuxquestions.org/questions/linux-newbie-8/symlinking-bin-sh-to-bash-question-4175464621/)

DavidLee1A 06-03-2013 09:26 PM

symlinking /bin/sh to bash question
 
I am trying to ensure this situation:
Quote:

/bin/sh should be a symbolic or hard link to bash
When I tried to do that i got:
Code:

david@DavidLee1A:~$ ln -s /bin/bash /bin/sh
ln: failed to create symbolic link `/bin/sh': File exists
david@DavidLee1A:~$ ln /bin/bash /bin/sh
ln: failed to create hard link `/bin/sh': File exists

How do I ensure that /bin/sh is properly liked to bash?
To be honest I don't exactly understand the point of this (something to do with how scripts execute in each shell?) and never really think about inodes.
Maybe this will give additional info:
Code:

david@DavidLee1A:~$ ls -ali
total 224
  262 drwxr-xr-x 30 david david  4096 Jun  3 19:58 .
  261 drwxr-xr-x  3 root  root  4096 May 28 09:49 ..
  4610 -rw-------  1 david david  1222 Jun  3 16:00 .bash_history
  265 -rw-r--r--  1 david david  220 May 28 09:49 .bash_logout
  263 -rw-r--r--  1 david david  3392 May 28 09:49 .bashrc
  278 drwx------  8 david david  4096 Jun  3 19:53 .cache
  275 drwx------ 14 david david  4096 Jun  3 18:34 .config
  281 drwx------  3 david david  4096 May 28 09:51 .dbus
  267 drwxr-xr-x  2 david david  4096 May 28 09:51 Desktop
  271 drwxr-xr-x  4 david david  4096 Jun  1 07:41 Documents
  268 drwxr-xr-x  8 david david  4096 Jun  3 13:10 Downloads
393235 drwxr-xr-x  2 david david  4096 May 29 07:32 .fontconfig
  289 drwx------  3 david david  4096 Jun  3 19:53 .gconf
  4598 -rw-r-----  1 david david    0 Jun  1 14:50 .gksu.lock
262826 drwx------  3 david david  4096 May 28 11:46 .gnash
  290 drwx------  5 david david  4096 May 31 14:10 .gnome2
262167 drwx------  2 david david  4096 May 28 10:10 .gnome2_private
263267 drwx------  2 david david  4096 May 29 08:00 .gnupg
262842 drwxr-xr-x  2 david david  4096 May 28 12:40 .gstreamer-0.10
  266 -rw-r--r--  1 david david  137 Jun  3 19:53 .gtk-bookmarks
  292 drwx------  2 david david  4096 May 28 09:51 .gvfs
393618 drwxr-----  2 david david  4096 Jun  3 19:54 .hplip
  285 -rw-------  1 david david  4008 Jun  3 19:53 .ICEauthority
393247 drwx------  3 david david  4096 May 29 07:47 .kde
  299 drwxr-xr-x  3 david david  4096 May 28 09:51 .local
  4609 -rw-r--r--  1 david david    40 May 28 12:41 Mary_Jones.letter
  309 drwx------  3 david david  4096 May 28 09:51 .mission-control
262169 drwx------  4 david david  4096 May 28 10:10 .mozilla
  272 drwxr-xr-x  2 david david  4096 May 28 09:51 Music
  273 drwxr-xr-x  3 david david  4096 Jun  2 08:18 Pictures
  264 -rw-r--r--  1 david david  675 May 28 09:49 .profile
  270 drwxr-xr-x  2 david david  4096 May 28 09:51 Public
  294 drwx------  2 david david  4096 Jun  3 19:53 .pulse
  293 -rw-------  1 david david  256 May 28 09:51 .pulse-cookie
266735 drwx------  2 david david  4096 May 29 07:06 .ssh
  269 drwxr-xr-x  2 david david  4096 May 28 09:51 Templates
263063 drwx------  4 david david  4096 Jun  3 18:34 .thumbnails
  341 -rw-r--r--  1 david david  1257 Jun  3 19:58 version-check.sh
  274 drwxr-xr-x  2 david david  4096 May 28 09:51 Videos
  4676 -rw-------  1 david david  1171 Jun  3 16:00 .viminfo
395061 drwxr-xr-x  5 david david  4096 Jun  2 14:43 WindowsDocuments
  250 -rw-------  1 david david  3866 Jun  3 20:58 .xsession-errors
  251 -rw-------  1 david david 54240 Jun  3 18:53 .xsession-errors.old


jpollard 06-03-2013 09:56 PM

If /bin/sh exists, leave it alone.

If it doesn't exist, then you can create it.

Normally /bin/sh is used during system boot... so tampering with it could be a problem, or cause a serious problem.

On MOST linux systems /bin/sh is either the bash binary ( and /bin/bash a link to it) or the other way around. As long as /bin/sh exists, system boot will work.

DavidLee1A 06-03-2013 10:15 PM

Thank you jpollard for replying but I am trying to avoid issues somewhere else:
Oh, by the way, I noticed the link goes to dash:
Code:

david@DavidLee1A:~$ readlink -f /bin/sh
/bin/dash

I thought this was a general question but I should have put this in the LFS thread, consider the manual entry located at http://www.linuxfromscratch.org/lfs/.../hostreqs.html which says:
Quote:

Symlinks that point to other software (such as dash, mawk, etc.) may work, but are not tested or supported by the LFS development team, and may require either deviation from the instructions or additional patches to some packages.

druuna 06-04-2013 01:45 AM

Quote:

Originally Posted by DavidLee1A (Post 4964908)
I thought this was a general question but I should have put this in the LFS thread, consider the manual entry located at http://www.linuxfromscratch.org/lfs/.../hostreqs.html which says:
Quote:

Symlinks that point to other software (such as dash, mawk, etc.) may work, but are not tested or supported by the LFS development team, and may require either deviation from the instructions or additional patches to some packages.

You can delete the current link to dash and create a new one by hand that points to bash (as root):
Code:

$ rm /bin/sh
$ ln -s /bin/bash /bin/sh

About mawk: Once you install gawk the link is also changed to reflect this.

Do make sure that your distro is compliant with the Host System Requirements if you are going to try building LFS, otherwise you'll encounter problems along the way and might need to start from scratch again.

BTW: Do post your LFS related questions in the LFS sub-forum :)

DavidLee1A 06-04-2013 11:31 AM

I marked this solved and continued it here: http://www.linuxquestions.org/questi...49#post4965249

DavidLee1A 06-04-2013 12:25 PM

Done. Thank you. If there are no issues then I'll mark this solved in a few hours.
Code:

root@DavidLee1A:/home/david# rm /bin/sh
root@DavidLee1A:/home/david# ln -s /bin/bash /bin/sh
root@DavidLee1A:/home/david# readlink -f /bin/sh
/bin/bash



All times are GMT -5. The time now is 09:48 PM.