-4

I have deleted a file and now I want it on the same place from where I have deleted? How I can check that deleted file in my system from CLI?

I tried find command but end up nothing.

sebasth
  • 14,872
  • Why do you have CentOS in title but linux-mint in tags? If you deleted a file why/where do you expect to find it? – sebasth Sep 01 '17 at 12:09
  • If you need file path you can try execute "history" if you use same account. It will display the history of terminal sessions. If you want to recover the file.. thats a different case.. – ilansch Sep 01 '17 at 12:11

1 Answers1

0

If you deleted file from CLI it's lost. You can try to recover it from disk, but you can't find it, because it's not exists.

If you want to trash-like feature in CLI you can create new folder, for example /trash and then create function in .bashrc

function rm {
    mv $@ /trash
}

It's very simple, and it won't probably handle all possible scenarios of arguments. You can also write your own 'remove tool' for example in Python, and replace standard rm command.

If you deleted file from GUI, there is probably bin folder in your home user folder. Check hidden folders (with dot at the beginning) in your home folder. According to mint doc it should be something like ~/.Trash or ~/.local/share/Trash

mrc02_kr
  • 2,003
  • Because people make mistakes, and it's easy to remove file you don't wanted to remove, especially while you testing scripts which suppose to remove some files. One good point is, I wanted to say /trash not /bin – mrc02_kr Sep 01 '17 at 12:06
  • This approach is too simple. You will have to delete files from /trash some time and cannot use rm and scripts and so on will probably make trouble. Further you overwrite existing files with the same name and lose the directory structure. If you really want a trash folder, have a look at libtrash or a snapshotting filesystem like nilfs2. – allo Sep 01 '17 at 15:02
  • @allo Thats why I wrote: "It's very simple". – mrc02_kr Sep 01 '17 at 15:40