Friday, October 15, 2010

The Battle With Solaris Part 2

Ok, so the next fight with Solaris 10 had to do with .profile and ownership of files/directories. This is probably remedial shit for a Unix person but it's new to me.

There was a .sql file I needed to run using sqlplus. When I navigated to the directory where the .sql file was and tried to run the command "sqlplus /nolog @create_me.sql" I received a Command Not Found error in my terminal/shell-window/command prompt/whatever you want to call it. I assume this error is similar to when you try to run a program in DOS that isn't on your PATH.

So the solution I read about was to alter your .profile of the user you're logging in as. Again, similar to Windows Environment Variables. The issue was when I tried to find my .profile file I couldn't see it. It was nowhere to be found in /export/home/myuser.

There was a local.profile file but altering that did nothing beneficial for me. For some reason Solaris hides your .profile file. Don't know why but they do. It's there even if you don't see it. So I VI'd the .profile file, and added ORACLE_BASE, ORACLE_HOME variables, and added in my ORACLE_HOME variable to the existing PATH variable by doing something like:
PATH=$ORACLE_HOME/bin:$PATH; export PATH

This adds ORACLE_HOME to the beginning of the current PATH variable. I assume this is important. I had to re-login for the changes to take effect. Once I logged back in running the env command showed me these new environment variables and their values as well as a bunch of other environment variables that weren't in my file at all. No clue what's going on there.

Sooooo.....

Now I was able to run my sql script using sqlplus. However when I ran it, it was giving me a "Permission Denied" error on a folder I had created. This was because I created the folder using user "root" but had not given access to everyone. So my "myuser" user couldn't utilize it.

There are probably many ways to solve this, but I found there was a command called chown which you can run to change the user who owns it as well as the group access. The command was:
chown -R oracle:oinstall /mydirectoryname

What this does is change the owner of the files and directories in the mydirectoryname folder to oracle, and the group that owns those files/directories to oinstall. The -R (capital) flag says "change ownership for every file/directory in mydirectoryname" vs. chown oracle:oinstall /mydirectoryname which would just alter the owner(ship) of that individual folder. Keep in mind that I had to su - root in order to change the ownership. This makes sense, a lesser privileged user who doesn't own a file shouldn't get giving everyone and their mother ownership to a file. Only the user who created it can.

Alternatively I probably could have read up about chmod and done some sort of chmod a+rwx /mydirectoryname but whatever, I learned something new with chown.

With this fixed I was able to get to a whole different Solaris 10 issue that I'll discuss in Part 3.

No comments:

Post a Comment