0
0
Linux CLIscripting~20 mins

mkdir (create directories) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
πŸŽ–οΈ
mkdir Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
πŸ’» Command Output
intermediate
1:30remaining
What is the output of this mkdir command?
You run the command mkdir -p /tmp/testdir/subdir on a Linux system. What happens if /tmp/testdir does not exist?
Linux CLI
mkdir -p /tmp/testdir/subdir
ABoth /tmp/testdir and /tmp/testdir/subdir directories are created without error.
BOnly /tmp/testdir/subdir is created; /tmp/testdir must exist first or it errors.
CThe command fails with a permission denied error.
DThe command creates a file named subdir inside /tmp/testdir.
Attempts:
2 left
πŸ’‘ Hint
The -p option helps create parent directories if missing.
πŸ’» Command Output
intermediate
1:30remaining
What error does this mkdir command produce?
You run mkdir /root/newdir as a normal user (not root). What is the expected output?
Linux CLI
mkdir /root/newdir
Amkdir: invalid option -- 'r'
BDirectory /root/newdir created successfully.
Cmkdir: missing operand
Dmkdir: cannot create directory β€˜/root/newdir’: Permission denied
Attempts:
2 left
πŸ’‘ Hint
Normal users usually cannot write inside /root directory.
πŸ“ Syntax
advanced
1:30remaining
Which mkdir command creates multiple directories at once?
You want to create three directories named dir1, dir2, and dir3 in your current folder with one command. Which option is correct?
Amkdir dir1 dir2 dir3
Bmkdir -p dir1,dir2,dir3
Cmkdir dir1; mkdir dir2; mkdir dir3
Dmkdir -m dir1 dir2 dir3
Attempts:
2 left
πŸ’‘ Hint
mkdir can take multiple directory names separated by spaces.
πŸ’» Command Output
advanced
1:30remaining
What is the effect of this mkdir command with -m option?
You run mkdir -m 700 secret. What are the permissions of the created directory?
Linux CLI
mkdir -m 700 secret
AThe directory 'secret' is created with default permissions 755.
BThe command fails with an invalid mode error.
CThe directory 'secret' is created with permissions rwx------ (only owner can read, write, execute).
DThe directory 'secret' is created with permissions rwxrwxrwx.
Attempts:
2 left
πŸ’‘ Hint
The -m option sets the permission mode of the new directory.
πŸš€ Application
expert
2:00remaining
How many directories are created by this command?
You run mkdir -p /tmp/a/b/c /tmp/a/d/e. How many new directories are created if none of these exist?
Linux CLI
mkdir -p /tmp/a/b/c /tmp/a/d/e
A2 directories: /tmp/a/b/c and /tmp/a/d/e only
B5 directories: /tmp/a, /tmp/a/b, /tmp/a/b/c, /tmp/a/d, /tmp/a/d/e
C3 directories: /tmp/a/b/c, /tmp/a/d/e, /tmp/a
D6 directories: /tmp, /tmp/a, /tmp/a/b, /tmp/a/b/c, /tmp/a/d, /tmp/a/d/e
Attempts:
2 left
πŸ’‘ Hint
The -p option creates all missing parent directories for each path.