Copying files and folders from windows /Users folder to linux /home permissions issues

Discussion in 'Linux' started by pf100, May 15, 2017.

  1. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,449
    90
    #1 pf100, May 15, 2017
    Last edited: May 15, 2017
    This is a bigger issue than just hexchat but I'm using hexchat as an example.
    I dual boot windows 10 and linux mint 18.1. I have hexchat installed on both os's and I want to keep both synced with the exact same log files and configuration.
    While running linux, if I copy the /home/(username)/.config/hexchat folder to /Users/(username)/AppData/Roaming/HexChat everything works fine. The files are copied over and the up to date logs and configuration are all working as expected.
    So now let's say I've rebooted into windows 10 for a few days and I've made changes and want to copy the updated config and log files back to linux.
    I boot into linux, and before starting hexchat, I copy the /Users/(username)/AppData/Roaming/HexChat folder to /home/(username)/.config/hexchat.
    Now I have a /home/(username)/.config/hexchat folder where the line endings are screwed up, and the files and folders have 777 permissions (-rwxrwxrwx and drwxrwxrwx, respectively).
    I can fix it by:
    Installing dos2unix if not already installed, then from the terminal while in the /home/(username)/.config/hexchat folder run the following commands:
    Code:
    find . -type f -exec dos2unix {} \;
    find . -type d -exec chmod 755 {} \;
    find . -type f -exec chmod 644 {} \;
    Is there a better way to do this?
    I'd like to be able to just copy any files and folders into my linux home folder from windows and automatically have the text files have the correct linux line endings, the folders permissions be 755, and the files permissions be 644.
    I know I can't be the only one to have this problem and I assume there's a fix for it but I haven't been able to find it. Any info would be appreciated. Thanks in advance.
     
  2. TT_ZX

    TT_ZX MDL Novice

    Aug 27, 2010
    33
    25
    0
    I would run a bash script from a cron job. It seems you already know how to do what you want to do it is just a PITA to do it manually. If you automate it with a bash script then you won't have to manually do anything.

    Alternatively if you have a network file system you could just create links to this and have the permissions forced. This won't work if you are using a laptop that isn't always connected to the network. It won't fix the line endings either which is why I didn't recommend it first.
     
  3. Nimbus2000

    Nimbus2000 MDL Senior Member

    May 5, 2010
    257
    179
    10
    #3 Nimbus2000, May 28, 2017
    Last edited: May 28, 2017
    I do something similar with Thunderbird. Rather than have 2 data folders being copied back and forth, I have the data stored in a partition accessible from both Windows and Linux. To automate mounting the partition and setting permissions in Linux, I have added the following line to /etc/fstab:


    Code:
    #Entry for /dev/sda5 :
    UUID=01D19709113A7A7F    /media/nimbus/Data    ntfs    defaults,nosuid,nodev,uhelper=udisks2,uid=1000,gid=1000,dmask=0077,fmask=0177    0    0
    Of course you would have to enter your own UUID and mount point.
     
  4. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,449
    90
    Nimbus2000, the way you're doing it is the right way, I was just hoping to avoid repartitioning just for this one program. Thanks for the tip though.