In the Linux system, many people don't know how to copy files between different users. In fact, there are many ways to copy files to another user. Today, Xiaobian will introduce you to the Linux copy files to other users. Kind of method, let's learn together.
Scenario:
There are a file.txt file foo under the user's home directory, which you want to copy to bar the user's home directory. Linux has strict permission restrictions on the user's home directory. Non-owner users or group users have no permission to read or write, unless it is root (the supreme root). If there is no root permission, is there any way to copy file.txt to the home directory of the bar user?
Solution:
The first method, first log in with foo user, copy the file to the system temporary directory /tmp, then switch to the bar user, and then from the system temporary directory /tmp Copy the file to your home directory. Why use cp without mv here? Because the file owner to /tmp is still foo, by default other users have read access and no write permission (naturally no move permission). Even by modifying the file permissions, let bar be writable, move to the home directory of bar home or foo, and root must be changed to bar. This method is a bit tortuous, and the drawbacks are obvious. The file needs to be copied twice and takes twice as long.
# cp file.txt /tmp/
# su - bar
# cp /tmp/file.txt ~/
# exit
# rm /tmp/file.txt
The second method is to use the scp command. The original scp is used to copy files over the network on different hosts, just used here. Log in as the bar user
# scp foo@localhost:/home/foo/file.txt . /
Enter the foo user password to start file transfer. You can also log in as foo user,
# scp file.txt bar@localhost:/home/bar/
Enter the bar user password, the process is the same.
The above is a description of the method of copying files from Linux to another user. This article only introduces two more practical methods. You can also use other methods to copy them. This article will not introduce them one by one.
CKEditor is commonly referred to fCKEDITOR, it is an excellent web editor, can supp
Lubuntu is a Ubuntu lightweight desktop environment with small size, fast running,
Linux is a command line system, so you want to mount an optical drive, a floppy drive, or a USB flas
Many users often confuse rpm and yum under Linux system, they have similar names and functions, and
When the Linux virtual machine mounts the hard disk, you are prompted to specify how to solve it?
Linux ls command operation example summary
How Ubuntu builds virtual network card
Summary of methods for getting help from Linux
Ubuntu system installation screen saver XScreenSaver steps
After the Ubuntu program is updated, the WiFi icon is not displayed properly. How to solve it?
Ubuntu system to change the terminal user name to red skills
Ubuntu notebook energy-saving three tips
How Linux uses the command line to clean up the disk to increase the space
Win10 system installs the Edge browser plug-in method
Win10 9879 running steam platform game crash solution
Windows8 system Metro network synchronization QQ/Gmail/Twitter and other methods
How to fix the Win10 common settings to the start menu
Win10 get member version is gray solution
Win7 detects a hard disk error after booting. Please backup the file immediately.
Restart Apache commands under Linux
Do you want to upgrade Win10? Different people want to distinguish
Win10 preview version 10122 update content Daquan
Win8 version of mine clearance officially landed: the shape has finally changed!