doubleudee1
Posts: 164
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

user pi refused command without using 'sudo' before command?

Sun Aug 25, 2019 9:58 am

I don't know what I've done wrong but I seem to have lost permissions for user 'pi' to remove a file or folder without using 'sudo' before the command.
From root I run ls and get a listing (as I should - see below), and running ls -lr it lists permissions for all, I'm the sole user and thought 'pi' was king of the castle, so why do I need to use 'sudo' before some commands?
How do I make pi fing of the catle who controls all? as i am the only user and log in as 'pi' everytime I thought I would be?
I thought it would be some combination of 'chgmod pi:pi' but can't work it out?

pi@raspberrypi:/ $ ls
bin boot.bak dev home lost+found mnt proc run srv tmp var
boot CreateDirsCopy etc lib media opt root sbin sys usr
pi@raspberrypi:/ $ ls -lr
total 79
drwxr-xr-x 12 root root 4096 Jan 20 2019 var
drwxr-xr-x 11 root root 4096 Nov 13 2018 usr
drwxrwxrwt 13 root root 4096 Aug 25 10:39 tmp
dr-xr-xr-x 12 root root 0 Jan 1 1970 sys
drwxr-xr-x 2 root root 4096 Nov 13 2018 srv
drwxr-xr-x 2 root root 4096 Apr 9 16:33 sbin
drwxr-xr-x 31 root root 980 Aug 25 09:10 run
drwx------ 6 root root 4096 Aug 13 09:39 root
dr-xr-xr-x 174 root root 0 Jan 1 1970 proc
drwxr-xr-x 7 root root 4096 Nov 13 2018 opt
drwxrwxrwx 3 pi pi 4096 Aug 24 11:38 mnt
drwxr-xr-x 3 pi pi 4096 Nov 13 2018 media
drwx------ 2 root root 16384 Nov 13 2018 lost+found
drwxr-xr-x 18 root root 4096 Feb 28 10:55 lib
drwxr-xr-x 3 pi pi 4096 Nov 13 2018 home
drwxr-xr-x 118 root root 4096 Aug 25 10:19 etc
drwxr-xr-x 16 root root 3740 Aug 24 11:33 dev
drwxr-xr-x 2 root root 4096 Aug 20 10:49 CreateDirsCopy
drwxr-xr-x 3 root root 4096 Jan 1 1970 boot.bak
drwxr-xr-x 4 root root 3072 Jan 1 1970 boot
drwxr-xr-x 2 root root 4096 Apr 9 16:33 bin
pi@raspberrypi:/ $

Any help please.
Thanks
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

jj_0
Posts: 124
Joined: Wed Jul 11, 2012 7:07 am

Re: user pi refused command without using 'sudo' before command?

Sun Aug 25, 2019 10:46 am

It would be helpful if you use the 'Code' tags when posting command-line output, like this:

Code: Select all

pi@raspberrypi:/ $ ls
bin boot.bak dev home lost+found mnt proc run srv tmp var
boot CreateDirsCopy etc lib media opt root sbin sys usr
pi@raspberrypi:/ $ ls -lr
total 79
drwxr-xr-x 12 root root 4096 Jan 20 2019 var
drwxr-xr-x 11 root root 4096 Nov 13 2018 usr
drwxrwxrwt 13 root root 4096 Aug 25 10:39 tmp
dr-xr-xr-x 12 root root 0 Jan 1 1970 sys
drwxr-xr-x 2 root root 4096 Nov 13 2018 srv
drwxr-xr-x 2 root root 4096 Apr 9 16:33 sbin
drwxr-xr-x 31 root root 980 Aug 25 09:10 run
drwx------ 6 root root 4096 Aug 13 09:39 root
dr-xr-xr-x 174 root root 0 Jan 1 1970 proc
drwxr-xr-x 7 root root 4096 Nov 13 2018 opt
drwxrwxrwx 3 pi pi 4096 Aug 24 11:38 mnt
drwxr-xr-x 3 pi pi 4096 Nov 13 2018 media
drwx------ 2 root root 16384 Nov 13 2018 lost+found
drwxr-xr-x 18 root root 4096 Feb 28 10:55 lib
drwxr-xr-x 3 pi pi 4096 Nov 13 2018 home
drwxr-xr-x 118 root root 4096 Aug 25 10:19 etc
drwxr-xr-x 16 root root 3740 Aug 24 11:33 dev
drwxr-xr-x 2 root root 4096 Aug 20 10:49 CreateDirsCopy
drwxr-xr-x 3 root root 4096 Jan 1 1970 boot.bak
drwxr-xr-x 4 root root 3072 Jan 1 1970 boot
drwxr-xr-x 2 root root 4096 Apr 9 16:33 bin
pi@raspberrypi:/ $
The user pi is not king of the castle, it's just an ordinary user. The user root is king of the castle. That's why you need sudo, this allows user pi to execute commands as root when required.
Normally the user pi only owns his own home directory tree (/home/pi). From the listing above you seem to have chown'd some directories to pi, e.g. /mnt, /media, /home. This might impede correct working of the system, you'd probably be better of starting with a fresh Raspbian system.

User avatar
DougieLawson
Posts: 40787
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: user pi refused command without using 'sudo' before command?

Sun Aug 25, 2019 10:48 am

You're in the root (/) directory. It is never a good idea to remove things from there.

Use cd [ENTER] and the shell will change to your home directory.
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
rpdom
Posts: 18130
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: user pi refused command without using 'sudo' before command?

Sun Aug 25, 2019 10:49 am

It is unusual to set up a normal user to be able to use "sudo" without having to enter the user's password to confirm, but that is the way the default Raspbian is set up.
Unreadable squiggle

Return to “Beginners”