From: Nasser M. Abbasi on
Hello,

This is on debian:

# uname -a
Linux me 2.6.26-2-686 #1 SMP Wed May 12 21:56:10 UTC 2010 i686 GNU/
Linux

I am trying Linux again after many years. And trying to remember many
of its commands.

But this one got me really confused.

I copied a directory tree over as a root from another device as root
(the device happened to be a mount disk which has my windows data, so
it was an NTFS disk, but this should have nothing to do with the
following).

Then as a root, I changed the owner of the directory to be a user
called "me".

Also, as root, changed the group id of the folder to the group which
"me" belonged to, which happened to be called "me" also.

So, now the directory and everything in it is owned by "me" and group
"me".

I also changed permission to be u+rw on the directory and everything
in it.

Now, when I am become user "me", I am unable to cd to the directory. I
get permission denied error.
I can cd to the directory as root. but not as user "me".

Any one has an idea? Here are the commands and the results:

me(a)me:~/tmp$ ls -ld HW1/
drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1/

me(a)me:~/tmp$ whoami
me

me(a)me:~/tmp$ id
uid=1000(me) gid=1000(me) groups=20(dialout),24(cdrom),25(floppy),
29(audio),44(video),46(plugdev),110(netdev),115(powerdev),1000(me)

me(a)me:~/tmp$ ls -l HW1
ls: cannot access HW1/post.bat: Permission denied
ls: cannot access HW1/build.bat: Permission denied
ls: cannot access HW1/ee420_hw1.bak: Permission denied
total 0
-????????? ? ? ? ? ? build.bat
d????????? ? ? ? ? ? ee420_hw1
-????????? ? ? ? ? ? ee420_hw1.aux
me(a)me:~/tmp$


Now I change to root, and cd, and it works:

me(a)me:~/tmp$ su
Password:

me:/home/me/tmp# ls -ld HW1
drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1

me:/home/me/tmp# cd HW1

me:/home/me/tmp/HW1# ls -l
total 632
-rw----rw- 1 me me 31 2010-05-26 21:57 build.bat
drwx---rw- 2 me me 12288 2010-05-26 21:58 ee420_hw1
-rw----rw- 1 me me 669 2010-05-26 21:58 ee420_hw1.aux


I must be doing something silly, but do not see it now. Any ideas?

thanks
--Nasser

From: Nasser M. Abbasi on
On May 26, 10:48 pm, "Nasser M. Abbasi" <n...(a)12000.org> wrote:
> Hello,
>
> This is on debian:
>
> # uname -a
> Linux me 2.6.26-2-686 #1 SMP Wed May 12 21:56:10 UTC 2010 i686 GNU/
> Linux
>
> I am trying Linux again after many years. And trying to remember many
> of its commands.
>
> But this one got me really confused.
>
> I copied a directory tree over as a root from another device as root
> (the device happened to be a mount disk which has my windows data, so
> it was an NTFS disk, but this should have nothing to do with the
> following).
>
> Then as a root, I changed the owner of the directory to be a user
> called "me".
>
> Also, as root, changed the group id of the folder to the group which
> "me" belonged to, which happened to be called "me" also.
>
> So, now the directory and everything in it is owned by "me" and group
> "me".
>
> I also changed permission to be u+rw on the directory and everything
> in it.
>
> Now, when I am become user "me", I am unable to cd to the directory. I
> get permission denied error.
> I can cd to the directory as root. but not as user "me".
>
> Any one has an idea? Here are the commands and the results:
>
> me(a)me:~/tmp$ ls -ld HW1/
> drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1/
>
> me(a)me:~/tmp$ whoami
> me
>
> me(a)me:~/tmp$ id
> uid=1000(me) gid=1000(me) groups=20(dialout),24(cdrom),25(floppy),
> 29(audio),44(video),46(plugdev),110(netdev),115(powerdev),1000(me)
>
> me(a)me:~/tmp$ ls -l HW1
> ls: cannot access HW1/post.bat: Permission denied
> ls: cannot access HW1/build.bat: Permission denied
> ls: cannot access HW1/ee420_hw1.bak: Permission denied
> total 0
> -????????? ? ? ? ?                ? build.bat
> d????????? ? ? ? ?                ? ee420_hw1
> -????????? ? ? ? ?                ? ee420_hw1.aux
> me(a)me:~/tmp$
>
> Now I change to root, and cd, and it works:
>
> me(a)me:~/tmp$ su
> Password:
>
> me:/home/me/tmp# ls -ld HW1
> drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1
>
> me:/home/me/tmp# cd HW1
>
> me:/home/me/tmp/HW1# ls -l
> total 632
> -rw----rw- 1 me me     31 2010-05-26 21:57 build.bat
> drwx---rw- 2 me me  12288 2010-05-26 21:58 ee420_hw1
> -rw----rw- 1 me me    669 2010-05-26 21:58 ee420_hw1.aux
>
> I must be doing something silly, but do not see it now. Any ideas?
>
> thanks
> --Nasser



I found if I apply chmod 777 to the folder (as root), then I can
access the folder as user "me". Which is strange, since the folder is
owned by "me"?


me(a)me:~/tmp$ cd HW1/
bash: cd: HW1/: Permission denied

me(a)me:~/tmp$ su
Password:

me:/home/me/tmp# chmod -R 777 HW1
me:/home/me/tmp# exit
exit

me(a)me:~/tmp$ cd HW1
me(a)me:~/tmp/HW1$ ls -l
total 632
-rwxrwxrwx 1 me me 31 2010-05-26 21:57 build.sh
drwxrwxrwx 2 me me 12288 2010-05-26 22:57 ee420_hw1
-rwxrwxrwx 1 me me 669 2010-05-26 21:58 ee420_hw1.aux
-rwxrwxrwx 1 me me 29201 2010-05-26 21:58 ee420_hw1.bak


Why?

--Nasser
From: Kevin D. Snodgrass on
Nasser M. Abbasi wrote:
> me(a)me:~/tmp$ ls -ld HW1/
> drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1/

[snippage]

> I must be doing something silly, but do not see it now. Any ideas?

chmod 777 HW1

or

chmod 755 HW1

You need "execute" permission to enter a directory, even if you own it.
From: Nasser M. Abbasi on
On May 27, 3:20 am, "Kevin D. Snodgrass" <kdsnodgr...(a)yahoo.com>
wrote:
> Nasser M. Abbasi wrote:
> > me(a)me:~/tmp$ ls -ld HW1/
> > drw-rw-rw- 3 me me 4096 2010-05-26 21:58 HW1/
>
>   [snippage]
>
>  > I must be doing something silly, but do not see it now. Any ideas?
>
> chmod 777 HW1
>
> or
>
> chmod 755 HW1
>
> You need "execute" permission to enter a directory, even if you own it.

Yes, thanks, I was about to make a post that I "discovered" this by
trial and error when I saw your post.

Now, this is what I do after I copy a tree from windows over to linux
to make sure tree is OK for me to use:

cd to root of tree, and type:

find -type d -print0 |xargs -0 chmod 744
find -type f -print0 |xargs -0 chmod 644

The above seems to fix things so I can use the tree now on linux.

--Nasser