You need sudo
every time because you cannot read the folder with your dheeraj
user.
First regain ownership of your home, but only the directory (not -R
), then show us the result of the ls -la
to see how far the issue went.
chown dheeraj:dheeraj /home/dheeraj/
chmod 750 /home/dheeraj/
ls -al .*
shows the contents of all directories in the current directory whose names begin with .
(ie all those matching the shell glob .*
)
In Bash, the .*
glob resolves to .
and ..
as well. Since .
represents the current directory, and ..
the parent directory, the contents of both of these directories, including any hidden files and directories, are shown too.1
.*
also catches hidden files in the current directory, but they are listed anyway as contents of .
As explained in What does `ls --directory` stand for? the -d
flag causes the directories themselves to be displayed, instead of their contents.
1this is also the case in dash, which is the shell symlinked to sh
in Ubuntu. However, other shells, including zsh and mksh, behave more intuitively and don't include .
and ..
when expanding .*
. It is also worth noting that, while most commands will operate on ..
and .
when they are included in a .*
glob (including chmod
and chown
- you can really mess up your system with those), the rm
command will helpfully fail by design to do so.
Best Answer
You have a typo in the directory name. It is
/etc
, not/ect
.Just to be clear, it seems you have not created a directory named
/ect
yourself so we can assume the standard name which is/etc
.I would suggest you to have a look at
man hier
to get more idea about how directories are laid out typically in Linux.