Differences between /bin and /usr/bin & /sbin and /usr/sbin?
Hi.
I just want to clarify the difference between /bin and /usr/bin. /sbin and /usr/sbin.
When it comes to booting /bin is only useful for booting with single user and recovery mode? /sbin is the main utilities folder for booting Linux?
Everything in /usr/bin are NOT root programs (but can be used with root)? /bin contains root programs?
In more modern distributions /bin is symlinked to /usr/bin and sbin is symlinked to /usr/sbin.
Have I got this correct?
Comments
-
/sbin contains "administrative tools" (like fdisk say) and /bin contains programs (and scripts) that are used in many contexts (like ls, cp etc.) The distinction can be rather blurry.
everything needed to boot the system is supposed to be in /bin and /sbin (other than the kernel and initramfs image)
so that the system can start even before /usr is mounted (and thus /usr/bin, /usr/sbin) and is available. This also applies
to /home, and /lib has all the stuff /bin and /sbin needs, /usr/lib has all the stuff /usr/bin and /usr/sbin have.This is all historical and in most situations no one boots this way anymore. It is rare for example that anyone has /usr or /home on an NFS partition (which has historically been common in Solaris). So there is really no need to have the separation anymore,
and redhat-based distros were first to say forget it. But we still keep both directories available as symlinks because there is a lot of software that expects to find things in certain places -- which probably should not be but it is what it is.The comment about what is a root program" etc is not correct. everything in all these directories is owned by root, but is routinely accessed by non-privileged users. If the non-privileged user tries to mess with something they don't have permission to do (like use fdisk, fsck etc), they will be denied the right to do it, when they run the program, but they can still call it.
I hope this helps
1 -
Hi @WarrenUK ,
I just want to add that you always can compare files that you may find in more than one directory. For many cases, they will be symlinks. But there are other cases. For example, to know what's the 'ls' command the system is using, you do:
$ which ls
/usr/bin/ls*But there is also one under /bin:
$ ls -l /bin/ls
-rwxr-xr-x 1 root root 137888 Jan 14 2019 /bin/lsSo, if you wonder if these are two binaries are the same, you can use 'diff':
$ diff -s /usr/bin/ls /bin/ls
Files /usr/bin/ls and /bin/ls are identicalRegards,
Luis.1 -
on red hat, centos, fedora and probably some other distributions it is even simpler:
ls -l / | grep bin
lrwxrwxrwx 1 root root 7 Aug 12 2018 bin -> usr/bin
lrwxrwxrwx 1 root root 8 Aug 12 2018 sbin -> usr/sbinthe entire directory is just a symlink, so there is no point to comparing anything
0 -
Thanks guys.
That cleared up some confusion I had.
I have many more questions over the coming days to keep you all busy. They may sometimes be dumb so forgive my ignorance.
1
Categories
- All Categories
- 175 LFX Mentorship
- 175 LFX Mentorship: Linux Kernel
- 745 Linux Foundation IT Professional Programs
- 372 Cloud Engineer IT Professional Program
- 168 Advanced Cloud Engineer IT Professional Program
- 73 DevOps IT Professional Program - Discontinued
- 3 DevOps & GitOps IT Professional Program
- 98 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- AI & ML Training
- Blockchain & Decentralized Identity Training
- Cloud & Containers Training
- Cybersecurity Training
- DevOps & Site-Reliability Training
- Linux Kernel Development Training
- Networking Training
- Open Source Best Practice Training
- System Administration Training
- System Engineering Training
- Web & Application Development Training
- 2 LFD103-JP クラス フォーラム
- 4 LFD210-CN Class Forum
- 764 LFD259 Class Forum
- 681 LFS101 Class Forum
- 2 LFS158-JP クラス フォーラム
- 162 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 4 LFS207-JP クラス フォーラム
- 61 LFS241 Class Forum
- 52 LFS242 Class Forum
- 42 LFS243 Class Forum
- 19 LFS244 Class Forum
- 4 LFS250-JP クラス フォーラム
- 166 LFS253 Class Forum
- 19 LFS256 Class Forum
- 1.4K LFS258 Class Forum
- 165 LFS261 Class Forum
- 26 LFS267 Class Forum
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 768 Linux Distributions
- 81 Debian
- 67 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 945 Programming and Development
- 310 Kernel Development
- 617 Software Development
- 977 Software
- 369 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)
