2

I have started using Linux recently for development of a project and currently facing some issues with file permissions in the directories.

I have some libraries .so files that I need to access from the folder /usr/local/lib. When I check the files manually in the folder, the files show that I am not the owner and root is the owner.

However, in a different directory, where I subsequently tried installing the same libraries at /home/jade/cb/lib/, if I check the libraries, I do have the permission.

My C++ program has been stuck since it cannot access the libraries from these. I tried changing the permissions using sudo chmod 777 -R *.* while inside usr/local/lib but the permissions or anything don't change. How do I get rid of this problem? (Distro: Ubuntu 12.10)

2
  • have you tried strace ?, if possible post errors/screen shots you are facing. Dec 25, 2012 at 16:28
  • 2
    chmod 777 is very high in the top-10 of worst Unix practices ever. Especially in combination with -R. Your files can loose vital properties (like s-bits) and everybody can change the files and directories. You do not want that.
    – jippie
    Dec 25, 2012 at 20:10

2 Answers 2

2

Most source that requires you to build it makes use of a configure script. This configure script takes a switch called --prefix that takes an argument which you can override the location of where the software will be installed. Usually you override the default location (usually /usr/local) with a directory that you have write access to.

Here's a example from the software application node.js. The node.js software when downloaded and untarred/unzipped looks like this:

[saml@grinchy node-v0.8.12]$ ls
AUTHORS    BSDmakefile  common.gypi  config.mk  deps  lib      Makefile  node.gyp  README.md  test   vcbuild.bat
benchmark  ChangeLog    config.gypi  configure  doc   LICENSE  node      out       src        tools

Running the configure script included looks like this:

[saml@grinchy node-v0.8.12]$ ./configure --help
Usage: configure [options]

Options:
  -h, --help            show this help message and exit
  --debug               Also build debug build
  --prefix=PREFIX       Select the install prefix (defaults to /usr/local)
  --without-npm         Don't install the bundled npm package manager
  --without-waf         Don't install node-waf
  --without-ssl         Build without SSL
  --without-snapshot    Build without snapshotting V8 libraries. You might
                        want to set this for cross-compiling. [Default: False]
...
...

If I want to change the default location I can call configure like so:

[saml@grinchy node-v0.8.12]$ ./configure --prefix=/home/saml/my_node.js

The resulting Makefile that get's generated will now target my directory instead of the default, /usr/local.

2
  • And then I should change the directory in my programming to the new one where I do have these permissons? Is that what you meant here?
    – Cipher
    Dec 25, 2012 at 17:02
  • Correct. You'd didn't specify enough for me to answer more than what I provided. For example, when you call gcc/g++ you'll need to include -L <path we gave config> so that it knows where to find these libraries. Also are you compiling statically or dynamically against these libraries? If you provide us this info I can provide further details.
    – slm
    Dec 26, 2012 at 1:11
2

man chmod:

chmod never changes the permissions of symbolic links; the chmod system call cannot change their permissions. This is not a problem since the permissions of symbolic links are never used.
However, for each symbolic link listed on the command line, chmod changes the permissions of the
pointed-to file. In contrast, chmod ignores symbolic links encountered during recursive directory traversals.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .