Removing file from Home Directory

The screen shot of my Home Directory contains three unwanted files: Empty Bash, Empty Desktop and, Empty File. How can I delete them. Moving to Trash doesn’t work.

Much thanks,

Kate

to find out why that may be so:

in a terminal:
ls -al ~/

look at the owner of the files and their permissions

or simply do:
sudo rm ~/Empty*

if you don’t care, but just want them gone …

That will remove them (not move them to Trash, but indeed delete them) with root user permissions.

3 Likes

Or filter to keep the list short:
ls -al ~/ | grep Empty

2 Likes

… of course - I did take care of it with the second command, but did not think of all the “dotfiles” with the first :grin:

1 Like

I don’t use Gnome so this is a bit of a guess. It looks like you may have deleted the Templates directory and these files are maybe templates looking for a new home. Perhaps Gnome recreates the templates in your home directory.

This might be a relevant post to look at:

5 Likes

Thanks so much everyone. Here’s a screenshot after running ls -al ~/

How should I proceed?

Katie

Those belong in the Templates folder in your Home directory–which seems to be missing.

Please edit your reply and post the output of the command as preformatted text, not a screenshot

2 Likes

rm ~/Empty*

Why would you name files like that? - Enclosed in … I don’t know what that character ' is called.
It usually has got a special meaning to the shell.

rm will delete it no problem.
mc file manager as well
why Nautilus (Gnome) apparently has got a problem with it, I don’t know.

1 Like

Those pesky spaces in the filenames cause that. :wink:

@kay-dee You need to either insert an escape character \ preceding spaces, or easier, enclose in the single quotes.

1 Like

… or just do not use the whole file name, but just the beginning of them all (Empty)
and then a wildcard (*)
as in my example

I have replicated the file names - and their listing and deletion.
See above.

tried and verified working example … :nerd_face:

2 Likes

That should do it, yes.

Side note: I regard spaces in filenames as down to sloppy coding, etc. :wink:

maybe this from the root cause

… but they (the OP @kay-dee ) said that they can’t even move it to Trash

Whatever these files are or who or what created them -
rm in terminal has got no problem whatsoever with removing them.

Okay, just to clarify… I can move the three files to Trash. They appear in Trash and are deleted after emptying Trash. But on re-booting, they once again appear in my Home Directory. Same after running rm ~/Empty* It seems to work, but the files show up in Home on re-boot. Same for ls -al ~/ | grep Empty

Not sure how to “remove the autostart entry which creates the files” but that sounds like the exact problim I’m having. As far as “You need to either insert an escape character \ preceding spaces, or easier, enclose in the single quotes.” I’m not sure what your asking or how to do it. Sorry.

Katie

what he was trying to explain to you is that spaces in filenames are problematic.
rm Empty Bash will not work because the shell would interpret it as two strings.

To delete Empty Bash the filename must either be delimited with ’ (single quote) or the spaces must be escaped with .
i.e. rm 'Empty Bash' or rm Empty\ Bash

1 Like

You keep changing the issue.

Initially you said:


something keeps re-creating these files

The issue is not that they can’t be deleted, but why they keep being recreated.

We know that now, after twelve posts …


Some script is recreating these.

And you have no idea or recollection about what it could be?

You can reverse-search your $HOME for that script,
for example by searching for the expression “Empty” being mentioned in any file anywhere in your $HOME.

They reappear upon reboot - the cause is likely not in your $HOME …

They reappear upon each log in - the cause is likely in your $HOME …

1 Like

Let’s slow down a little here and perhaps shift focus…

This seems to be an XY Problem.

How did those files end up where they don’t belong with incorrect permissions?

:thinking:

2 Likes

… permissions seem o.k. - that of the user, but only read for the user group … :man_shrugging:

But OP didn’t bother to remove the screenshot in favor of copy/pasted text …

1 Like

This is more of a problem for scripting… let’s play:

mkdir test && cd test && touch Empty.txt Empty\ Bash.txt Bash.txt && ls

So now you have THREE files, with possible problems deleting…

The way to do this is to type ‘rm’ and then start typing 'Em` and hit your tab… for me, this brings up two options - and hitting TAB again takes me through them, hitting Enter will remove the highlighted option…

This works great in FISH, quite well also in ZSH, though admittedly in my screenshot rm gets expanded to rm -rvd (just as I normally would type ‘mkcd test’ to make and then enter ‘test’.

If any of those are stubborn, then you need to add some extra power - use doas or sudo - generally pressing AltS will reprint the failed command and prepend sudo.

I set abbreviations for deleting (alias can be used in zsh and bash):

rm = rm -vdI (verbose, tells you what it does; d - removes empty diretories; I prompts if more than three files come up for deletion as a safeguard.

Interestingly, rmdir is only for empty diretories, so I abbreviated that too… so before you delete your ‘test’ folder, add another abbreviation:
rmdir1 = rm -rvdI

Then, rmdir test:
First, hit ..Enter to jump up out of test folder. Now delete it rmdir1 test:

❯ rm -rvdI test
rm: remove 1 argument recursively? y
removed 'test/Empty Bash.txt'
removed 'test/Bash.txt'
removed directory 'test'

You must hit yEnter to get it done.

TL;DR
We don’t need to type long or complicated filenames in our terminal - it really only becomes an issue if you have automation and/or scripts.

1 Like

It seems like few people are reading the thread suggested by Phemisters. How about a similar one from Reddit:

https://old.reddit.com/r/linuxquestions/comments/djlh84/3_new_files_appear_in_my_home_folder_on_startup/

The program that creates these files is /usr/bin/create-template. To stop running it on login you can run “Tweaks” click “Startup Applications” and then “Remove” next to “create-template”.

2 Likes