bash – Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
bash – Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
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.
While /home
happens to be the parent directory of all user-specific home directories on Linux-based systems, you shouldnt even rely on that, given that this differs across platforms: for instance, the equivalent directory on macOS is /Users
.
What all Unix platforms DO have in common are the following ways to navigate to / refer to your home directory:
- Using
cd
with NO argument changes to your home dir., i.e., makes your home dir. the working directory.- e.g.:
cd # changes to home dir; e.g., /home/jdoe
- e.g.:
- Unquoted
~
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 (seeman bash
)- e.g.:
echo ~ # outputs, e.g., /home/jdoe
- e.g.:
$HOME
– as part of either unquoted or preferably a double-quoted string – refers to your home dir.HOME
is a predefined, user-specific environment variable:- e.g.:
cd $HOME/tmp # changes to your personal folder for temp. files
- e.g.:
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 – thats why you ran into the Permission denied
error.
you can try writing the command using sudo:
sudo mkdir DirName
bash – Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
Try running fuser command
[[email protected] ~]# fuser -mv /home
USER PID ACCESS COMMAND
/home: root 2919 f.... automount
[[email protected] ~]# kill -9 2919
autofs
service is known to cause this issue.
You can use command
#service autofs stop
And try again.