Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm following a tutorial in a book and I'm tryin to install Oracle JDK 8.

I've opened a terminal and entered the following command after the dollar prompt:

sudo mkdir -p/usr/lib/jvm/

However, it's throwing me the following error:

mkdir: invalid option -- '/'

What am I doing wrong?

share|improve this question
up vote 5 down vote accepted

You should write with a space after the option e before the directory name

sudo mkdir -p    /usr/lib/jvm/

Some words about the options and the use of the space.

In general the use of the space after the option depends from the command and the option that you intend to use. Each time you have to read the synopsis of the command. In this case you can use man mkdir.

     mkdir [OPTION]... DIRECTORY...  

       -m, --mode=MODE  
             set file mode (as in chmod), not a=rwx - umask  
       -p, --parents
             no error if existing, make parent directories as needed


If the option is written with a space you have to use the space between option and option_argument. If it is not present you have not to use it. You can see the standard links below for the complete list of rules and exceptions.

Moreover in the same command you can have two or more different way to call the same action.
So for another option with the same command you can do

mkdir A  -m a+x
mkdir A --mode=a+x

Those command are equivalent and produce the same effect, but in the first case you need the space and the second not.


  • the option -p or --parents do not requires argument and have to be separated however from the Name(s) of the directory that you want to create.

If interested you may read more from those standards IEEE Std 1003.1-2001 12.1.2 and GNU Getopt.

share|improve this answer
Guys, many thanks for your help - that sorted it. – Jon295087 Jun 20 '14 at 20:01
You're welcome: answer expanded... – Hastur Jun 20 '14 at 20:55

There needs to be a SPACE after the -p, so..

sudo mkdir -p /usr/lib/jvm/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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