Criar um link simbólico em / bin cria automaticamente um segundo link em / usr / bin e o comando which escolhe / usr / bin

1

Acabei de criar um executável:

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

depois, verifico se tudo é bem-sucedido e funciona ( /bin/script é criado) , mas isso também criou :

/usr/bin/script

e se eu verificar o que o sistema usa para o comando script com which , ele usa /usr/bin/script .

Aqui estão os 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

Pergunta :

Por que ele cria este segundo link em vez de aderir aos comandos fornecidos e qual é a razão disso?

Note que, antes de criar este link simbólico, verifiquei se o comando existia:

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

Por comentário que solicitou mais informações:

$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 /MOUNT01 ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/sda1 /MOUNT02 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

Mais informações por solicitação:

$/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
    
por somethingSomething 26.06.2015 / 18:39

1 resposta

8

Bem vindo ao futuro. Agora é 2012, e na sua nova versão do Fedora, 17 /bin é agora meramente um link simbólico para /usr/bin . Não há um diretório /bin separado.

Leitura adicional

por 26.06.2015 / 19:25