Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Safe to copy source built binaries to /usr/bin?

  1. #1
    Join Date
    Apr 2020
    Location
    where the work takes me
    Beans
    93
    Distro
    Ubuntu 18.04 Bionic Beaver

    Safe to copy source built binaries to /usr/bin?

    Hello all,

    Is it safe to copy binaries built from source to /usr/bin so they can be called without needing the full file-path?

    I know it sounds like a dumb question but I know sometimes seemingly harmless stuff can be less than ideal for 'special Linux reasons' that nobody would ever just think of off of the top of their head.

    Thanks

  2. #2
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!

    Re: Safe to copy source built binaries to /usr/bin?

    Simpler, and maybe safer, depending on what they are, to copy them to ~/bin in your home which is automatically added to $PATH if it exists.
    Last edited by ajgreeny; June 6th, 2020 at 08:28 PM. Reason: Incorrect pathway corrected
    DISTRO: Xubuntu 20.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo --- Wireless-Info --- SolvedThreads

  3. #3
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    15,069
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: Safe to copy source built binaries to /usr/bin?

    I follow the standard of most source code which is to put everything under /usr/local. /usr/local/sbin and /usr/local/bin are in the default path set by Ubuntu, and ldconfig is already set up to look in /usr/local/lib. Oftentimes configuration files will then end up in /usr/local/etc.

    Usually "sudo make install" will use /usr/local unless you chose something else during the ./configure stage.

    If you're talking about binaries for which you don't have source and did not run the usual "./configure; make; make install" then whether you can copy those binaries directly is more iffy. Unless the binary is "statically-compiled" it will depend on files in places like /lib and /usr/lib that you may not have. I would rely on the repositories for any file that ships with Ubuntu, for instance, using the repository version of Firefox rather than the binary on its site. I only compile software when it doesn't exist in a repository, or the repository version lacks features I desire.
    Last edited by SeijiSensei; June 5th, 2020 at 11:26 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  4. #4
    Join Date
    May 2010
    Beans
    367

    Re: Safe to copy source built binaries to /usr/bin?

    Or /opt
    The package system will blindly overwrite files it finds with new ones during updating. You could make a deb if your efforts which will make packages not be able to overwrite files as it will be seen as part of a different package (an overlap) and stop.
    Using /opt and adding the directory to $PATH avoids all of this and makes things easier

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    20,270
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Safe to copy source built binaries to /usr/bin?

    Good question. If you aren't around Unix people all the time, lots of these questions exist that take nothing to know, but there are subtle reasons for specific answers. A 2 minute chat can clear up this stuff easily. There are thousands of similar types of questions.

    For commonly used tools, typically F/LOSS, I'd go with /usr/local/ method if they need to be available for everyone on the system. Just be certain you add /usr/local/ to your backups.

    For tools that are only for me, I put them into ~/bin/ which I have added to the PATH in my ~/.bashrc.

    For commercial tools or complex packages made up of many different, tightly coupled programs that are provided as binary installs, not with source, I place those into /opt/. Think of something like Zimbra and a complex apache+tomcat+jetty+mariaDB service. In theory, zimbra parts can be replaced, but in practice, the 15 different F/LOSS programs involved are tightly coupled.

    For most things on a Unix system, there are long-standing reasons for why things are the way they are. Some really brilliant people worked on these solutions decades before us. When something doesn't make sense, there is probably a good reason that we just don't know yet.

    If you haven't been told about this book http://linuxcommand.org/tlcl.php is is worth skimming. Stop where something grabs your interest and go deeper. It is a "what" book, not a "why" book. Most books aren't good at the "why" - that's where a mentor or LUG can help.

  6. #6
    Join Date
    Apr 2020
    Location
    where the work takes me
    Beans
    93
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Safe to copy source built binaries to /usr/bin?

    Hi there,

    There isn't a ~/bin on my system by default, I tried adding it but binaries stored in there can't be called using only their name. I'm sure I could fix that but I'm keen to try and keep things consolidated instead of spreading files around if I cam help it.

    Is it really bad practice to use /usr/bin? My other binaries I installed from the package manager are stored there.

  7. #7
    Join Date
    Aug 2013
    Beans
    4,271

    Re: Safe to copy source built binaries to /usr/bin?

    No, just create a new folder called bin in your $HOME (or ~/.local/bin though I prefer it not be hidden) and put your bin file there. Logout and login (since the folder didn't exist before) then it will be in your $PATH.

    You don't want to corrupt your file system, the other binaries installed by package manager store there but the package manager keeps track of them, it won't keep track of stuffs you put there.

  8. #8
    Join Date
    Apr 2020
    Location
    where the work takes me
    Beans
    93
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Safe to copy source built binaries to /usr/bin?

    Hello!

    I don't actually have a /usr/local/bin, only /usr/local/sbin.

    I only have one other binary that I built from source, a tool called 'jstest-sdl' which automatically installed itself in /usr/bin so I got the impression that was the default location for user installed stuff?

    On your last point yes I haven't been compiling anything that can be had from the repo unless totally necessary, the binary in question is just a tool called 'heimdall-flash' that's basically an open source copy of Samsungs Odin tool for flashing things to Samsung phones. For some reason the repo version is known to not work with some phones (it is an older version so maybe that?) but if one compiles the latest version it works okay. I'd prefer not to self install though as I believe it can sometimes be tricky to remove stuff that has been plonked wherever the makefile decides?

  9. #9
    Join Date
    Aug 2013
    Beans
    4,271

    Re: Safe to copy source built binaries to /usr/bin?

    That's why if you compile from source it is better to use checkinstall (sudo apt install checkinstall) instead of doing make install because that way it creates a .deb then install it so that the package manager can keep track.

  10. #10
    Join Date
    Apr 2020
    Location
    where the work takes me
    Beans
    93
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Safe to copy source built binaries to /usr/bin?

    Ah I need to log out/in! That's the missing piece...

    Will it really corrupt anything though? I understand that the package manager keeps track of all the things installed via itself but will a few intruders cause a problem? (not a rhetorical question I honesty have no idea)

    Edit: also regarding your comment about check install, that sounds very interesting and I'll deffo look into that

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •