LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2010, 05:12 AM   #1
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Rep: Reputation: 0
Linux Script loses its executable permission in Windows


Hi, I have found that when a shell script having executable permission(+x) is copied to Windows from Linux machine,loses its executable permission when again copied back to Linux from Windows machine.
Can someone please guide me how to maintain its executable permission in Windows too.

Last edited by aanand0; 12-23-2010 at 05:14 AM.
 
Old 12-23-2010, 05:24 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
Windows and Linux has different permissions system. For example FAT32 does not support executable permission at all. How do you copy these files? Through network or just another drive.
 
Old 12-23-2010, 05:36 AM   #3
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
I am copying these script files over network with the help of ftp. But I have tried using USB drives also. It gives same result.
 
Old 12-23-2010, 05:37 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Tar the files, and tell tar to preserve permissions?

If time stamps etc. are also important to you, bear in mind that when copying (plain) files, they may (read: will) change too. This is why you might want to archive the file(s) somehow before transferring them, sort of like put them into a box the contents of which remain untouched on the road (vs. just carrying the contents around, letting the environment interact with the contents).

Last edited by b0uncer; 12-23-2010 at 05:40 AM.
 
Old 12-23-2010, 05:54 AM   #5
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Yes,this is true. File does maintain its permissions in tar format.But in this process I will have to copy the file (without unzipping it in the Windows) in the tar format in Linux machine. It means I will not be able to see the contents inside the tar file.Because when I unzip tar file, script loses its permission and achieves default permission of 644. It doesn't solve my purpose.
 
Old 12-27-2010, 02:54 AM   #6
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I'll try to clarify myself, just in case there's a misunderstanding here. The basic "problem" with permissions and copying files from one place to another is the filesystem in each end. If the endpoint (or midpoint) filesystem does not "understand" all of the properties of a "file" copied from the starting point, those "properties" are typically lost. Permissions belong to this group if you think of FAT (or NTFS I guess, at least to some extent--not that I use it much) and Linux ext filesystems for example. But if you move a file (for example) from a Linux machine to another Linux machine, and both of them use a filesystem that does understand the concept of owners and permissions the same way, you generally can keep those things intact, if you want. If you transfer the files through a filesystem that does not know of such properties or does not handle them the same way (e.g. FAT in this case), you'll need to wrap the files up somehow to keep the actual files intact--you may use tar for this, or some other archive formats. The thing to remember is to make sure to tell the archiver at both ends (when archiving and when unarchiving) if needed that you'd like to keep the permission and owner information and such. This is because 1) if you do not make sure that information is kept "as is" when archiving, you naturally cannot restore it later when unarchiving, and 2) because even if you stored the information when archiving, you can later choose not to keep it when unarchiving, but instead reset the permissions. Some archiving software may keep the information by default when archiving, but check if you're not sure.

If you copy from a filesystem to another (that understands the permissions and ownerships) directly (for example over the network, or on the same machine), you can either archive (and remember to preserve permissions etc.) or use a copying program that can preserve permissions (nearly all of them I guess). If you move the files onto a "difficult" filesystem such as FAT somewhere in the middle, then you are to archive the files, as I mentioned before. From the man page of tar,

Code:
man tar
Quote:
-p (x mode only) Preserve file permissions. Attempt to restore the
full permissions, including owner, file modes, file flags and
ACLs, if available, for each item extracted from the archive. By
default, newly-created files are owned by the user running tar,
the file mode is restored for newly-created regular files, and
all other types of entries receive default permissions. If tar
is being run by root, the default is to restore the owner unless
the -o option is also specified.
So when you unarchive the tar file, remember to add -p to the options, to keep the permissions. Without it, they're reset.
 
Old 01-05-2011, 05:50 AM   #7
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Sorry for a late response. I got exactly what your point is. So, finally it can be understood that I can't unzip a tar file in Windows or this file will lose its permission if I copy it back to Linux. Am I correct?
Please respond.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Windows Loses Money, Linux Nears $1 Billion Mark LXer Syndicated Linux News 0 08-28-2009 05:10 AM
LXer: Mac OS X, Windows 7 Win, Linux Loses LXer Syndicated Linux News 2 02-02-2009 03:15 PM
Convert python script to windows executable ankit_mcgill Linux - Newbie 4 10-05-2008 02:21 AM
LXer: Top four reasons Windows wins and Linux loses LXer Syndicated Linux News 0 01-04-2007 02:03 PM
executable files in linux and windows... GEJOE DANIEL Programming 7 01-12-2006 02:59 PM


All times are GMT -5. The time now is 02:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration