I gave execute permissions to a file and then compressed into a zip file in Linux OS. Then I moved this zip file to Windows and again copied it to another Linux server. This time I don't have the execute permission.
I know that we can directly copy the files and folders using scp command withing Linux but I have to let the user copy it from Windows to Linux also.
Please let me know how can I preserve the permissions while copying from Windows to Linux.
Thanks.
Since your executable file is inside a zip-archive it doesn't really matter what filesystem you're on or what operating system you're on. As long as the zip-archive is untouched.
However, as far as I know, zip-archives cannot keep track of file permissions. You can read more about it here:
Maintain file and folder permissions inside archives
It's up to whatever application is actually doing the copy.
But there are serious differences between the idea of file permissions on Linux/UNIX and Windows. UNIX file permissions have the idea of being "executable" which is not something that exists on Windows. Windows files are noted as runnable by their file extension not its permissions.
Furthermore, file permissions on UNIX have the concept of a group owner, and I don't think this exists on Windows so such a thing might not be possible in the strictest sense.
If you just want the writable/readable permissions as assigned to the owner to stick however, it will again depend on the application you are using to do the copy.
More recently, you can also use the Linux subsystem for Windows and zip the file using the linux shell command. I successfully did this recently when copying a executable for AWS from github to my Windows machine, and then up to Amazon.
Thanks for all your responses.
I found 2-solutions for my problem:
I am copying the complete zip file to the Linux server instead of copying a single file. This way it works fine.
Using cygwin helps me in copying the file onto a Linux server by preserving the execute permissions.
Related
My spring application is running on a tomcat server under Windows system and saves files to path C:\pathtoSav (file = new File("C:\upload\" + filename)).
I want to migrate my application on a tomcat server under Linux system.
Can I create this file with path on Linux system without change my code.
You will need to change your code. You have a few options:
Use a relative directory such as saving the file to the current directory. This will work on both systems.
Check the operating system using something like System.getProperty("os.name") and hardcode the path to what you need in each system (e.g. C:\upload in Windows and /home/ubuntu/uploads in Linux), selecting which one you want based on the OS.
Find a way to get a reasonable path on any OS, such as System.getProperty("user.home") which will always return the user's directory for the operating system.
If you need to build paths yourself, Java has File.separator as a convenience, which will be a forward slash on *nix and a backslash on Windows.
I am writing a C# application (in Visual Studio on Windows) that will be run as a mono application on Unix (Raspbian aka Debian). I am a Unix noob, and though I have read (well, skimmed) the Linux Foundation Filesystem Hierarchy Standard I am still not completely clear on where I should put the files my application will need. I have:
The compiled C# application (app.exe). I thought I would put this in /usr/bin, except that the application is not run directly (it is invoked by "mono app.exe"), so maybe /usr/libexec is a better location?
Configuration files (there may be more than one) (app.1.conf, app.2.conf, etc.). If they are not user specific, I would think /etc/app (a directory, not a file) would be a good place for these. How about if they are user specific? /home/?
Log file (app.log). Seems that /var/log is the right place for this.
Thanks in advance for your input.
You should look at an already established Mono app for reference. For example let's take MonoDevelop:
The exe file goes to /usr/lib/{appnameinlowercase}/bin/ , but they place a launcher script in /usr/bin, named {appnameinlowercase}, for easy launch from the command line (this script just calls exec mono YourAppName.exe).
In .NET the config files need to be in the same directory as the executable file, so you could place them in /usr/lib/{appnameinlowercase}/bin, then later for convenience, put symlinks to them from /etc/{appnameinlowercase}/.
Correct, /var/log/{appnameinlowercase}/ should be fine.
When I download source code from perforce, the symlinks gets downloaded as files and the project, of course, doesn't build. This happens on certain computers and virtual machines but the same symlinks download fine on other computers.
The download file is often a short file which just contains path of the linked file instead of being zero byte symlink file.
This actually had to do with user permissions on windows, not so much with perforce. The problem is that the user doesn't have permission to create symlinks so perforce ends up creating a file (In my opinion, it should generate an error message instead of converting the symlink to file).
The simple solution in most cases should be to start P4V as administrator and then download the source code. You may have to force it to download everything since it will not re-download wrong symlinks because those objects already exist on disk.
You can check if you have permissions with the following command. More here.
mklink <linkFile> <ExistingFile>
Note: you may well be able to create symlinks (=shortcuts) using File Explorer but it's the command line (above) that will determine if you have the privileges or not.
Is it possible to install and run applications using the regular filesystem but make created files and changes written to a specific directory?
I want to make an application believe it is installed to the system root and remove it by just deleting one folder from my home directory. A lightweight solution would be great!
It should be possible by combining unionfs and namespace. Create a mount namespace (using unshare(1)), mount a unionfs over everything and run the application there (I haven't done it myself, so no example commands, sorry).
Take a look at mbox http://pdos.csail.mit.edu/mbox/
It intercepts system calls to a temporary directory which you can specify
I am trying to create a standalone app with a resources folder that is writable. I would like to include this in the exe, similar as to how it is done on OSX with an .app. Is this possible?
Thanks!
Assuming that you're talking about a modern Windows OS you're probably going to have problems with this even if you could come up with a solution. Most apps gets put under the Program Files directory and by default only Admins have write permissions there so it's generally seen as a bad thing to store anything the app needs to write to next to the executable in Windows.