Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory on my linux os(Ubuntu) full of files that start with a tilde sign(e.g. example.txt~, When I look at my directury using the regular gui I don't see any files there. But when I do ls in that directory I see such files. what do these files do and how do I get rid of them?

share|improve this question

migrated from May 21 '12 at 23:24

This question came from our site for professional and enthusiast programmers.

What is the name of the directory? More common files contain tilde at the end (file.txt~), it is a traditional way of denoting backups. – choroba May 21 '12 at 21:47
up vote 1 down vote accepted

Since you seem to be having trouble, removing any file with a '~' anywhere in the file name would be as easy as adding another asterisk.

Example: rm *\~*

Strange that whatever application would place the tilde in the beginning of the file name, I've never seen that.

share|improve this answer
Forgot to mention that you should examine the permissions of the files and make sure you are allowed to remove them. I know some applications will return a "No such file or directory" if you're trying to execute them from a non privileged user account. Although I'm not sure about files... Good luck. – Pizano May 21 '12 at 23:24
Thnx, this worked! – Bentley4 May 22 '12 at 22:51
The answer's last sentence is using a mighty weird meaning of the word "beginning". – TOOGAM Jul 13 at 20:28

These are probably temporary or backup files.

Gedit will prepend a tilde to backup files

You are probably using a program that prepends a tilde for a similar purpose.

To delete them from the current directory

rm \~*

You can also use the -R flag of rm to remove recursively, but do so with caution...

share|improve this answer
When I do rm \~* in that directory I get rm: cannot remove '~*': No such file or directory. Any idea? – Bentley4 May 21 '12 at 22:38

Tildes are generally used to indicate that the file is a backup copy of another file, so they're generally not shown in Nautilus and other file managers.

In your case, it looks like you were editing a few files in Emacs or Vim and had the editor's process terminated while you were editing them.

share|improve this answer

First cd to the directory, then to remove the files use:

rm -f ./~*


rm -f ./*~
share|improve this answer
If you were using VI and typed :wq~ instead of :wq! these tilde files show up. You can type vi ./~ and see the contents. Then, if it is the file you were editing, better do a mv ./~ myfilename.extension. Then you can go about moving the files around to the saved one. Otherwise you can just delete if you successfully did a :wq! after typing :wq~ on accident. – CarComp Jul 12 '13 at 16:49

They were probably created by another program (or by accident from a mis-typed command).

If you really don't want them (you can open them up to make sure you don't need them), you can delete them just like any other file. Based on other answers it sounds like they're probably backup files.

The tilde is a special character, so you have to escape it with a backslash to refer to it from the command line.

You could delete them all with this command:

rm \~*

To view the contents of any one file, you could do this:

cat \
share|improve this answer
When I do rm \~* in that directory I get rm: cannot remove '~*': No such file or directory. The cat command does not work either. – Bentley4 May 21 '12 at 22:29
It sounds like they don't exist. What arguments are you passing to ls? – jahroy May 21 '12 at 22:36
They should exist, because when I do ls I can see them. – Bentley4 May 21 '12 at 22:38

~ is often used to indicate backup or temporary files. That is why you probably can't see them in your GUI.

You can removed them with the shell command "rm", but before you do, you probably want to consider why they are there. Perhaps your GUI or some other tool you are running creates them and is relying on them - removing them from underneath the tool may have unintended consequences.

Any particular reason you think you need to remove them?

share|improve this answer

I found that in Linux Mint if you go ls ~backup in the home folder, it shows a list of files that dont exist in the home folder, but are actually in /var/backups.

So ls ~backup == ls /var/backups.
It appears as if ~backup is a hidden folder in $HOME (~) folder, but isn't.

ls ~backup -d shows /var/backups, so it must be a Symbolic Link called ~backup which is hidden, or something more complex.

share|improve this answer

The question implies that you want to remove them using the GUI application but can't because you can't see them in the GUI. To make them visible for removal using that tool, open your GUI file manager, navigate to the directory, and press ctrl+h. This normally reveals all hidden files and directories (depends on which GUI application you are using to see the files, as ctrl+h is a shortcut command).

share|improve this answer
This doesn't really answer the question (what are they and how to get rid of them). The OP can obviously see them or wouldn't have written the question. – fixer1234 Mar 21 '15 at 18:06
@fixer1234 The question states: "When I look at my directury using the regular gui I don't see any files there. . But when I do ls in that directory I see such files. what do these files do and how do I get rid of them?". He gave an example for the file "example.txt~", the files with ~ are generally not shown in file managers, I just showed a way of showing them, and by showing them he can get rid of them. – Karl Morrison Mar 21 '15 at 18:11

Those are backup files created by text editor. you can git rid of it by changing the following setting:

  1. Open gedit text editor.
  2. Go to Edit -> Preferences from the menu. (It is on the top panel in Ubuntu now, called global menu)
  3. Select the Editor tab.
  4. Uncheck the option Create a backup copy of files before saving.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .