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.

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?