1

I have an executable file but don't know what type or format it is. When I execute like this

$chmod +x xfile
$./xfile

It shows

Permission denied

when I run as super user

$sudo ./xfile

It shows

sudo: ./xfile: command not found

I am new to Linux please tell me how to execute it.

4
  • 1
    Try sudo sh /path/to/file/xfile
    – blade19899
    Sep 18, 2012 at 13:17
  • which type of executable is it? A python program, ruby or some binary ? Sep 18, 2012 at 14:05
  • You are doing the right process to run the file. Nevertheless, in certain cases you must use sudo chmod -x xfile in order to create the proper execution permissions over the file itself. In addition you must consider the location of the file. If it belongs to a different hard disk drive/partition or usb-memory/external-storage the command may not succed giving the proper permissions to the file for execution. Good luck! Sep 18, 2012 at 15:15
  • Once I was in trouble because I forgot the extension of the file. Did you put it?
    – Michele
    Sep 23, 2012 at 14:47

3 Answers 3

2

Strange, it works exactly that way over here.

First, try to find out what the file is:

file xfile

The file command looks inside the file and based on certain "magic" tries to figure out what that program does.

From what you describe I guess that it is a shell executable that tries to execute yet another program. If this is the case, why don't you post the code of the shell executable using http://paste.ubuntu.com.

1

Had the same problem. In my case the executable was stored on a different drive which was why chmod+x was not working.

I copied the executable to a Linux directory (like Desktop), set the permissions using chmod+x, ran the executable using "./" and it worked :)

1
  • yes, probably because of the reason in my answer.
    – cat
    Jan 23, 2016 at 0:54
0

The problem is that unless the filesystem of the device is like ext3 or ext4, (and probably it is FAT32 for you), the filesystem does not store much metadata about files, including the executable bit.

When you do chmod +x yourfile, then ls -la yourfile, you will notice the executable bit has not in fact been set.

The solution here is to cp yourfile ~/yourfile; chmod +x ~/yourfile; ~/yourfile, because the filesystem on which your Linux is installed has executable permissions.

Learn more about the *nx permissions model.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .