进一步阅读

进一步阅读

我刚刚创建了一个可执行文件:

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

然后我检查一切是否成功并且确实成功(/bin/script已创建)但这也创造了:

/usr/bin/script

如果我用 来检查系统使用的script命令which,它会使用/usr/bin/script.

以下是链接:

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

问题:

为什么它创建第二个链接而不是遵守给定的命令,原因是什么?

请注意,在创建此符号链接之前,我检查了该命令是否存在:

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)

编辑#1

根据要求更多信息的评论:

$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

编辑#2

根据请求提供更多信息:

$/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

答案1

欢迎来到未来。现在是 2012 年,在全新的 Fedora 版本 17 中,/bin现在只是/usr/bin.没有单独的/bin目录。

进一步阅读

相关内容