Foo User home Directory has a file file.txt, to copy it to the bar user's home directory. Linux has strict permissions on the user's home directory, not the owner or the same group user without permission to read and write, unless it is root (the root of the supremacy). If there is no root authority, what is the way to copy the file.txt to the bar user's home directory?
Workaround:
The first way, first with the Foo user login, copy the file to the system temp directory/tmp, and then switch to the bar user, and then from the system temp directory/tmp to copy the files to their home directory. Why use CP here without MV? Because the file copied to/tmp is owner or foo, by default other users have Read permission, no write permission (naturally no move permission). Even if you make bar writable by modifying the file permissions, move to the bar's home directory owner or Foo, and you have to root to change to bar. This approach is a bit tortuous, the drawbacks are obvious, the file needs to be duplicated two times, spending twice times the time.
# CP file.txt/tmp/
# Su-bar
# Cp/tmp/file.txt ~/
# exit
# Rm/tmp/file.txt
The second approach, use the SCP command. Originally SCP was used to copy files over the network on different hosts, just right here. Log in with bar user
# SCP [email protected]:/home/foo/file.txt. /
Enter the Foo user password to start the file transfer. You can also log in with the Foo user,
# SCP file.txt [email protected]:/home/bar/
Enter the bar user password, as in the procedure.
Recommended Method Two
Linux cross-user copy files