Make directories containing subdirs using mkdir

Hello everybody, I wonder if there's a way to make a directory that contains multiple subdirectories. For example, if I want to make /home/student under the current working directory, how do I do it? Can I do it using a single mkdir command or do I have make home first, cd into it and then make student? Thanks.

mkdir -p home/student will create home (if it doesn't already exist) and home/student under the current directory (note the lack of leading slash - otherwise you're specifying an absolute path).

1 Like