Reputation: 373
I am following a tutorial where I have to create a directory but also pass -p
flag. I tried running it and I got a syntax failure
. So I wanted to figure out what the -p
did and found that this abbreviation is short for privileged. And found
Script runs as "suid" (caution!)
Started looking what that meant and found it meant Set User Identification and read that
– When a command or script with SUID bit set is run, its effective UID becomes that of the owner of the file, rather than of the user who is running it. Source
However, I still do not quite understand it. What is the purpose of me setting a directory to have that privilege and why should I be careful? Also, I tried looking here but I couldn't find any clarification(with the different search keywords I used). Also, not necessary.. but , why would me doing mkdir -p src/entities
give me a syntax failure? I am using Windows(but I also have a bash package for Anaconda).
Upvotes: 2
Views: 2789
Reputation: 1
"-p" creates parent directories if they don't exist.
For example:
With "-p" if "first" directory doesn't exist.
mkdir -p first/second # "first" parent directory is created
Without "-p" if "first" directory doesn't exist.
mkdir first/second # "first" parent directory is not created
mkdir: cannot create directory ‘first/second’: No such file or directory
Upvotes: 1
Reputation: 85767
It looks like you're following a Unix-ish tutorial but running the commands on Windows in cmd.exe
.
As the usage instructions say:
C:\>mkdir /?
Creates a directory.
MKDIR [drive:]path
MD [drive:]path
If Command Extensions are enabled MKDIR changes as follows:
MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:
mkdir \a\b\c\d
is the same as:
mkdir \a
chdir \a
mkdir b
chdir b
mkdir c
chdir c
mkdir d
which is what you would have to type if extensions were disabled.
Windows commands don't use -
for options (and in particular, the mkdir
command built into cmd
doesn't understand -p
).
The part about "privileged" is for the shell option -p
, as in bash -p
. It has nothing to do with mkdir -p
, which is explained in man mkdir
:
-p
,--parents
no error if existing, make parent directories as needed
But again, that only applies to the Unix mkdir
, not Windows / cmd
.
Upvotes: 2