This post assumes you have basic knowledge of bash and the terminal. If you are not
aware of these concepts I suggest visiting these posts
Changing directories in the terminal is simple. Let's start by creating a
directory named tutorial.
You will notice we used a default bash command mkdir. This command will
create the directory with the name tutorial and we can check that this
directory is created by using the ls command.
We can also make multiple directories in a single line of text at the terminal.
You will notice that we passed the flag -p to the mkdir command. This flag
tells Bash to create the directory structure and create any missing parent
directories. You can find out more about the mkdir command by typing man
mkdir on the terminal.
Again we can use ls to check if the directory is created
You can also see the whole directory structure using the
tree command
We can move up multiple directory levels by passing the directory name up to
the directory you want
We can use
tree again to see exactly where we are in the directory structure
Now let's move to the last directory we created.
From here, we can move back to the home directory by passing the
../ shorthand
to the
cd command. This moves you up one directory level at a time.
You will notice that you can move up multiple directories by combining the ../ shorthand.
Conclusion
We can use the
cd command to change directories. You can move both up or down
a directory structure. We can use the
mkdir command to create new directories, the
ls
command to list directory contents and the
tree command to list directories
and subdirectories.
Comments
Post a Comment
Please provide feedback on the post, and suggestions of what you would like to read about next