2

I am copying a simple text file to a guest Linux system on VirtualBox through shared folders, but after the copy, the VM seems to think that the file is a binary (it shows up green in ls):

Is there a way I can convert this back?

The Linux distribution is SANS SIFT, which I believe runs on top of Ubuntu 14.

  • 2
    What's the originating OS? What's "file yourfile" indicate? This should help identify line endings, encoding, or that your simple text file is actually binary on the host OS. – ǝɲǝɲbρɯͽ Apr 23 '15 at 16:10
  • 1
    I think you see different attributes: the executable one x, probably -rwxrw-r--. Try with ls -l yourfile. If you want to see if it is binary check with type yourfile. Of course if so it depends on how you mounted the shared partition on the guest system. – Hastur Apr 23 '15 at 16:12
  • @Hastur Of course, executable makes more sense! – ǝɲǝɲbρɯͽ Apr 23 '15 at 16:15
5

This happens to me all the time, usually when I copy a text file generated on Windows over to my Linux server via a network share managed by samba on the server's side. Hastur is right, in the comments, and Joe Sewell in his answer, too: it's just the 'executable' permissions flag is set. My solution is:

chmod u-x,go+r filename

This makes it not-executable for my user, and readable for 'group' and for 'others'. The ,go+r part is optional, as long as you are the only one who's going to need to access the file.

EDIT: It should be possible to change the default samba behavior for these permissions. I haven't bothered to try figuring it out, but a quick Google search turned up this serverfault post that describes the first thing I would try:

I typically use SAMBA's native functionality for permissions and groups management on shares. For example..

force user=user1
force group=sharedgroup
create mask=775

You would specify these settings under the share. Be certain to reload SAMBA after the configuration change, which could be done via the init script.

Based on the comments on that question/answer, there are a number of subtle and specific settings that must be properly set. I'm able to be of no help in that regard, I'm afraid.

  • <tips hat> I'm no Linux guru, but I can at least help with this one! Glad it worked. – hBy2Py Apr 23 '15 at 16:51
  • Did you try to mount the shared folder manually? – Hastur Apr 23 '15 at 17:33
2

If you've got LS_COLORS set up with default values (or at least the defaults I've seen in RHEL), the green color of the filename doesn't mean it's binary, only that one or more executable bits are set. ls -l should give you the information you need to confirm this. Remember that, in Linux, shell scripts are text files that must be executable in order to work (well, unless you source them).

0

I think you see different attributes: the executable one x, probably now you have -rwxrw-r--. To be sure try from your guest system ls -l yourfile and you will see which attribute your file is seen.

If it is a problem of executable attribute set (x) with chmod u-x you can fix the problem.
Look at the answer of Brian to fix the problem with that reading attributes for group too.

This depends from how you mount the shared folder, with which attributes, and sadly you have to fix it again, the next time.

If you cannot do in another way, you can always try to fix it mounting them manually as suggested e.g. on serverfault and choosing the appropriate options. It is suggested

In a Linux guest, use the following command:

mount -t vboxsf [-o OPTIONS] sharename mountpoint

To mount a shared folder during boot, add the following entry to /etc/fstab:

sharename   mountpoint   vboxsf   defaults  0   0

References and notes:

  • man mount and man fstab for all the options about how to mount a partition by command-line and at boot time.
  • Virtualbox shared folder manual.
  • Old post on virtualbox forum

  • If you want to see if it is binary file check it with type yourfile, always from you guest system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.