1

I just created an executable:

ln -s /path/to/script.sh /bin/script

then I check if everything succeeds and it does(/bin/script is created) but this has also created:

/usr/bin/script

and if I check what the system uses for the script command with which, it uses /usr/bin/script.

Here are the links:

2370517 0 lrwxrwxrwx. 1 root root 32 Jun 26 15:48 /bin/script -> /home/username/Scripts/script.sh
2370517 0 lrwxrwxrwx. 1 root root 32 Jun 26 15:48 /usr/bin/script -> /home/username/Scripts/script.sh

Question:

Why does it create this second link instead of adhering to the commands given and what is the reason for this?

Note, before I created this symlink I checked if the command existed:

which script
/usr/bin/which: no script in (/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:
/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/usr/lib64
/alliance/bin:/usr/libexec/sdcc:/home/username/.local/bin:/home
/username/bin:/usr/lib64/alliance/bin:/usr/libexec/sdcc:/usr/lib64
/alliance/bin:/usr/libexec/sdcc)

EDIT #1

Per comment that asked for more information:

$df
Filesystem                       1K-blocks       Used Available Use% Mounted on
devtmpfs                           4067656          0   4067656   0% /dev
tmpfs                              4079452       7876   4071576   1% /dev/shm
tmpfs                              4079452        960   4078492   1% /run
tmpfs                              4079452          0   4079452   0% /sys/fs/cgroup
/dev/mapper/fedora_hostname-root    4674688      78624   4335560   2% /
/dev/mapper/fedora_hostname-usr    98874972   13540704  80288612  15% /usr
/dev/sdb2                           369639     168512    177524  49% /boot
/dev/mapper/fedora_hostname-var     6597808    1523556   4716060  25% /var
/dev/mapper/fedora_hostname-opt    23901328     630808  22033324   3% /opt
/dev/mapper/fedora_hostname-tmp     9480420      21592   8954204   1% /tmp
/dev/mapper/fedora_hostname-home   81412840    5154748  72099424   7% /home
/dev/sda2                        453437944   19435724 410945836   5% /MOUNT1
/dev/sda1                       1469159772 1182245732 212261988  85% /MOUNT2
tmpfs                               815892         36    815856   1% /run/user/1000
tmpfs                               815892          0    815892   0% /run/user/0

$cat /proc/self/mounts
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=4067656k,nr_inodes=1016914,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/mapper/fedora_hostname-root / ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/mapper/fedora_hostname-usr /usr ext4 rw,seclabel,relatime,data=ordered 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=28,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
nfsd /proc/fs/nfsd nfsd rw,relatime 0 0
/dev/sdb2 /boot ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/mapper/fedora_hostname-var /var ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/mapper/fedora_hostname-opt /opt ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/mapper/fedora_hostname-tmp /tmp ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/mapper/fedora_hostname-home /home ext4 rw,seclabel,relatime,data=ordered 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
/dev/sda2 /MOUNT\0401 ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/sda1 /MOUNT\0402 ext4 rw,seclabel,relatime,data=ordered 0 0
tmpfs /run/user/1000 tmpfs rw,seclabel,nosuid,nodev,relatime,size=815892k,mode=700,uid=1000,gid=1000 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=815892k,mode=700 0 0

EDIT #2

More information per request:

$/bin/ls -ld /bin /usr/bin
lrwxrwxrwx. 1 root root      7 Nov 18  2014 /bin -> usr/bin
dr-xr-xr-x. 3 root root 135168 Jun 26 15:48 /usr/bin
  • Show also the output of df and cat /proc/self/mounts. Maybe you have some bind mount somewhere. Or perhaps you typed other commands. – Basile Starynkevitch Jun 26 '15 at 16:51
  • 7
    I bet /bin and /usr/bin are linked. – Jeff Schaller Jun 26 '15 at 16:53
  • 1
    Show also output of /bin/ls -ld /bin /usr/bin; I guess that Jeff Shaller is right and then he got the explanation – Basile Starynkevitch Jun 26 '15 at 17:14
  • 2
    See also freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge - as of Fedora 17, /bin and /usr/bin point to the same directory. – godlygeek Jun 26 '15 at 17:19
  • 2
    To be clear, it didn't create a second symlink. You're just looking at the same symlink from a different direction. – mattdm Jun 27 '15 at 4:09
8

Welcome to the future. It is now 2012, and in your brand new Fedora version 17 /bin is now merely a symbolic link to /usr/bin. There is no separate /bin directory.

Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.