1

Background

I had a failed update from 21.04 to 22.04 because of a misunderstanding that I had about updating my Ubuntu installation. I asked about what had happened here.

Luckily I was able to back-up and restore my data after doing a fresh / complete install of 22.04.

Some files I had simply copied from my old 21.04 installation onto a large external USB drive.

Why Do Files Have Executable Attribute Now?

Now, I see that the files I copied over from the USB drive seem to have +x (filemod 755) where they used to only have (filemode 644 -- not executable). Directories which were copied over also have +x.

Why did that happen? Is this an expected thing on Linux installations? Was there something I needed to do when I copied these files to mitigate this situation?

Quick Way To Reset Them to 644?

Is there a quick way to reset them to -x?

Official Backup/Restore Causes Problem Also

Deja Dup Backups deja dup backups

I had some directories which were backed up and restored using the actual Ubuntu backups program and they are also set to 755 so it isn't just the files that I copied to USB drive.

raddevus
  • 1,800

1 Answers1

1

Never copy Linux files over to an NTFS. NTFS is mounted with specific settings and will change all the files to those settings. It will add executable permissions if it is mounted as such. If you want to do that you need to use tar and store that on the NTFS.

When you use cp to copy files to an EXT you need to use -p to preserve mode, ownership, and timestamps of the files. If the destination is owned by someone else cp will error out.

If you use tar then, by default, it preserves mode, ownership, and timestamp of files when creating the tar file. Extracting will error out if you extract it with another owner and you will need to use root(/sudo) to extract that tar.

Is there a quick way to reset them to -x?

That depends... are there NO executable files? If so this will ...

chmod -R -x+X .

Where ...

-R = recursive
-x = remove executable flag
+X = set executable flag if it is a directory
Rinzwind
  • 299,756
  • Thank you. This is a lesson-learned for me. I'll resolve them as I can. I'll mark this as answer because you've explained what has occurred. – raddevus Aug 11 '22 at 14:49