LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   unable to create directory under /opt (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-create-directory-under-opt-916409/)

suddublr 11-30-2011 12:21 PM

unable to create directory under /opt
 
Dear Members,

On linux, as non-root[oracle] user am not able to create directory under /opt. It says Permission denied. But I understand /opt should not be specific to root, since the application installed as non-root gets installed under /opt.

any idea as how to create directory under /opt ?

cheers
Sud

corp769 11-30-2011 12:26 PM

Hello,

Because opt is located in / itself, it is owned by root. So technically saying, yes, /opt IS specific to root. Now what you can do is create a directory as root within opt, then change the ownership and permission of that newly created directory, and voila, there you go.

Cheers,

Josh

suddublr 11-30-2011 01:26 PM

Thank you. The step suggested by you will work and will be sort of work around. I have observed that on other linux system I could see many directories under /opt which does not belong to root. Is it something to do with user account ?.

corp769 11-30-2011 01:37 PM

More of the permissions and ownership; Look at the following:
Code:

/
/opt/
/home/
.
.
.
etc...

You see, / is at the very top level of your directory structure. Since opt is located within the top level, it is owned by root. Of course, you could change the ownership and permissions of /opt itself, and you can do what you need to do. This, however, is technically a security issue, since you are allowing X users FULL permission of opt.

suddublr 11-30-2011 01:53 PM

Ok. Thank you. But I guess there wont be serious security breach if permission is given to /opt since system specific files are not present under /opt.

corp769 11-30-2011 01:58 PM

True, but it's the thought. I would never do that, regardless if files were to be compromised or not.

brucegraham 12-02-2011 09:50 AM

You could also set the sticky bit, e.g. 'chmod 1777 /opt', similar to how the '/tmp' directory is configured. That way anyone can create files and directories there but only the owner of files and directories under '/opt' can delete or rename them.

traceman 12-02-2011 10:11 AM

Re: Unable to create directory under /opt
 
I’ve had to do something similar with various applications. If you want to create a usable directory in /opt
that user oracle can access and still maintain the permission/security integrity of /opt, do the following:

oracle$ su – # become root

# cd /opt
# mkdir oradir # hypothetical directory name
# chown –R oracle:oracle oradir # make user oracle the owner
# ls –la
-rwx-r—r-- oracle oracle oradir

# exit # get out of root

oracle$ cd /home/oracle # cd to whatever directory to create a link (optional) but suggested
oracle$ ln –s /opt/oradir oradir # create a link as the user needing access to the directory



It’s worked for me pretty well. The good thing is that you don’t have to compromise the permissions for the entire /opt
directory, just the directory within /opt that you need to access.


All times are GMT -5. The time now is 01:30 PM.