Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin [duplicate]

1

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.

/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin

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...

0 0
2
Created attachment 313644 [details] setup-2.7.1-sbinsanity.patch The attached patch should add /sbin:/usr/sbin:/usr/local/sbin to the end of PATH for all non-root users. The separation between **/bin and **/sbin provides no actual value and confuses everyone using Fedora. The reasoning is described more fully in the Feature page: http://fedoraproject.org/wiki/Features/SbinSanity Created attachment 313649 [details] setup-2.7.1-sbinsanity.patch ( Well, the previous patch didn't do *quite* what I wanted; I got the order of the pathmunge() calls wrong. This new patch fixes that. Ignoring the /usr/kerberos difference (which will require changes to krb5-workstation), the situation is now this for bash: root has: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin non-root: /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin csh puts the paths in a different order, for some reason. In csh.login it has: root has: /sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin...
0 0
3

I googled this and found loads of different confusing ways to add values to e.g. PATH. The options on the command line using export and = only last within that terminal session. The last suggestion in this thread seems simplest to me - and it seems to work. Open /etc/environment as root with a text editor:


Add the desired variable in the text file separated by colon, save, logout, login - and it is permanently and globally changed - if that's what you want. In my case added the AndroidSDK path:


Code: Select all

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/etc/android-sdk/android-studio-ide-135.1641136-linux/bin/
...
0 0
4

On Sun, Feb 04, 2007 at 07:12:13AM -0600, Steve Tornio wrote:

| Gregory Hinton wrote:

|

| >

| >I notice that /usr/local/bin was added to _PATH_STDPATH on 1998/03/31

| >(rev 1.11). Pure speculation but I wonder if, at that time, few or

| >none of the ports installed executables into /usr/local/sbin.

| >

| >At any rate, many ports currently install there and not being able to

| >find them with whereis(1) is annoying at the very least.

| >

| >...GH

| >

| >

|

| So, add it to your path. There's a good chance that an OpenBSD box will

| never see a file installed to /usr/local/sbin, so it makes little sense

| to have it as part of the default PATH.

Please see [1], the default .profile that every user gets when given a
bourne-like shell (sh, ksh, etc). /usr/local/sbin *is* part of the
default path.

The original poster was inquiring why...

0 0
5
Aug 19, 2011

Let's get clear with all bin and sbin folders(from filesystem hierarchy standard):

So the question is: Why there are so many directories and what are the meanings of /usr/sbin, /usr/local/sbin and /usr/local/bin?

Many programs are distributed through archives and we have to build them from source code. Usually they have makefile so it's quite easy. This process involves creating files in usr/local/lib, usr/local/bin... usr/local/whatever without creating specific folders for a given program.

I think it's not right because if we need to remove the program we have to manually delete every of its files if the program's creator didn't take care of it.

Ubuntu Servers :: Mount A USB Drive In Rc.local With /sbin/mount And UUID Instead Of Fstab? General :: Target Filesystem Doesnt Have /sbin/init? General :: Ubuntu Booting :Can't Find /sbin/init? General :: Konqueror Updates To Local Files / Executing Local Binaries? General :: -bash:...
0 0
6
(0015020)
herrold (reporter)
2012-05-04 19:08 upstream does not place content in: /usr/local ...

unless this diverges from upstream, it is as designed

(0015021)
mconigliaro (reporter)
2012-05-04 19:11 OK, but /usr/local/sbin is in root's $PATH. It seems inconsistent. (0015023)
toracat (developer)
2012-05-04 19:48 On my CentOS-6 system:

[root@p64c6 ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@p64c6 ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@p64c6 ~]#
[root@p64c6 ~]# rpm -qf /usr/local/bin
filesystem-2.4.30-3.el6.x86_64
[root@p64c6 ~]# rpm -qf /usr/local/sbin
filesystem-2.4.30-3.el6.x86_64

Both /usr/local/bin and /usr/local/sbin belong to filesystem.

(0015024)
mconigliaro (reporter)
2012-05-04 20:09 ...
0 0
7

