[SOLVED] Linux Script loses its executable permission in Windows
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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).
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.
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,
-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.
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?