pwd | cd | mkdir | rmdir command in Unix | Linux Tutorial

pwd command in Unix

pwd command prints the current working directory. It displays the current working directory in which user is present.

pwd
/home/user

cd command

cd refers to changing the current directory. It changes the current working directory to the directory specified as an argument.

cd prog1
if the file (prog1) or directory is in the current directory.

cd /bin
use absolute pathname if the file or directory is not in the current directory.

cd
reverts to the home directory.

mkdir command

mkdir is used to create directory in the current directory.

mkdir dir1
it creates a directory dir1 in the current directory.

We can also make multiple directories simultaneously.

mkdir dir dir/dir1 dir/dir2

This will first create the parent directory and then the two child directories in the parent directory. Make sure to create the parent directory before creating the child directories.


rmdir command

rmdir is used to remove a directory from the current directory.

rmdir dir/dir2 dir/dir1 dir

We cannot remove a directory unless it is empty, so first we have to make the directory empty by removing all the files inside that directory.

Comments