Linux install to local directory

Installing a .deb package in home directory

You could build a deb package that installs anywhere. But why would you want to? Packages are supposed to be installed into the system.

@Faheem Mitha — We don’t all have root access to our Unix boxes you know, I certainly don’t where I work. If we need a package (RPM in my case) to use some piece of software, it would be nice if we could install it in user space rather than have to speak to I.T. and get them to install the package on the system for us.

@FaheemMitha Another thing is testing a new version of a package. If I want to make a specific package available to one user only I don’t go on installing it system-wide.

@FaheemMitha Maybe or maybe not 😉 My use case was a development machine with several users serving as development environments. I needed to bump a package to a new version for one specific user only, so that we could test how the new version behaves. But the server is a virtual machine itself, so you’re partly right 😉

3 Answers 3

It depends what you mean by «install». It is possible to extract the file contents of a .deb file using dpkg-deb -x , but whether you can actually use the software after extracting it locally depends on how it is written. A lot of Linux software will be expecting to find its resource files in standard locations specified at compile-time, such as /usr/share or /usr/lib , which will fail if the software is not installed in the usual location. Also any system-wide configuration files installed by the package, such as .desktop files that create entries in the start menu, will not function as intended if installed in the wrong location.

Thanks for all your comments an answers. It was a self-packaged piece of software where I would like to make some basic checks if my packaging was correct. I am root on my computer but wouldn’t like to do a real installation there nor want to use a virtual image for the moment. I came up with this solution: https://serverfault.com/questions/23734/is-there-any-way-to-get-apt-to-install-packages-to-my-home-directory Which perfectly works for me atm.

@Ivogel asks «The page you linked to has many posts, and I can’t tell which one is the solution that worked for you. Could you please specify?»

Note that use of the Debian package system requires root access. So, installing a deb package in a users home directory requires root access. If you have root access, then makes more sense to just install into the system as normal.

If you don’t have root access, you can’t use the Debian packaging system. You could certainly unpack a deb file into its component pieces and stick it in your home directory, but doing so would make little sense imo. I suggest you go with a local install. Depending on what software you are installing,the software may have some sort of internal package management system you can use.

Читайте также:  Linux изменить таблицу разделов

I don’t know if it was added afer this answer was created but dpkg has a —force-non-root option which can be used to get around this.

If you run dpkg —help it mentions —force-thing. If you run dpkg —force-help it gives more details. See for example askubuntu.com/questions/193695/…

@BruceAdams Ok, I see it, but I have no idea how it would work: not-root Try to (de)install things even when not root .

See my question stackoverflow.com/questions/47099045/… However, at the time of writing it doesn’t yet have an answer. So I have no idea either.

Источник

Install application to /usr/local

Some application that installs automatically such as Netbean, JDK often install to /usr/local and I run it by normal user (not root). But another application, just extract tar.gz file and run it. Under normal user, I cannot use cp command to copy from Download directory to /usr/local directory, I must use root user ( su command). But because I copy by root user this directory belongs to root, so I cannot run it under normal user. It makes my headache. How can I run it under normal user, as other application that I list above. Or, is there another way to install it?

2 Answers 2

/usr/local and its subdirectories ( bin , lib , share , etc) should be (and likely are) owned root and set 755 so that anyone can execute stuff there.

If you unpacked something and copied it in, then it could be the permissions on the individual binaries, which should also be 755 to allow general use.

Keep in mind how $PATH works. Your example of the JDK may be confusing in this regard, but a normal tarball that you ./configure & make install will put executables in /usr/local/bin , libraries in /usr/local/lib , and miscellaneous things like documentation somewhere in /usr/local/share . Those are the appropriate paths, and you need to follow the same pattern. In other words, just putting stuff anywhere in /usr/local (such as an individual directory for the package) or subdirectories of bin/ will not work.

There are two potential issues you may be getting tripped up by.

First issue — execute permissions for directories

The permissions on one of the directories you copied into /usr/local may not have the permissions set correctly. The permissions on the directories needs to be such that users other than root, can execute the programs/scripts out of these directories.

The permissions on the directory probably need to be set so that «other» users are able to execute applications out of this directory.

For example

# don't have permissions on directory root$ cd /usr/local $ ls -ld somedir drwxr-x--- 2 root root 4096 Apr 25 13:27 somedir # have permissions on the script root$ ls -l somedir/testscript.bash -rwxr-xr-x 1 root root 23 Apr 25 13:27 somedir/testscript.bash 

In this scenario even though other users have execute permissions on the script to both read & execute it, they won’t be allowed due to the fact they don’t have read & execute on the directory the script is in.

Changing the permissions on the directory allows them access:

 user$ ls -ld somedir/ drwxr-xr-x 2 root root 4096 Apr 25 13:27 somedir/ user$ somedir/testscript.bash hi 

This entire issue can be resolved by changing the permissions in the directory being unpacked from the tar.gz file by finding all the directories that have scripts and running the command chmod +rx against these directories.

Читайте также:  Ошибка виртуал бокс линукс

Second issue — execute permissions for files

The permissions on the files from the .tar.gz file may not have been set prior, so applications or scripts in the archive would’ve been unpacked missing these. Simply chmod +x will resolve this issue on files that have this particular problem.

### For example user$ ls -ld somedir drwxr-xr-x 2 root root 4096 Apr 25 13:27 somedir/ user$ ls -l somedir/testscript.bash -rw-r--r-- 1 root root 23 Apr 25 13:27 somedir/testscript.bash user$ somedir/testscript.bash bash: somedir/testscript.bash: Permission denied 

Источник

Installing files in ~/.local

I don’t like either of these, and thought that since there is already a ~/.local subdirectory, why not install there? It already contains a ~/.local/share, which has come to mean a local user’s private /usr/share, so it would seem very logical to install programs, creating the whole ~/.local/bin, ~/.local/lib etc.

My question is: Is it ok to install local software in ~/.local?

Why don’t I find any references to this when I search google or stackexchange for places to install per-user software? To me it seems like such an obvious location that the lack of posts suggesting it means there must be a catch somewhere.

Perhaps someone who has done this can share their experience, be it positive or negative?

I couldn’t find any reference to ~/.local in the FHS — just /usr/local, (pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY)

Be careful that ~/.local/share is used for per-user application data. Why not create a ~/.usr and install things there!

4 Answers 4

Remember, it’s your home directory; you can do anything you want in there. GNOME/KDE/whatever might complain if you go around deleting .config, but anything you do in your home directory will, by definition, only affect you. Adding some directories in .local is harmless.

Putting something in a dot directory will be mildly inconvenient, depending on your workflow. How much it will affect you depends on how you navigate the filesystem and how often you’ll need to do it. If it was me, I’d make a regular directory to act as a root (probably call it local or apps) and use it that way, but that’s personal preference.

Where you’ll run into problems is that the system isn’t set up to see your directory. You’ll need to adjust PATH, MANPATH, INFOPATH, and LD_LIBRARY_PATH in your .bashrc (or whatever is appropriate for your shell). There will likely be other small «gotchas» as well.

I’m willing to be that there aren’t many posts here about it because not many people need to do it. If it’s a personal machine, there are few reasons not to use /usr/local. Everything’s already set up for it in most distributions. If you’re just installing a few apps, a lot of people make directories in /opt (like /opt/blender). Solaris does this when you install a package.

The only real use case for what you’re describing is for developers or people who don’t have root on their machine. Most people who don’t have root just ask the admin to install a program for them — they probably wouldn’t know how to compile a program anyway.

Читайте также:  Canon dr m140 драйвер linux

Источник

How to install python modules in a local directory? —user and exporting pythonpath isn’t working

I don’t know very much about python but would like to install some python modules in a local directory on a server on which I don’t have sudo access. I start by going into my desired directory (not root) and create the directory tree needed to store my custom modules

cd /root/example/sub-example mkdir -p local/lib/python2.7/site-packages 
export PYTHONPATH=$PYTHONPATH:/root/example/sub-example/local/lib/python2.7/site-packages 
mkdir example-python-directory cd example-python-directory wget http://example-python-package tar -xvf example-python-package.tar.gz cd example-python-package 

Last, I run the setup.py script with the —user flag to try to get it to install in my specified /local directory

python setup.py install --user 

The problem is, nothing is installed in my /root/example/sub-example/local/lib/python2.7/site-packages directory, and instead I find that I now have a new directory at root: /root/.local/lib/python2.7/site-packages Is there a way to prevent this? I feel like my lack of Python knowledge is causing me to make some silly error that is probably obvious to others. Thanks for the help!

3 Answers 3

create a folder called «lib»

For Python 3

For Python 2

CFLAGS=-I$(brew —prefix)/include LDFLAGS=-L$(brew —prefix)/lib pip install

I found that on servers where you haven’t root access to, you can usually install the python module into your .brew/lib using this.

virtualenv is what I would recommend for this case (and pretty much any other case). I use it for pretty much everything I do in Python.

It allows you to essentially create a sandbox containing a Python environment that is bootstrapped from a Python install on your machine, and to install any modules you want into it.

It should not, in general, require the use of sudo, since you’re not touching the system install. You can generally pip install a module right into the virtualenv, and then you run your scripts out of that virtualenv. You would basically just need a location you can read/write/execute from, say a directory you create in your user’s home directory.

You can keep track of what’s installed by doing a pip freeze > requirements and checking that into an SCM, and then a new virtualenv can be recreated using that file, ready to run your scripts.

The link I provided above has more details about how to use virtualenv.

Edit in response to comment from OP:

You can still use pip install outside of virtualenv, and I would recommend that. However, that can only operate on various Python installs that may be on the box (invoke pip from the bin directory of the install you want to use).

However, that won’t work for installation into arbitrary directories. For that, you could try to unzip the egg file (they are supposed to be zip files) into the directory you want, and then make sure that directory is on the PYTHONPATH . Some egg files are available for direct download off of PyPI, although some are source only.

I think is approach is much more complex and prone to problems than virtualenv would be, though.

Источник

Оцените статью
Adblock
detector