Changes between Version 2 and Version 3 of Linux/CopyFileBetweenUserAndRoot


Ignore:
Timestamp:
02/08/08 23:38:12 (9 years ago)
Author:
tj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Linux/CopyFileBetweenUserAndRoot

    v2 v3  
    1313cp: cannot stat `/mnt/remote/Backups/rootfs/etc/udev/rules.d/41-permissions-tun.rules': Permission denied 
    1414}}} 
     15It is possible for the super-user to execute a shell script that redirects to the destination file, such as: 
     16{{{ 
     17cat /mnt/remote/Backups/rootfs/etc/udev/rules.d/41-permissions-tun.rules | sudo sh -c "cat > /etc/udev/rules.d/41-permissions-tun.rules" 
     18}}} 
     19but this form can run into problems if there are quotes in the command itself, since they may need escaping now the entire output command is wrapped in quotes. 
    1520 
    16 There are several possible workarounds involving staging the file in a temporary locaton, but I found this is an elegant way to avoid confusion and run each ''half'' of the transaction as the correct user: 
     21There are several other possible workarounds involving staging the file in a temporary locaton, but I found this is an elegant way to avoid confusion and run each ''half'' of the transaction as the correct user: 
    1722{{{ 
    18 $ cat /mnt/remote/Backups/rootfs/etc/udev/rules.d/41-permissions-tun.rules | sudo dd of=/etc/udev/rules.d/41-permissions-tun.rules 
    19 0+1 records in 
    20 0+1 records out 
    21 112 bytes (112 B) copied, 0.000106927 s, 1.0 MB/s 
     23$ cat /mnt/remote/Backups/rootfs/etc/udev/rules.d/41-permissions-tun.rules | sudo tee /etc/udev/rules.d/41-permissions-tun.rules 
    2224}}} 
     25To '''''append''''' (like doing >> shell redirection) add the '''-a''' option: 
     26{{{ 
     27$ cat /mnt/remote/Backups/rootfs/etc/udev/rules.d/41-permissions-tun.rules | sudo tee -a /etc/udev/rules.d/41-permissions-tun.rules 
     28}}} 
     29The only draw-back is that tee echos all the output to the console which, if the input is larger (or binary) causes other problems.