2

I have two users on my laptop, say user1 and user2. I want to access user1's data from user2, provided I know the password(I manage both accounts). But I want to use the GUI instead of accessing it by terminal.

I tried using the "Connect to Server" option, but I'm not sure what to type in.

How can I do this?

  • 1
    Logout, then login as the other user. – mikewhatever Apr 20 '18 at 15:59
  • If you 'only' want access to the data, do as suggested by @mikewhatever, login as that user. But if you want to copy files from one user to another user, you should make sure that the user who 'wants' the files has read access to the other user's directories and files. Then you can copy the files (but it will be a waste of drive space). – sudodus Apr 20 '18 at 16:05
  • Well logging in to user1 has some display issues for some reason, so I'm not opting for that. And yes @sudodus I want to copy those files, but I want to access it via GUI (simple copy and paste) rather than using terminal. Any way to do that? – Md. Ameen Yoosuf Apr 20 '18 at 16:52

1 Answers1

0

Disclaimer

Yes, you can log in graphically, if you use xhost. If in your own computer at home, fine, but in a network with several people, for example at work, it is a security risk. So the general recommendation is to do such things via command lines in text mode.

Log in graphically from one user to another one

  • Log in as user2 according to your question

  • Open a terminal window

  • Allow the other user (in your question user1) to open windows in your desktop environment

    $ xhost +si:localuser:user1
    localuser:sudodus being added to access control list
    
  • Log in as the other user

    $ su - user1
    Password: 
    
  • If you wish, you can run some text mode commands to check where you are, pwd, and who you are, whoami.

  • Next you can start your file browser or some other graphical program. I'm running Lubuntu, so I start pcmanfm. In standard Ubuntu you would run

    nautilus --no-desktop
    

The following screenshot illustrates how it works.

LANG=C pcmanfm makes pcmanfm use the default language, US English, instead of my local language.

enter image description here

Copy files

You want to copy files from user1 to user2.

  • If 'personal data'

    • When logged in as user1, check that user2 has read access to the directories and files, that you want to copy and modify the permissions if necessary. This is possible with the file browser, but I think it is easier to check with the command ls -l and modify with the command chmod.
    • When logged in as user2, open two windows of the file browser and copy/paste from the window, that is 'looking at' user1 files, to the window that is 'looking at' the user1 directory, where you want the copies.
  • If system data (configuration data). Risky!

    • The permissions and ownership of system data files is often very important. This means that you must preserve these properies, if you want them to work.

    • It is a good idea to back up your previous system data before you start using some system data from the other user, particularly when there are problems logging into that user (so some system data are bad).

    • This is relatively easy to do with command lines with

      sudo rsync -Havn source target
      

      or

      sudo rsync -Havn source/ target
      

      See man rsync for more details, for example the effect of the trailing slash.

  • An alternative is to run the file browser with elevated permissions (preparing with xhost for root and running with sudo -H or pkexec or using some other method, that is considered relatively safe, for example nautilus-admin. See the following link,

    Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland?

sudodus
  • 46,324
  • 5
  • 88
  • 152