Question about ls -l

Good afternoon, I hope that someone can make a suggestion or two as what my issues are and how to solve them, or suggest the correct group to post the questions to.

I have successfully installed Oracle Solaris 11.1 (x86/64-bit) installation on Oracle VirtualBox. Now, I would like to install Oracle 11gR2 in my Oracle Solaris 11.1 environment. At the moment, I am completing the pre-installation instructions. Having signed on as the root user, I created the oracle user and the oinstall group. Further on, the instructions call for the creation of two directories, /u01/app/oracle and /u02/oradata, which I created without error, both directories being owned by root. Next, the instructions call for changing the owner and group to the oracle user and the oinstall group, as follows:

# chown -R oracle:oinstall /u01/app/oracle
# chown -R oracle:oinstall /u02/oradata

My specific issue is that after performing the chown command, I do an ls -l and see that the two directories appear to be still owned by root (the group is root as well). Even though I am performing the chown command as root, the chown command does not appear to change the owner and group of the two directories to oracle:oinstall

After a suggestion was made to me to execute an ls -ld (as root) on the root directory, I got the following results:

root@solaris://>ls -ld /u01/app/oracle /u02/oradata
drwxrwxr-x 2 oracle oinstall 2 Feb 21 05:36 /u01/app/oracle
drwxrwxr-x 2 oracle oinstall 2 Feb 21 05:36 /u02/oradata

I was surprised to say the least, as when I executed an ls -l from the root directory as root, I got the following results:

root@solaris://>ls -l
total 1042
lrwxrwxrwx 1 root root 9 Oct 4 23:41 bin -> ./usr/bin
drwxr-xr-x 5 root sys 8 Oct 4 23:41 boot
drwxr-xr-x 2 root root 5 Oct 5 00:33 cdrom
drwxr-xr-x 254 root sys 257 Feb 21 12:39 dev
.
.
.
drwxr-xr-x 3 root root 3 Feb 21 05:36 u01
drwxr-xr-x 3 root root 3 Feb 21 05:36 u02

I exited from the root role and back to my user account, and then executed an ls -ld from the root directory and got the same results as above, showing the oracle and oinstall as the owner and group, respectively. I then executed an ls -l from the root directory and the results showed root and root as the owner and group. Can anyone enlighten me on what the difference is between ls -l and ls -ld that would show the owner/group for ls -l as root:root and the owner/group for ls -ld as oracle:oinstall ? Is there any way to tell whether root:root is the owner:group of the two directories or is oracle:oinstall the owner:group of the two directories?

I appreciate any suggestions that one can make, many thanks in advance for your assistance.

1 Like

The ls -l is showing you the information about the contents of the directory, ls -ld shows you information about the directory itself.
Play around with it on some other directories that have subdirectoires and you see what I mean.

1 Like

Try doing a:

ls -l /u01/app /u02

Code tags aside, that is a well written question, BTW..

1 Like

There should be no cause for surprise. If you ask chown to recursively change the ownership of a directory, /a/b/c, chown will change the ownership of that named directory and any files and directories below it, such as /a/b/c/d and a/b/c/d/e. It will not change the ownership of files or directories above /a/b/c, such as /a and /a/b.

What you've demonstrated above is equivalent to using chown on /a/b/c and then using ls to inspect the ownership of /a. /a will not be affected.

Regards,
Alister

1 Like

I think your problem is more one of understanding, not of not achieving what you want to do. I have quoted the relevant part:

The command "ls" shows information about files and/or directories. That means, your first command showed information about two directories you specified as arguments to the command: /u01/app/oracle and /u02/oradata .

In the second line you specified no such operand. In this case "ls" implies the current directory (also called PWD) as operand. As suggested by your prompt this was probably / and by issuing "ls" without any argument you did effectively this:

root@solaris://>ls -l /

Of course, / has different ownerships than /u01/app/oracle and /u02/oradata , but this is to be expected.

To confirm this, try the following:

root@solaris://>cd /u01/app/oracle
root@solaris:/u01/app/oracle/> ls -ld

and you will see the corresponding output to ls -ld /u01/app/oracle (similar for the other directory). The reason is simply that by changing your current directory with the "cd" (change directory) command first you changed the default value for "ls" in absence of any directory name provided on the command line.

I hope this helps.

bakunin

1 Like

Hi Alister, Bakunin: thanks very much for your replies. As I read each reply, the light went on and I totally agree with what each of you said.

Alister, allow me to summarize your answer and how I was able to solve my problem. Assuming I have logged in and su - root, and have cd to the root directory, I execute the chown -R oracle:oinstall on /u01/app/oracle. This in effect is the same as the example in your answer, to chown -R /a/b/c. What I have in fact requested is to recursively change the owner & group on on directory "c" and below, i.e. changing the owner & group for the "oracle" directory. However, this leaves root root as the owner & group of the u01 and app directories. What I really wanted to achieve is to change the owner & group of the u01, app, and oracle directories to oracle:oinstall. To do this, I executed the chown -R u01 and and low & behold, after executing an ls -l, the owner & group of u01 is now oracle:oinstall. I have done the same for the u02 directory.

Again, I appreciate the time you took to read my question and summarize what was a lack of understanding on my part. Thanks very much!

Happy to help. You're very welcome.

Regards,
Alister