Skip to content

Welcome to Tech by Example

Menu
  • Home
  • Posts
  • System Design Questions
Menu

How to find what /bin/sh points to on your machine

Posted on May 29, 2023May 29, 2023 by admin

Overview

/bin/sh could be either a symbolic or hard link to what it points to. /bin/sh could point to

  • /bin/bash
  • /bin/dash
  • ….

If /bin/sh is a symbolic link

If /bin/sh is a symbolic link then we can find what it points to using the below command

file -h /bin/sh

If the /bin/sh has a symbolic link to bash then it will output

/bin/sh: symbolic link to bash

If /bin/sh is a hard link

In this case, we can use the below command to find what /bin/sh points to

find -L /bin -samefile /bin/sh

If it points to dash then below will be the output

/bin/dash
/bin/sh

For example on the docker ubuntu container the /bin/sh points to /bin/dash. So if you will run the above command in the docker ubuntu container then it will output as /bin/dash

Command to run for docker container

docker run -it ubuntu  find -L /bin -samefile /bin/sh

Output

/bin/dash
/bin/sh

Note: Check out our system design tutorial series System Design Questions

©2025 Welcome to Tech by Example | Design: Newspaperly WordPress Theme