Skip to content

copy to from NTFS usb disk permissions issue

problem

usb disk with NTFS FS , mounted without the -o option to specify a user
linux will in that case consider all the files as “being owned by root”
when you copy files to a ext4 fs in that scenario =>

  • in parent folder :
    sudo chown -R ward:ward sql-scripts-tx

  • set rw-rw-rw- for all files from parent error ; -R option : recursive
    chmod -R 666 sql-scripts-tx
    – dit zet tevens de exec recht af voor de folder

redo : chmod 777 sql-scripts-tx

  • go into the dir
    chmod -R 666 sql-*.sql
    works for all files , but not subfolders
chmod 775 $(find /mnt/data/dba/dba.werk/dba.Transics/lapwm_TRANSICS -type d) 
chmod 666 $(find /mnt/data/dba/dba.werk/dba.Transics/lapwm_TRANSICS -type f)

# => this works, but not  if the file names has spaces in it (and possible aslo a "-")   

# there is an -printf option with find that can reformat output
find /mnt/data/dba/dba.werk/dba.Transics/SQL-Transics2/_scripts-prd  -printf "\"%p\" " 
    ( with no newlines,  but uses space as seperator)  
# => output is ok 

# but this technique does not work with  the $() construct as the input source for chmod
chmod 775 $(find /mnt/data/dba/dba.werk/dba.Transics/SQL-Transics2/_scripts-prd -type d -printf "\"%p\" ") 
# => error

find /mnt/data/dba.tmp/admin-dba/ -type f
chmod 666 $(find /mnt/data/dba.tmp/admin-dba/ -type f)