I'm new to Linux and saw files named "example.cmd" and "test.com".

How do I open these files? Also, what kind of files are these?

  • 1
    In Linux, filename extensions are not as important as on MS Windows. Do not rely on them much. – choroba Dec 2 '11 at 13:24
  • 1
    as in, they don't exist. People use the dotted notation for convenience only. The vast majority of the time anyhow (i.e: unless a particular app is coded in an odd way) – Sirex Dec 2 '11 at 13:45

As luke says, you should use the file utility to try to find out the truth; but my best guess is that these are actually Windows scripts/executables that have somehow found their way onto a linux system.

This means there might not be much point opening them. Still, but you could just start by trying to run the command less example.cmd or less test.com, and if you just see garbage, try hexdump. I don't know if that counts as "opening" in any useful sense, but at least you might find out something.

  • I would use strings on suspected binaries before using less. But use file first. – RedGrittyBrick Dec 2 '11 at 16:14
  • the "com" file is a ASCII text, what does that mean? – Josh Dec 2 '11 at 16:26
  • It depends on what the text is. You should definately just open it up using less or your faviourite text editor and have a look. It might be a script of some kind, if @file@ says "ASCII text" it might just be a document written by and for humans, but it might just be that it was doesn't know what kind of text it is. By the way, what is the context, where is this file and how did you get it? – Adrian Ratnapala Dec 2 '11 at 17:03

Try running the file command on the files, e.g:

file test.com

and see if it gives you any useful information.

  • when I did that, it said "the file is an ascii text" – Josh Dec 2 '11 at 16:24
  • OK, you can go ahead and run less test.com to view the contents of the file as @Adrian Ratnapala suggests. – Luke Girvin Dec 2 '11 at 16:27

Many cross-platform applications include both windows (.cmd) and unix/linux (.sh, etc) scripts, usually to start up an application. A bit more information about where you saw them, what the actual names are, etc would be needed to determine exactly what you're looking at.

.com files are a hold-over from the MS-DOS days.

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.