Results 1 to 9 of 9

Thread: LS command gives error "permission denied". HELP!

  1. #1
    Join Date
    Jan 2021
    Beans
    1

    LS command gives error "permission denied". HELP!

    Hey guys,
    I’m a new linux user and learning ubuntu CLI. I’m trying to use ‘ls’ command to test the user & groups things.
    so I have main user ‘beekay’ and other 2 new ones as mentioned in the text below. both can use the ls for /home/username directories howver beekay can’t
    please help. below are the groups, ownerships for the folders. only problem with user beekay is that it can’t ls into /home/felipe.
    Code:
    beekay@beekay-Ubuntu-20:~$ ls /home/yogi_v/
    beekay@beekay-Ubuntu-20:~$ su - felipe 
    Password: 
    felipe@beekay-Ubuntu-20:~$ ls /home/yogi_v/
    felipe@beekay-Ubuntu-20:~$ ls /home/beekay/
    Desktop    Downloads  notes.txt  Public  Templates
    Documents  Music      Pictures   snap    Videos
    felipe@beekay-Ubuntu-20:~$ logout
    beekay@beekay-Ubuntu-20:~$ ls /home/yogi_v/
    beekay@beekay-Ubuntu-20:~$ ls
    Desktop    Downloads  notes.txt  Public  Templates
    Documents  Music      Pictures   snap    Videos
    beekay@beekay-Ubuntu-20:~$ ls /home/
    beekay  felipe  yogi_v
    beekay@beekay-Ubuntu-20:~$ ls /home/felipe/
    ls: cannot open directory '/home/felipe/': Permission denied
    beekay@beekay-Ubuntu-20:~$ ls -ld /home/felipe/
    drwxr-x--- 2 root student 4096 jaan  24 20:50 /home/felipe/
    beekay@beekay-Ubuntu-20:~$ 
    beekay@beekay-Ubuntu-20:~$ ls -ld /home/felipe/
    drwxr-x--- 2 root student 4096 jaan  24 20:50 /home/felipe/
    beekay@beekay-Ubuntu-20:~$ ls -ld /home/yogi_v/
    drwxr-xr-x 2 root student 4096 jaan  24 20:53 /home/yogi_v/
    beekay@beekay-Ubuntu-20:~$ ls -ld /home/beekay/
    drwxr-xr-x 17 beekay beekay 4096 jaan  24 02:00 /home/beekay/
    beekay@beekay-Ubuntu-20:~$ id beekay 
    uid=1000(beekay) gid=1000(beekay) groups=1000(beekay),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),1001(student)
    beekay@beekay-Ubuntu-20:~$ id felipe 
    uid=1001(felipe) gid=1002(felipe) groups=1002(felipe),1001(student)
    beekay@beekay-Ubuntu-20:~$ id yogi_v 
    uid=1002(yogi_v) gid=1003(yogi_v) groups=1003(yogi_v),1001(student)
    beekay@beekay-Ubuntu-20:~$ su - yogi_v 
    Password: 
    yogi_v@beekay-Ubuntu-20:~$ ls /home/felipe/
    yogi_v@beekay-Ubuntu-20:~$ ls /home/beekay/
    Desktop  Documents  Downloads  Music  notes.txt  Pictures  Public  snap  Templates  Videos
    yogi_v@beekay-Ubuntu-20:~$ logout
    beekay@beekay-Ubuntu-20:~$ su - felipe 
    Password: 
    felipe@beekay-Ubuntu-20:~$ ls /home/yogi_v/
    felipe@beekay-Ubuntu-20:~$ ls /home/beekay/
    Desktop  Documents  Downloads  Music  notes.txt  Pictures  Public  snap  Templates  Videos
    felipe@beekay-Ubuntu-20:~$ logout
    beekay@beekay-Ubuntu-20:~$ ls /home/yogi_v/
    beekay@beekay-Ubuntu-20:~$ ls /home/felipe/
    ls: cannot open directory '/home/felipe/': Permission denied
    beekay@beekay-Ubuntu-20:~$
    Last edited by deadflowr; January 25th, 2021 at 06:10 PM. Reason: code tags

  2. #2
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    650
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: LS command gives error "permission denied". HELP!

    The first thing you need to get a grip on is to not use su - "user".
    It doesn't really change the user, but kind of pretends to by setting some environment variables. man su discourages the use of "su -" probably for good reasons
    You can get temporary higher privileges by using sudo before a command.

    That being said, you're all members of gid=1001(student), so ls not working is strange.
    Last edited by ml9104; January 24th, 2021 at 10:54 PM.

  3. #3
    Join Date
    Jan 2021
    Beans
    5

    Re: LS command gives error "permission denied". HELP!

    This happened because beekay does not belong to the same group as felipe. beekay is therefore treated as others, and others do not have the permission to read /home/felipe/

    solution: change permission by typing
    Code:
    sudo chmod 755 /home/felipe/
    then enter the root password.

  4. #4
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    650
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: LS command gives error "permission denied". HELP!

    "This happened because beekay does not belong to the same group as felipe. beekay is therefore treated as others, and others do not have the permission to read /home/felipe/

    solution: change permission by typing
    Code:
    sudo chmod 755 /home/felipe/

    then enter the root password."

    Huh? All three are members of 1001(student)

    My suspicion leans more towards the misspelling of "sambasha re" in the beekay group listing. If beekay's been fiddling around with the groups and accidentally inserted a space in "sambashare", this might result in the read failure of the 1001(student) group.





    Last edited by ml9104; January 24th, 2021 at 10:38 PM.

  5. #5
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: LS command gives error "permission denied". HELP!

    Changing permissions on the top level of a user's home directory so that another user can gain access -- even read only access -- is profoundly bad advice.

    Leave the permissions alone.
    Last edited by QIII; January 25th, 2021 at 01:17 AM.
    Please read The Forum Rules and The Forum Posting Guidelines

    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: LS command gives error "permission denied". HELP!

    Quote Originally Posted by ml9104 View Post
    The first thing you need to get a grip on is to not use su - "user".
    It doesn't really change the user, but kind of pretends to by setting some environment variables. man su discourages the use of "su -" probably for good reasons
    You can get temporary higher privileges by using sudo before a command.

    That being said, you're all members of gid=1001(student), so ls not working is strange.
    News to me. Please explain.

    su - username **is** preferred to my knowledge, as it causes a login to the other userid which sets the environment of that account. From the manpage:
    Code:
           -, -l, --login
               Provide an environment similar to what the user would expect had
               the user logged in directly.
    
               When - is used, it must be specified before any username. For
               portability it is recommended to use it as last option, before any
               username. The other forms (-l and --login) do not have this
               restriction.
    However, using it to change to the root account would NOT be preferred on ubuntu systems, but that is a different use case.

    Or did I misunderstand?

    For the OP, I'd use 3 different terminals, one for each userid, and show the ls -alF for the directories involved, including the parent. Parent directories control access inside and to all child object inside. A little whitespace would help readability too. I didn't look too hard are the wall of text. Sorry.

    Whenever permissions aren't working as expected, it is always something like ACLs or SELinux in the way, IME.

  7. #7
    Join Date
    Jan 2021
    Beans
    5

    Re: LS command gives error "permission denied". HELP!

    Sorry I missed the fact that beekay and filipe shared a group. That means my earlier answer is wrong.
    Last edited by youngwarlock; January 25th, 2021 at 04:29 PM.

  8. #8
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    650
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: LS command gives error "permission denied". HELP!

    Quote Originally Posted by TheFu View Post
    However, using it to change to the root account would NOT be preferred on ubuntu systems, but that is a different use case.

    Or did I misunderstand?
    No, I misunderstood. I read the codeblock as su to root, which is wrong. Sorry.

  9. #9
    Join Date
    May 2011
    Beans
    23
    Distro
    Ubuntu Mate 20.04 Focal Fossa

    Re: LS command gives error "permission denied". HELP!

    Quote Originally Posted by beekayverma View Post
    I’m a new linux user and learning ubuntu CLI. I’m trying to use ‘ls’ command to test the user & groups things.
    so I have main user ‘beekay’ and other 2 new ones as mentioned in the text below. both can use the ls for /home/username directories howver beekay can’t
    please help. below are the groups, ownerships for the folders. only problem with user beekay is that it can’t ls into /home/felipe.
    ...

    NVM, I just noticed the bottom part of your example...

    The issue looks like it's just that felipe doesn't have read access for everybody, while the other two users do. Having read access for all is usually not good practice, but I assume you have good reasons...
    Last edited by New_buntu_89; 4 Weeks Ago at 10:02 PM. Reason: Misread the first post

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •