When I type ls in the terminal, it shows the files that are present as well as the files that I have deleted. How can I see the current files only, and why does ls keep a record of deleted files?

ls shows the deleted file names followed by a tilde (~).

  • 1
    Does it shows any tild(~) symbol at the end of deleted files @Vasu
    – Ravan
    Commented Aug 23, 2015 at 10:35
  • 4
    Please include the output of ls verbatim in your question (formatted as code).
    – l0b0
    Commented Aug 23, 2015 at 10:37
  • @Ravan Yes it shows tilt symbol at the end of deleted files Commented Aug 23, 2015 at 10:39
  • they are mostly back-up files created by text editors. You can view them and If you are sure you don't want them, you can delete them as well.
    – Ron
    Commented Aug 23, 2015 at 10:40
  • 1
    of course, it will. :) see linux.about.com/od/ubuntu_doc/a/ubudg10t7.htm for more
    – Ron
    Commented Aug 23, 2015 at 11:26

3 Answers 3


ls does not cache file names. It really does show you exactly what is currently on the file system. However, as @Ravan hinted, there may be similarly named files in your directory. These are typically runtime caches or lock files created by programs such as Vim and Emacs, but could be pretty much anything. For example, if I do the following in one terminal:

$ touch foo
$ vim foo

Then I'll see the following in another terminal:

$ ls -A
foo  .foo.swp

.foo.swp is a hidden temporary file which will be deleted if Vim exits nicely.

Such files can be safely deleted if they are left around from earlier editing sessions which are no longer open. Just make sure you quote the file names, since they may contain special characters like tilde (~):

$ rm '.foo~'
  • how to delete them ? Commented Aug 23, 2015 at 10:43

You may use

printf '%s\n' *

echo *

ls -U

any one of those instead of ls reference here

The ~ symbol may runtime cache or backup files.For that refer here

I edited this after seeing your comment;use this command to delete those backup files (files with ~ symbol)

find ./ -name '*~' | xargs rm
  • Just know I edited @Ron....OP asking to see only current files..
    – Ravan
    Commented Aug 23, 2015 at 10:54
  • 2
    better now. find has a -delete option as well. So find ./ -name '*~' -delete will work as well.
    – Ron
    Commented Aug 23, 2015 at 10:55
  • @Ron the edit was helpful!! Commented Aug 23, 2015 at 11:01
  • Is there an alternative such that the tilt(~) files that are created by the editors are not shown which are shown in ls command so that i have not to delete them? Commented Aug 23, 2015 at 11:04
  • @Ravan I found that I could hide tilt files by making an alias for ls and putting it into .bashrc ..... code to put in .bashrc is alias ls="ls --ignore-backups $@" but it is not working? Commented Aug 23, 2015 at 11:16

The name followed by "~" is actually a cache file. When you delete the file it may still remain as an hidden file for the nautilus but the "ls" command will show them.

Run rm *~ to remove those files.

You must log in to answer this question.

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