FreeKB - mkdir (make directory)
Linux Commands - mkdir (make directory)

The mkdir command is used to make a directory. In this example, the "foo" directory is created.

mkdir /tmp/foo

 

The ls (list) command with the -l (long) option can be used to view the standard permissions and ownership of the newly created directory. By default, the standard permissions of a newly created directory will be drwxr-xr-x. The "d" indicates it is a directory. Additionally, the directory will be owned by the user that created the directory (root in this example).

ls -l /tmp
. . .
drwxr-xr-x  1  root root 4096 Sep 18 19:02 foo

 

Permission denied will be displayed if you do not have write permission to the parent directory. For example, let's say you want to create a directory under /opt. In this example, only root has write permission to the /opt directory. In other words, only root will be able to create a directory under /opt. All other users will get permission denied.

This can be resolved by giving sudo permission to the mkdir command.

ls -ld /opt
. . .
drwxr-xr-x 1 root root 4096 Sep 18 13:49

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 5b2f4 in the box below so that we can be sure you are a human.




Comments