Files
在 /bin 中創建符號連結會自動在 /usr/bin 中創建第二個連結,並且 which 命令選擇 /usr/bin
我剛剛創建了一個執行檔:
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
歡迎來到未來。現在是 2012 年,在您全新的 Fedora 版本 17
/bin
中,現在只是指向/usr/bin
. 沒有單獨的/bin
目錄。進一步閱讀
- 喬 ‘Zonker’ Brockmeier (2012-01-30)。不斷變化的 Linux 文件系統:將目錄合併到 /usr中。linux.com。
- Harald Hoyer 和 Kay Sievers (2012)。 使用者移動。Fedora 項目。