Execute permission lost in transfer

I copied a script to another computer.

For some reason, it had no execute permission on the new computer.

Is that standard procedure ?

how did you copy the script?
I just did scp file.script user@host:destdir and it maintained the permissions.
You can also try rsync -p file.script user@host:destdir or
tar cvzf myfile.tar file.script, copy myfile.tar to the other host and tar xvzf myfile.tar

1 Like

I emailed it to myself.

Same thing happened when I copied file on my computer from hard drive to flash drive ???

@fixit7 What your experiencing is normal. Flash drives by default are formatted to the FAT32 file system, which does not support permissions. So when you copy a file from a file system that supports permissions (Your hard drive), to a file system that does not support permissions (Your flash drive), all permissions are lost. Emailing the file would have the same affect.

After copying the file back to a file system that supports permissions, permissions will be assigned to the current user, but you will have to set the file to execute again.

Your can read more about file system permissions here:

https://en.wikipedia.org/wiki/File_system_permissions

1 Like

Thanks.

I will reformat my flash drives to Linux file systems.

I did so.

Now I can not copy files to my flash drive nor save files to them. ??

Linux is good at learning patience. :slight_smile:

Proverbs 19:11New International Version (NIV)

A person’s wisdom yields patience;
it is to one’s glory to overlook an offense.

Your almost there :slight_smile:

When you formatted your flash drive, you had to become root to do so. This causes the ownership of the flash drive to be that of root. Since root owns the flash drive, your normal user no longer has write permissions. This is why you can not copy files to your flash drive.

So you have to change the permissions of your flash drive, in order to use it.

  1. Insert and mount your flash drive.
  2. Open Mate Terminal and enter sudo lsblk

This should give you a output similar to the following:

steven@virtual-ubuntu:~$ sudo lsblk
[sudo] password for steven:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
├─sda1 8:1 0 7.5G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 510M 0 part [SWAP]
sdb 8:16 1 3.8G 0 disk
└─sdb1 8:17 1 3.8G 0 part /media/steven/3060ee83-d8e0-4218-83ff-40360e71d5cb
sr0 11:0 1 1024M 0 rom
steven@virtual-ubuntu:~$

Here we will find the UUID of your flash drive so we can change the permissions. In the example above, the UUID of the mounted flash drive is every thing past /media/steven/

To change the permissions enter the following in Mate Terminal. Changing every instance of steven to the username that your logged in as. Also you must change the UUID in the example below to the UUID of your flash drive.

sudo chown steven:steven /media/steven/3060ee83-d8e0-4218-83ff-40360e71d5cb

At this point you should have write permissions on the flash drive. If not, eject the flash drive and reinsert it.

Note: You need to maximize Mate Terminal before issuing the sudo lsblk command, to insure none of the numbers in the UUID gets cut off. If Mate Terminal reports "No such file or directory" when issuing the chown command, this is what happened.

1 Like

andy@7:~$ sudo lsblk
[sudo] password for andy:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
└─sda1 8:1 0 1.8T 0 part /
sdb 8:16 0 298.1G 0 disk
├─sdb1 8:17 0 98.4G 0 part /media/andy/MAXTOR_SDB1
├─sdb2 8:18 0 101G 0 part /media/andy/MAXTOR_SDB2
└─sdb5 8:21 0 98.7G 0 part /media/andy/MAXTOR_SDB5
sdc 8:32 1 7.3G 0 disk
└─sdc1 8:33 1 7.3G 0 part
sr0 11:0 1 1024M 0 rom
andy@7:~$ blkid
/dev/sda1: UUID=“ac6bf8cc-5bbc-44a6-a92f-0745372729f7” TYPE=“ext4” PARTUUID=“cafc53cc-01”
/dev/sdb1: LABEL=“MAXTOR_SDB1” UUID=“b3b0f384-9e2e-45f5-8995-932f1113f59d” TYPE=“ext3” PARTUUID=“000f0791-01”
/dev/sdb2: LABEL=“MAXTOR_SDB2” UUID=“8adebdf0-6bc3-4eee-8363-3e9440688d42” TYPE=“ext3” PARTUUID=“000f0791-02”
/dev/sdb5: LABEL=“MAXTOR_SDB5” UUID=“fd00f2d7-d666-4614-885d-5ace942dd3f6” TYPE=“ext3” PARTUUID=“000f0791-05”
/dev/sdc1: UUID=“d1670deb-0626-449f-94c3-87d4c10f1213” SEC_TYPE=“ext2” TYPE=“ext3” PARTUUID=“1d33400f-01”
andy@7:~$ chown andy:andy /dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213
chown: cannot access ‘/dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213’: Not a directory
andy@7:~$ chown andy:andy /dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213
chown: cannot access ‘/dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213’: Not a directory
andy@7:~$ chown andy:andy /dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213

Found a way that works.

https://community.linuxmint.com/tutorial/view/213

Well done @fixit7. The solution you found does the same thing, only using a GUI approach. I tend to think of solutions that involve using the command line, since that’s the way that I’m most interested in.

Thanks.

I like the command line, but this shows that it did not work ?

andy@7:~$ chown andy:andy /dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213
chown: cannot access ‘/dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213’: Not a directory
andy@7:~$ chown andy:andy /dev/sdc1/d1670deb-0626-449f-94c3-87d4c10f1213

Your sudo lsblk is not showing a mount point for sdc1

How is it listed in /media/andy/ ?

Edit 1:

Lets say for example you wanted to change permissions for sdb1

You would enter

sudo chown andy:andy /media/andy/MAXTOR_SDB1

The reason MAXTOR_SDB1 is listed instead of the UUID is because that partition has a label.

So however your flash drive is listed in /media/andy/, whether a UUID or a label, that is what you would use in the command.

I changed the label to

/media/andy/KINGSTON_1/

So the command would be

sudo chown andy:andy /media/andy/KINGSTON_1/

Thanks for the help.

1 Like

Needs to be recursive to give you ownership of all the files, not just the directory.

Thank you @Dynamic-Gravity. If there where files already on the drive, then yes it should be recursive.

1 Like