I'm not quite sure what just happened, all I did was running:
~/Desktop$ mv sublime.desktop \~/.local/share/applications/
The \
sign before ~/.local
came up as autocomplete, so I thought it was okay to run it.
But instead of moving the desktop file to /.local/share/applications/
(which was my intention), the command created new folder on Desktop. (The ~
was folder)
Liso@thinkpad:~/Desktop$ ls
~ backup.sql Apps
When I tried to remove ~
:
~/Desktop$ rmdir ~
rmdir: failed to remove ‘/home/liso’: Permission denied
So what am I missing actually ?
EDIT
@Ravexina ask me to ran test
command to confirm whether it was a directory or a file.
Liso@thinkpad:~/Desktop$ test -d \~ && echo "it's a dir"
it's a dir`
You didn't move your home directory...
We refer to
~
as tilde expansion, most of the times it will be replaced with the value of the$HOME
shell variable, before the command get executed.\
is the strongest type of quoting in the shell.So using
\~
you are skipping the tilde expansion by quoting it. Means that you are actually saying: move the "sublime.desktop" to a new file named exactly "~...".I can't reproduce your command's result, but somehow you ended up with a file/directory exactly named
~
.Check to see if it's a file or directory and get a list of its contents:
Then move them to the correct path, if it was a file to move it back you have to escape its name again, otherwise it will be expanded to
/home/liso
:And remember by
rmdir ~
you are trying to remove the actual home directory:/home/liso
not the~
.The tilde is expanded by the shell to the $HOME of the user, in your case
/home/liso
. In the first command you escaped the~
so it was not expanded to the location you wanted, instead it was passed literally tomv
as the symbol~
.I think you wanted to run
(with an optional trailing
/
)I would expect the command you say you ran to fail like this
because
mv
does not create destination directories like that. If you really did run that command, I think you must have already had a directory actually named~
in yourDesktop
with that path, ieand if so you will now find a file there:
And you should run
But if you ran
that would create a file
~
becausesublime.desktop
would be renamed~
. Try reading the fileIf it contains the contents of your
sublime.desktop
file, then runThe tilde character is only expanded to your home directory (among other possibilities) when it is not quoted. Putting a
\
character in front of it prevents tilde expansion. When in doubt, use$HOME
instead, as it is a regular shell variable with a predictable syntax and behavior.To remove a directory named
~
(make sure there's nothing of importance in it first), you should use the same trick as before: escape the tilde so it's interpreted literally. Oh, and you'll also need to runrm
recursively to remove a non-empty directory: