LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-27-2010, 09:56 AM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,795

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
How to stop files moved to Linux from Windows via USB being marked "executable"?


Sorry about the long subject line but that pretty much summarizes the problem.

I'm finding this behavior increasingly annoying: When I move files from Windows to Linux using a USB drive, all files are marked as executable. Then double clicking on a ".txt" file gets you the ridiculous dialog box asking whether you want to display the file or execute it. (NOTE: The /etc/fstab entry for the USB mount includes the "noexec" option already and it hasn't helped.) Now that my wife and daughters are moving files back and forth between the two OSs, I'm getting pestered for a solution to this and I haven't been able to track anything down. Yet.

What can one do -- presumably on the Windows side of the transfer -- to prevent these files from being marked executable? Or is it a hopeless problem caused by some dainbread decision made by a Windows developer?

TIA

--
Rick
 
Old 09-27-2010, 10:04 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
What filesystems are in use on all three ends (Linux source, USB stick, Windows destination)?
 
Old 09-28-2010, 07:15 PM   #3
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2, 15.0
Posts: 631

Rep: Reputation: 152Reputation: 152
I get the same thing all the time. It happens (in my case) with an ext2 Linux filesystem and a USB stick with a windows format. The windows format filesystem does not have all the bits that the ext2 filesystem does, so when the files are copied the missing attribute bits have to be invented from somewhere.
The copy command supplies them from its defaults.

That is as far as I have got. I usually do a "chmod a-x workdir/* "
after I get irritated enough.

Finding out what the copy command does to supply missing attributes would be difficult. It is likely not paying any attention to where the file comes from or else it presume that no windows file could possiblu be executable on Linux.

Could use dostools to do the file copy, and see if it does better.
Could make a script that does the copy and then removes the execute from all files.

Off the top of my head (which means probably lots of errors):

cp -a $(1) $(2)
if [ -d $(2) ]; then
chmod a-x $(2)/*
else
chmod a-x $(2)
fi
 
Old 09-28-2010, 07:29 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by selfprogrammed View Post
Off the top of my head (which means probably lots of errors):

cp -a $(1) $(2)
if [ -d $(2) ]; then
chmod a-x $(2)/*
else
chmod a-x $(2)
fi
This will not work correctly if there are folders in a copied folder. If you use the -R option of chmod you can shorten the script to this:
Code:
cp -a $(1) $(2)
chmod -R a-x $(2)
 
1 members found this post helpful.
Old 09-28-2010, 07:32 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by rnturn View Post
Or is it a hopeless problem caused by some dainbread decision made by a Windows developer?
It's because Windows and it's filesystems (NTFS, FAT*) have no concept whatsoever of Unix-style file permissions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
accidently moved files in "/" to a folder dopraaditya Linux - Newbie 13 05-19-2010 12:21 AM
samba - windows files lose "created on" date stamp when moved to samba share on linux jaredk51 Linux - Software 5 02-19-2010 03:13 PM
Moving text files between Windows and Linux: Unicode and "executable" problems AchubaNanoiaBR Linux - Newbie 2 07-04-2009 04:15 PM
"list dynamic dependency" of an executable using command other than "ldd" Amrita@3086 Solaris / OpenSolaris 3 04-04-2007 04:56 AM
Moved files => Apache: "You don't have permission to access / on this server." teek Linux - Server 1 12-31-2006 04:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration