1

I was yesterday trying to mount a partition & playing around with firejail, when I realized I have a ${HOME} folder (written just like that) in my /etc folder, even if my home folder is in the root folder (so now I have two, the ${HOME} and the /home.) I'm wondering if this is a link I managed to somehow create. The folder appears as 0 bytes and empty from the GUI, but if I try to delete it from the command line, I get the error that the folder is not empty (plus I'm scared of deleting my entire home folder!).

What happened and why? Thanks!

ls -al '/${HOME}'

total 0
drwxr-xr-x. 1 root root 0 Dec 16 16:01 .
dr-xr-xr-x. 1 root root 172 Dec 16 16:02 ..
8
  • 2
    What does ls -al '/${HOME}' say? Commented Dec 17, 2023 at 8:08
  • 2
    if you have /${HOME} AND /home and a ${HOME} in /etc ... i.e. /etc/${HOME} then you have THREE, not TWO Commented Dec 17, 2023 at 9:45
  • Otherwise my bad, I have only two: /etc/$HOME and /home Commented Dec 17, 2023 at 12:33
  • 1
    Edit your post to add the output using code blocks please. Command output is usually unreadable in comments. Commented Dec 17, 2023 at 16:17
  • 3
    I am unclear why both your Title and your text say the problem directory is within /etc', but your ls -al '/${HOME}'` is an absolute path name that omits /etc and apparently still works. Can you clarify ? Commented Dec 17, 2023 at 22:02

1 Answer 1

2

You should be able to delete the unwanted empty directory as root quite safely:

rmdir '/${HOME}'

Or if you're not already root, then use sudo,

sudo rmdir '/${HOME}'

Notice the single quotes. These tell the shell not to treat any characters in the string specially, so it will not expand ${HOME} as a variable - it will literally use the sequence of seven characters.

Incidentally, if you had tried rmdir /${HOME} you would have attempted to delete your own home directory, because the shell would have expanded $HOME as the value of your home directory and then executed rmdir with the resulting string. Fortunately this target won't have been empty and you'll have received an error message ending, Directory not empty with a consequent no action taken.

1
  • I see, so it's about escaping characters. Thank you! Commented Dec 18, 2023 at 9:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.