User avatar
Grumpy Mike
Posts: 934
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Sudo for the desktop

Sun Aug 26, 2012 2:13 pm

I know I can log on as root but is there a way of doing a drag and drop desktop operation temporarily as root when I log on as Pi?
Having googled this I see there are some flavors of Linux you can do this with. Is there any way of doing this with Raspbain?

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Sun Aug 26, 2012 2:55 pm

Do you mean drag and drop in the sense "move"? That is not a task I can easily imagine needing root privileges for. Do you have any specific examples where it would have been useful? It might be better to change the permissions on the files you are working with.

User avatar
Grumpy Mike
Posts: 934
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: Sudo for the desktop

Sun Aug 26, 2012 3:08 pm

jojopi wrote:Do you mean drag and drop in the sense "move"?
Yes
That is not a task I can easily imagine needing root privileges for.
Yes suppose you want to put something in a directory that is owned by root, like putting a customised wallpaper image in a directory or ejecting an SD card as a user that was first mounted under root.
I am rather fed up of constantly quitting X logging out, log in as root, startx, doing the move copy or what ever, then quitting X, logging out, logging back in as Pi and startx again. Personally I have better things to do with my life.

rasbeer
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am

Re: Sudo for the desktop

Sun Aug 26, 2012 3:13 pm

I haven't done this on a Pi, but I think if you start the filemanager (eg thunar or whatever) from a terminal window, like this:

Code: Select all

gksu thunar &
it has root privileges (& also doesn't freeze the terminal window).

Using sudo instead of gksu is similar (but different in some subtle way I've never grasped). :)

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: Sudo for the desktop

Sun Aug 26, 2012 3:33 pm

Code: Select all

sudo pcmanfm 
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Sun Aug 26, 2012 4:12 pm

Grumpy Mike wrote:Yes suppose you want to put something in a directory that is owned by root, like putting a customised wallpaper image in a directory or ejecting an SD card as a user that was first mounted under root.
I am rather fed up of constantly quitting X logging out, log in as root, startx, doing the move copy or what ever, then quitting X, logging out, logging back in as Pi and startx again. Personally I have better things to do with my life.
A customised wallpaper can and should live in your home directory with your other personal files, and be owned by you, so that you can back it up separately from the base operating system. The only exception to that is if you (as system administrator) want to make the image available to all users. But even in that case you should not drag it into any of the standard artwork directories, where it might get clobbered by a future package update. Instead you should put it somewhere under /usr/local/, or in some other site-specific directory that you create, such as /home/grumpy. Notice that /usr/local/ is writeable by group "staff", so "sudo usermod -aG staff pi" gives pi permission to drag stuff there (after next login). There is no reason that /home/grumpy could not be writeable by pi, or mike, or whoever is deemed the sysadmin.

I do not have a card reader to test with, and I am not sure what you are using it for, how you are mounting it, or why want to be able to unmount as a different user. But I suspect that Tools→Open Current Folder as Root in the file manager will make the eject icon appear.

As well as being inconvenient, it is definitely not advisable to run startx as root. There is always a better way.

User avatar
Grumpy Mike
Posts: 934
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: Sudo for the desktop

Sun Aug 26, 2012 8:06 pm

Thanks.
I know what I want to do and as usual Linux is stopping me.
What a nanny operating system.
Last edited by Grumpy Mike on Sun Aug 26, 2012 8:22 pm, edited 1 time in total.

Nr90
Posts: 216
Joined: Sat Nov 26, 2011 12:39 pm

Re: Sudo for the desktop

Sun Aug 26, 2012 8:19 pm

you could open a terminal and type
sudo nautilus (or w/e file manager you use)
LXDE as installed does not ask for root permission when you're trying to do something that requires root like some other distro's.

User avatar
Grumpy Mike
Posts: 934
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: Sudo for the desktop

Sun Aug 26, 2012 8:23 pm

OK thanks I will give that a go in the morning.

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Sun Aug 26, 2012 9:12 pm

Grumpy Mike wrote:I know what I want to do and as usual Linux is stopping me.
What a nanny operating system.
Apparently, what you want to do is drag files into places that even a sysadmin would not expect to be writing to. Presumably so you can then announce that "Things break very quickly with Linux, it is not a very stable platform."

If you were complaining that GPIO access needed privileges and was hard to delegate, then you would actually have a point. But everyday user and programmer tasks do not require privileges unless you are doing them in the wrong way.

Anyway, pcmanfm's Tools→Open Current Folder as Root is totally happy to allow stupid things like dragging JPEGs into /. I do see how that is a nanny operating system, unless you mean there is a evil nanny who fails to stop you getting into trouble.

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Sudo for the desktop

Sun Aug 26, 2012 9:27 pm

before starting X or exit to the command line.

Code: Select all

sudo startx
In any terminal, (or even make a bash user config script later)

Code: Select all

sudo bash
and type the following to lose sudo (note # and $ prompt)

Code: Select all

exit
You will not be protected from any typing errors that may harm the data on the SD.

OK?
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sudo for the desktop

Mon Aug 27, 2012 9:39 am

jojopi wrote:... stupid things like dragging JPEGs into /. I don't see how that is a nanny operating system, unless you mean there is an evil nanny who fails to stop you getting into trouble.
(edited slightly, my italics)
Nanny tells kids "Don't run in the road" - good Nanny.
Nanny tells grandpa "Eat up your greens - they'll make you big and strong" - bad Nanny

Okay, I break my Pi, it's my Pi and I'll do what I want. ***** Nanny.

Use RISC OS. Nanny doesn't go there.

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Sudo for the desktop

Mon Aug 27, 2012 9:49 am

***** Nanny.
I can't think of a verb with five letters that would fit there. Apart from "quote" which doesn't make sense.
An adjective that works is "silly"

User avatar
Grumpy Mike
Posts: 934
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: Sudo for the desktop

Mon Aug 27, 2012 11:52 am

Burngate wrote:
***** Nanny.
I can't think of a verb with five letters that would fit there. Apart from "quote" which doesn't make sense.
An adjective that works is "silly"
It is like passwords, they don't always have the same number of *s as letters typed :lol:

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Mon Aug 27, 2012 1:41 pm

Burngate wrote:Okay, I break my Pi, it's my Pi and I'll do what I want. ***** Nanny.
Use RISC OS. Nanny doesn't go there.
But there is no nanny here either. Even the daft thing that Mike originally asked for (but does not really need) — the ability to drag files into system directories, using a specific GUI — can indeed be done.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Sudo for the desktop

Mon Aug 27, 2012 9:20 pm

An alternative which I use all the time is to ssh into the pi with a sftp client as root from another machine and shuffle files around. Winscp is one for windows, the Nautilus file manager in Linux does it as standard The Pi is big enough to do the multi user thing.

Option 2 : You can start up an alternative tty on the pi itself by pressing ctrl alt f2, logging in as root and then starting a second gui with startx. You then have a gui as root. you can then switch back to the standard user with ctrl alt f7. to switch back to the root gui you press ctrl alt f8. You can switch backwards and forwards at will.
Last edited by pluggy on Mon Aug 27, 2012 9:47 pm, edited 1 time in total.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Mon Aug 27, 2012 9:46 pm

pluggy wrote:You can switch bacwards and forwards at will.
Remember to release and re-press Ctrl+Alt between each switch, because the X servers cannot see raw keystrokes that started on a different console.

Are you able to share any examples of when you might need to "shuffle files around" as root? It sound very dangerous and unnecessary. (As opposed to editing files as root, which I concede is occasionally useful.)

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Sudo for the desktop

Mon Aug 27, 2012 9:53 pm

Its what GM wanted to do. More often than not I'm running the pi headless and using it as some form of server, logging in as root is something I do all the time. Its very convenient to use a GUI without actually having to fire one up on the Pi. Editing textfiles in gedit on my Ubuntu box beats faffing around with vi,pico etc from a command line.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: Sudo for the desktop

Mon Aug 27, 2012 10:19 pm

You said that you "shuffle files around" "as root" "with a sftp client" "all the time". Not edit them. I am interested to know whether you are shuffling files that are controlled by the packaging system, and if so how this can be useful, or if you have ended up with data files owned by root.

Return to “Beginners”