I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only user profile on the computer.
Here's what happened on my command line:
jdub@Snowball:~$ cd /home
jdub@Snowball:/home$ mkdir bin
mkdir: cannot create directory ‘bin’: Permission denied
As @kirbyfan64sos notes in a comment,
/home is NOT your home directory (a.k.a. home folder):
The fact that
/home is an absolute, literal path that has no user-specific component provides a clue.
/home happens to be the parent directory of all user-specific home directories on Linux-based systems, you shouldn't even rely on that, given that this differs across platforms: for instance, the equivalent directory on OS X is
What all Unix platforms DO have in common are the following ways to navigate to / refer to your home directory:
cdwith NO argument changes to your home dir., i.e., makes your home dir. the working directory.
cd # changes to home dir; e.g., '/home/jdoe'
~by itself / unquoted
~/at the start of a path string represents your home dir. / a path starting at your home dir.; this is referred to as tilde expansion (see
echo ~ # outputs, e.g., '/home/jdoe'
$HOME- as part of either unquoted or preferably a double-quoted string - refers to your home dir.
HOMEis a predefined, user-specific environment variable:
cd "$HOME/tmp" # changes to your personal folder for temp. files
Thus, to create the desired folder, you could use:
mkdir "$HOME/bin" # same as: mkdir ~/bin
Note that most locations outside your home dir. require superuser (root user) privileges in order to create files or directories - that's why you ran into the
Permission denied error.