- Linux Binary Directories Explained
- Linux Directory Structure explained: /bin folder
- 1./bin folder
- 2./sbin folder
- 3./usr/bin folder
- 4./usr/sbin folder
- 5./path/to/some/bin
- 6./path/to/some/sbin
- Surendra Anne
- Latest posts by Surendra Anne (see all)
- Purpose of Bin Directory [closed]
- 2 Answers 2
- Еще одно мнение о разнице между bin, sbin, usr/bin, usr/sbin
- /bin
- /sbin
- /usr/bin
- /usr/sbin
- /usr/local/bin и /usr/local/sbin
- /home/$USER/bin
Linux Binary Directories Explained
Binaries are files that contain compiled source code (or machine code). Binary files are the files which contain compiled source code (or machine code). They are also called executable files because they can be executed on the computer.
Binary directory contains following directories:
The /bin directory contains binaries for use by all users. The ‘/bin’ directory also contains executable files, Linux commands that are used in single user mode, and common commands that are used by all the users, like cat, cp, cd, ls, etc. According to the FHS the /bin directory should contain /bin/cat and /bin/date (among others). The ‘/bin’ directory doesn’t contain directories.
Other /bin directories
You can find a /bin subdirectory in many other directories. A user named Amy could put her own programs in /home/amy/bin. Some applications, often when installed directly from source will put themselves in /opt. A samba server installation can use /opt/samba/bin to store its binaries.
The /sbin contains binaries to configure the operating system. The ‘/sbin’ directory also contains executable files, but unlike ‘/bin’ it only contains system binaries which require root privilege to perform certain tasks and are helpful for system maintenance purpose. e.g. fsck, root, init, ifconfig, etc. Many of the system binaries require root privilege to perform certain tasks.
The ‘/lib’ directory contains shared libraries which are often used by the ‘/bin’ and ‘/sbin’ directories. It also contains kernel module. These filenames are identable as ld* or lib*.so.*. For example, ld-linux.so.2 and libfuse.so.2.8.6. Below is an example of the partial contents of /lib.
$ ls /lib/libc*
/lib/libc-2.5.so /lib/libcfont.so.0.0.0 /lib/libcom_err.so.2.1
/lib/libcap.so.1 /lib/libcidn-2.5.so /lib/libconsole.so.0
/lib/libcap.so.1.10 /lib/libcidn.so.1 /lib/libconsole.so.0.0.0
/lib/libcfont.so.0 /lib/libcom_err.so.2 /lib/libcrypt-2.5.so
1) /lib/modules: The ‘/lib/modules’ stores kernel modules and has a directory for each installed kernel. Typically, the Linux kernel loads kernel modules from /lib/modules/$kernel-version/. Modules are meant to use extra hardware support without making a new kernel.
2) /lib32 and /lib64: We currently are in a transition between 32-bit and 64-bit systems. During compilation time of libraries, you’ll encounter through the directories named ‘/lib32’ and ‘/lib64’ which will clarify register size to be used. A 64-bit system may have compatibility for 32-bit binary.
The term ‘opt’ is short for optional. Its main purpose is to store optional application software packages. In many cases this is software from outside the distribution repository. Add-on applications from individual vendors should be installed in ‘/opt’. In some systems ‘/opt’ is empty as they may not have any add-on application. A large package can install all its files in /bin, /lib, /etc subdirectories within /opt/$packagename/. If for example the package is called wp, then it installs in /opt/wp, putting binaries in /opt/wp/bin and man pages in /opt/wp/man.
If you need any further help please reach our support department.
Linux Directory Structure explained: /bin folder
This is second post in our Linux directory explanation series. /bin is one more important folder. Bin stands for binary which means an executable file. This folder contains commands or scripts or executable which can be executed to accomplish a task. We have some cousins to this folder as given below along with bin folder.
Let’s start with /bin folder.
1./bin folder
/bin: Stands for binary. This folder contains base executables which are required for minimal system working. These commands are available in runlevel 1 for basic administration. Commands which are available in /bin folder is accessed by every one and can run by every user. This folder contains basic commands such as cat, chmod, chgrp, chown, date, dir, dd, df, ln, mv, echo and zipping tools such as bzip, gzip etc.
2./sbin folder
/sbin: This folder stands for system binaries or super user binaries. This folder contains commands which are required for changing system properties or system level settings such as disk management, network management etc. This folder is accessed some times by normal user but they can not execute any of the commands located in this and what ever commands/scripts located in this folder are run only by root user. If you want to make normal user to run these commands you have to implement SUDO or Powerbroker to give elevated access. Some of the commands available in this folder are chkconfig, dhcpclient, fsck and it’s related commands, ifconfig and it’s related commands, init and it’s related commands, lvm and it’s related commands etc.
3./usr/bin folder
/usr/bin: This folder is similar to /bin. This folder contains normal commands which are an extend set of commands to /bin folder for normal user and not that much essential to run the machine. This folder contains commands such as at, atq, bc, awk, cal, cmp, dig, diff, du, env, find, free, ftp, gcc, groups, id, info iostat, last, lsof, md5sum, nmap, rar, seq, tail, top, vi, unzip, who.
4./usr/sbin folder
/usr/sbin: This folder is similar to /sbin. This folder contain system commands which are an extend set of commands to /sbin folder for root user and not that much essential to run the machine. This folder contain commands such as arp, adduser, cron, cups related commands, grub related commands, kvm, ppp related commands, tcpdump etc.
5./path/to/some/bin
Some times you will see bin folder in other locations such as /usr/local/bin this is the place you can see some of the binaries which are installed on the system locally. Some time you can see a bin folder in /opt which indicates that some binaries are located in this /opt bin folder.
6./path/to/some/sbin
Some times you will see bin folder in other locations such as /usr/local/sbin this is the place you can see some of the binaries which are installed on the system locally and are system related commands. Some time you can see a sbin folder in /opt which indicates that some binaries are located in this /opt/bin folder.
PATH variable is one of the important variable related to this binaries. To know more about PATH variable read our post on path variable.
stay tuned to our next post on /dev folder
Surendra Anne
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container — June 30, 2020
- Anisble: ERROR! unexpected parameter type in action: Fix — June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS — August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) — August 27, 2018
- How to use ohai/chef-shell to get node attributes — July 19, 2018
Purpose of Bin Directory [closed]
Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information.
Could anyone please describe what the purpose of the Bin Directory in Linux is?
I have already had a browse online, but couldn’t find a brief, yet comprehensive, answer.
Try searching Google with the phrase «what is the linux bin directory for». The first hit seems to be pretty clear to me.
First hit is this question. Let’s remember that Google results change with time and by the user, and this is a site for answering questions.
2 Answers 2
Bin is an abbreviation of Binaries. It’s just a directory where a user of an operating system can expect to find applications.
The different directories on a Linux system can be daunting or confusing if you aren’t used to them. There’s a good overview on wikipedia that explains what each standard directory is for.
It contains essential binary files (unlike /usr/bin directory) also for booting. It usually contains the shells like bash and commonly used commands like cp , mv , rm , cat , ls .
Unlike /sbin , the bin directory contains several useful commands that are of use to both the system administrator as well as non-privileged users.
In modern Linux, anyway, the distinction between /bin and /usr/bin is fairly obsolete, though it may hold in some other Unixes. (The original purpose of /bin — to hold enough of a system to boot successfully until you could mount /usr — is now served by initrd/initramfs; many distributions now put all system applications in /usr/bin and make /bin a symlink there.)
Еще одно мнение о разнице между bin, sbin, usr/bin, usr/sbin
Недавно я обнаружил вот такую статью: Разница между bin, sbin, usr/bin, usr/sbin. Хотелось бы поделиться своим взглядом на стандарт.
/bin
Содержит команды, которые могут использоваться как системным администратором, так и пользователями, но которые необходимы, когда не смонтированы никакие другие файловые системы (например, в однопользовательском режиме). Он также может содержать команды, которые косвенно используются скриптами.
Там ожидается присутствие таких команд:
cat, chgrp, chmod, chown, cp, date, dd, df, dmesg, echo, false, hostname, kill, ln, login, ls, mkdir, mknod, more, mount, mv, ps, pwd, rm, rmdir, sed, sh, stty, su, sync, true, umount, uname.
Можно сделать симлинки на /usr, но хотя во времена systemd /usr на отдельном устройстве не встречается, его еще можно встретить на встраиваемой системе, светофоре, кофемолке и PDP-11 обслуживающем важный прибор в одной из лабораторий Академии Наук.
/sbin
Утилиты, используемые для системного администрирования (и другие команды только для root), /sbin содержит двоичные файлы, необходимые для загрузки, восстановления, восстановления и/или восстановления системы в дополнение к двоичным файлам в /bin. Программы, выполняемые после того, как /usr монтируется (когда проблем нет), обычно помещаются в /usr/sbin. Локально установленные программы системного администрирования должны быть помещены в /usr/local/sbin.
fastboot, fasthalt, fdisk, fsck, getty, halt, ifconfig, init, mkfs, mkswap, reboot, route, swapon, swapoff, update.
Один из способов защиты системы от шаловливых рук юзеров — это запрет запуска этих утилит кому-попало, установкой атрибута x.
К тому же, замена /bin и /sbin на копии из архива (одинакового для всех однотипных систем) является быстрым способом починки систем без пакетного менеджера.
/usr/bin
Тут всё просто. Однотипные команды, одинаковые для всех серверов/кофемолок компании. И сам /usr может разворачиваться одинаковым для разных ОС (для /bin и /sbin такое как правило не работает), это архитектурно независимые программы. Может содержать линки на интерпретаторы perl или python, которые лежат в /opt или еще где-то в сети.
/usr/sbin
Тоже самое, что /usr/bin, но для использования только админами.
/usr/local/bin и /usr/local/sbin
Одна из важнейших локаций. В отличие от остального, /usr не может быть одинаковой для всей организации. Тут находятся ОС-зависимые, hardware-зависимые и просто программы, которые не на всех устройствах нужны. При синхронизации /usr на машинах, /usr/local требуется исключать.
/home/$USER/bin
Тут случай аналогичный с /usr/local, только лежат программы специфичные для конкретного пользователя. Можно переносить (или синхронизировать) на другую машину при переезде пользователя. То, что нельзя переносить складывается в /home/$USER/.local/bin. Можно использовать local без точки. /home/$USER/sbin по понятным соображениям отсутствует.
Буду рад исправлениям и дополнениям.