The default build system for Ruby in Sublime 3 just tries to invoke ruby "$file", so based on the error message output you posted above, bash can't find ruby and it's not in any of /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin or /bin, which is what your path is specifying (which is surprising because I would have bet on /usr/bin or /usr/local/bin myself; however, none of my linux boxen run Ubuntu so maybe it's special?)

It would seem that you need to add the proper path to the ruby executable to your path so that it can be found, or override the Ruby build system to specify the absolute path to the interpreter.

How are you running the script that actually works from the command line?

If you're running the script just by name (e.g. ./code.rb from a terminal) then the first line is likely a shebang that tells the shell where to find ruby and you can get the path from there. If you run it with the ruby interpreter (e.g. ruby code.rb) and that works,...

0 0
8

If you installed a program (with apt, yum, or compiled it and then installed – or whatever) and then you try to run it.

# gem

but you get the error (even though you know gem exists in one of your PATH directories):

-bash: /usr/bin/gem: No such file or directory

What you need to do to fix this is run (THE SOLUTION)

hash -r

A close look at how this happens by example

What happened is this, lets take a look at example above. Im trying to run “gem” which is a program that comes with “ruby”. First I have installed ruby 1.9.1

apt-get install ruby

And that installed it (ruby, gems, and other executables) to its various directories (such as /usr/bin/). After running ruby I noticed it wasnt new enough (however at this point bash remembered that ruby and gem are all located in /usr/bin and it saved it into its “hash” table – the bash hash table is a list of program names and the locations from where they are run from) However I...

0 0
9

Please refer to the Filesystem Hierarchy Standard (FHS) for Linux for this.

/bin : For binaries usable before the /usr partition is mounted. This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Think of binaries like cat, ls, etc.

/sbin : Same, but for scripts with superuser (root) privileges required.

/usr/bin : Same as first, but for general system-wide binaries.

/usr/sbin : Same as above, but for scripts with superuser (root) privileges required.

if I'm writing my own scripts, where should I add these?

None of the above. You should use /usr/local/bin or /usr/local/sbin for system-wide available scripts. The local path means it's not managed by the system packages (this is an error for Debian/Ubuntu packages).

For user-scoped scripts, use ~/bin (a personal bin folder in your home directory).

The FHS says for /usr/local:

...
0 0
10

Nginx is fantastic as a high performance server that can serve static files very, very quickly with minimal, predictable use of resources. Static files are the CSS, Javascript and boilerplate images that make up the design of a website. As the name suggests, static files tend not to change very often. These days the chances are that they have already been optimised, minified and compressed before being deployed to the web server.

Nginx doesn’t handle requests for scripts like PHP or Python directly, but instead acts a reverse proxy and will pass requests to backend server. We tend to use php-fpm but the backend can be anything, even Apache.

Websites typically have a lot of images uploaded by users that are needed in lots of different variants (thumbnail, crop, large etc.). These user generated images obviously can’t be optimised and resized ahead of time like all the boilerplate images.

One solution is to generate all the different image variants when an image...

0 0
11

Why do you need to type ./ before executing a program?

In the terminal, whenever you type the name of an application, let's say gedit, the terminal will go look in some (pre-defined) directories that contain applications (the binaries of the applications). The names of these directories are contained in a variable called PATH. You can see what's in this variable by executing echo $PATH. See those directories separated by :? Those are the directories that the terminal will go search in, if you just type gedit, nautilus, or a.out. As you can see, the path of your a.out program is not there. When you do ./a.out, you're telling the terminal "look in the current directory, and run a.out, and don't go look in PATH.

Solution 1

If you don't want to type ./ every time, you'll need to add a.out's directory in $PATH. In the following instructions, I'll assume that the path to a.out is /path/to/programs/, but you should change it to your actual path.

Simply...

0 0
12
This is a collection of some of the more frequently asked questions about Busybox. Some of the questions even have answers. If you have additions/corrections to this document, we would love to add them.

General questions

What is Busybox? How can I get started using Busybox? How do I configure Busybox? How do I build Busybox with a cross-compiler? How do I build a Busybox-based system? Which Linux kernel versions are supported? Which architectures does Busybox run on? Which C libraries are supported? Where can I find other small utilities since Busybox does not include the features I want? I demand that you to add right now! How come you don't answer all my questions on the mailing list instantly? I demand that you help me with all of my problems Right Now! I need help with Busybox! What should I do? I need you to add ! Are the Busybox developers willing to be paid in order to fix bugs or add in ? Are you willing to provide support contracts? Can I include Busybox as part of...
0 0