# Can files/directories deleted with rm be restored?

1

Speaking in the most abstract terms, whenever you delete a file on the graphical interface, the file is "moved" to a special "buffer", a directory called trash. You can locate it in your home directory, ~/.local/share/Trash/. Files "deleted" from this directory, will be really deleted. This real deletion is what happens when you use rm on a file.

It's extremely hard to recover deleted files. Files in the file system are represented as nodes on a B-tree or the like. When a file is deleted using rm, the tree is updated, number of hardlinks are reduced, the corresponding entry in the directory listing is removed. If at all, your file had a hard link, your file is absolutely safe. You can do a file / -samefile filename. You can search the file if you remember its inode number too (this is hardly the case).

Another case is when none of the above possibilities is true. Whenever you rm a file, the file entry on the directory is removed, reducing the number of hardlinks by...

0 0
2

#### Question:

Is it possible to restore files/directories which are deleted from terminal using rm and rm -r?. If a file is deleted from graphical interface, it could be restored from trash, but how do you restore a file if it is removed using the rm utility?.

#### Solution:1

To this end I use trash-cli package and the following alias in my ~/.bashrc

alias rm=trash

The files you remove will be moved to trash, and you can see them in nautilus trashcan.

You can always access the real rm by using one of the following method:

command rm something 'rm' something \rm something

There are also commands to access the trashcan from terminal, trash-list, restore-trash (or trash-restore), trash-empty installable from package trash-cli (then see their man pages).

Last note, it is not advisable to use such an alias for super-user, because it can interfere with system operations.

#### Solution:2...

0 0
3

I am giving one general Example

Just consider your hard disk size is 80GB

From 0 to 10GB you saved PICTURES

11 to 30GB ----- PDF

31 to 60GB ----- MP3

61 to 75GB ----- TXT

If you try to save one 10GB movie then it shows No enough memory

It will not overwrite your any data because these files (PICTURES,PDF,MP3,TXT) are now protected by your file system.

Now you delete PICTURES, at that time that picture storage location will be detached by your filesystem ( That means now it is not protected by your file system, anyone can write here)

After deleteling also you can recover your PICTURES (as RedGrittyBrick said) that is because only logical address are gone, but that data are still in your hard disk in the form of bytes.

Now you saved your 10GB movie

At that time from 0 to 10GB PICTURES are replaced by this MOVIE

Now if you try to recover your PICTURES then its not possible

That is because it...

0 0
4

Hi.

In a system like:

Code:

OS, ker|rel, machine: Linux, 2.6.32-358.23.2.el6.centos.plus.x86_64, x86_64 Distribution : CentOS 6.4 (Final)
There appears to be:

Code:

extundelete.x86_64 : An ext3 and ext4 file system undeletion utility testdisk.x86_64 : Tool to check and undelete partition, PhotoRec recovers lost : files
I have no experience with either one.

This could also be considered a valuable (but difficult) learning experience:
1) Have a backup, even if minor (e.g. file.01, file.02, etc).
2) Balance extra resources with risk of losing one's time.
3) It's a rite of passage to destroy something valuable.

I consider my time to be very valuable. So I use a number of strategies to reduce risk. For example, I use virtual machines most of the time. This allows me to do a snapshot, which can restore an entire system in less than 5 minutes (and usually less). I usually do a snapshot just before a big update....

0 0
5

When attempting to remove a directory using a command such as the rmdir command, you may receive a prompt such as "rmdir: 'dir': Directory not empty" and be unable to delete the directory.

To remove a directory that contains other files or directories, use the following command.

rm -r mydir

In the example above, you would replace "mydir" with the name of the directory you want to delete. For example, if the directory was named "files", you would type rm -r files at the prompt.

Executing the above command would delete all files and directories within the directory named in the command. However, it would also present a prompt for approval to delete each of the files. If you don't want to receive a prompt for each file, use the following command instead.

rm -rf mydir

In the above example, the "mydir" directory, along with all files and directories within that directory, would be deleted with no prompt or...

0 0
6

Did this ever happen to you? You realized that you had mistakenly deleted a file – either through the Del key, or using rm in the command line.

In the first case, you can always go to the Trash, search for the file, and restore it to its original location. But what about the second case? As I am sure you probably know, the Linux command line does not send removed files anywhere – it REMOVES them. Bum. They’re gone.

Suggested Read: How to Recover Deleted Files/Directories Using Scalpel Tool

In this article we will share a tip that may be helpful to prevent this from happening to you, and a tool that you may consider using if at any point you are careless enough to do it anyway.

#### Create an alias to ‘rm -i’

The -i switch, when used with rm (and also other file-manipulation tools such as cp or mv) causes a prompt to appear before removing a file.

The same applies to copying, moving, or renaming a file in a location where one with the same name...

0 0
7

If a running program still has the deleted file open, you can recover the file through the open file descriptor in /proc/[pid]/fd/[num]. To determine if this is the case, you can attempt the following:

$lsof | grep "/path/to/file" If the above gives output of the form: progname 5383 user 22r REG 8,1 16791251 265368 /path/to/file take note of the PID in the second column, and the file descriptor number in the fourth column. Using this information you can recover the file by issuing the command:$ cp /proc/5383/fd/22 /path/to/restored/file

If you're not able to find the file with lsof, you should immediately remount the file system which housed the file read-only:

$mount -o remount,ro /dev/[partition] or unmount the file system altogether:$ umount /dev/[partition]

The reason for this is that as soon as the file has been unlinked, and there are no remaining hard links to the file in question, the underlying file system may free the blocks...

0 0
8

If you’ve accidentally deleted a file in Linux, don’t worry, you can probably still restore it as long as that area of disk has not yet been overwritten. This post will show you how to easily restore a deleted file in Linux.

Foremost is able to search a disk or raw image file to recover files based on their headers, footers, and internal data structures.

### Install Foremost

Foremost is available in many different distributions of Linux.

#### Mint/Debian/Ubuntu

We can install Foremost in Linux Mint, Debian, or Ubuntu by simply running the following command.

apt-get install foremost

#### CentOS/RHEL

By default Foremost is not available in any of the standard CentOS/RHEL repositories, so we’ll install it directly from the RPM.

yum install https://forensics.cert.org/centos/cert/7/x86_64//foremost-1.5.7-13.1.el7.x86_64.rpm -y

This RPM is for el7, el6 can be found here.

0 0
9
...
0 0
10

### Fixing the deletions

When you remove files from the index and the working tree, git will notice that files that you had in the current commit are now gone, and so git status will show that those files are deleted.

However, no need to panic. This is just Git’s way of telling you that it sees those files gone compared to the prior commit. The files still exist in the repo. In fact, if you stage all the deletions and commit right now, you’ll just have a new commit without the files, but your current commit will still exist with all the files in the repo. You can check it out at any time and it will restore those files back into the working directory.

Info on how to restore files from git rm is available in this answer.

Note: Be careful with:

git reset --hard

This will work in this case (per the other answers), but be a little careful with it – understand that while it will restore all files to the last (current) commit, that means you will lose all...

0 0
11
git resetgit reset --hardgit reset --hard [filename]git reset [filename]

But if you want the command-line option, you can use this command:

However, no need to panic. This is just Git's way of telling you that it sees those files gone compared to the prior commit. The files still exist in the repo. In fact, if you stage all the deletions and commit right now, you'll just have a new commit without the files, but your current commit will still exist with all the files in the repo. You can check it out at any time and it will restore those files back into the working directory.

If you use git reset --hard then it will clear both the index and the working directory and restore the file(s) to the original condition for the current commit - they will be unstaged with no changes - which is one...

0 0
12

Normally on this blog I tend to write about more complicated tasks or fancy Linux tricks and completely overlook some of the most basic tasks that a SysAdmin needs to know. Today I have decided that I will make my blog a little more comprehensive and add some posts with some of the basics.

Along with this I will be starting a new category, called Sysadmin Basics and I will try to post an additional article each week that covers some of the more basic concepts and commands used by Linux and Unix Sysadmins.

### Remove Directories with the rmdir command

The rmdir command is used to delete and remove empty directories. I bolded empty as it is important to note that rmdir will only remove a directory if there are no files within that directory. If you want to remove a directory and all files within that directory, skip down to the rm section of this article.

#### Remove multiple empty directories (in a single tree)

# rmdir...
0 0
13

I deleted an important directory with rm -R command. This is an very populer host data. It was located /var/zpanel/hostdata/ayrintilih After remove ayrintilih directory has gone everything.

I tried to undelete with ext4magic program. But it need to another hdd volume for recovery.

Error message:

ERROR: can not use "/root/recoveried" for recover directory. It's the same filesystem : "/dev/dm-0"

My ISP just replied my request:

Unfortunately there is no way to add another Volume to a virtual Instance. If it would be a dedicated Server, we could do it, but not in a Cloudserver. You could try to minimize the partition and create another one, that would count as another Volume. We also recommend to have allways a Backup for your Important...
0 0
14

### Deleting Folders

Deleting folders differs from deleting files because there may be any number of files inside the directory. This video shows how to delete folders whether or not they contain other folders and files.

#### Deleting Empty Folders with rmdir

Deleting directories is also a little different from the way you delete files. a command like "rm " won't work. To demonstrate, I'll try to delete the "AlsoImportant" directory with the "rm" command.

The command I'll try is this: "rm AlsoImportant/"

When I press Enter, I get the message "rm: AlsoImportant/: is a directory". This doesn't actually tell you that it failed, but if we type "ls" we'll see that the directory is still there.

There is a command "rmdir" (for remove directory) that is designed to remove (or delete) directories. This however, will only work if the directory is empty. So, if I try to delete the "AlsoImportant" directory with "rmdir" I'll get an error.

The command...

0 0
15

There are odd times where we would have accidentally deleted some important folders without having any actual backup. It happened to us, one of our team members on the way to remove a symbolic link, accidentally deleted a webfolder using rm -rf, though we normally maintain GIT repo, for this temporary project, we did not. So we had to restore it though initially it looked gloomy. I stumbled upon "extundelete" but that could not restore any important files. Then we tried http://www.cgsecurity.org/wiki/TestDisk. See more details below

In Ubuntu/Debian based system, you can install using

apt-get install testdisk

Lets say you lost the folder in /home/username/webroot, then we can try restoring the whole volume. I tried to restore all file types, so used

photorec /debug /log /d /mnt/recover/disk /cmd /dev/xvdf1 partition_none,options,mode_ext2,fileopt,everything,enable,search

/dev/xvdf1 is the actual volume that has /home/username data. You can find that using fdisk...

0 0
16

### Use Description

The rm command is commonly used commands to delete a file or directory (remove files or directories). It is also a dangerous command, when used with special care, especially for the novice, or the entire system will be destroyed in this command (such as / execute rm *-rf). So, before we execute rm best to check first in which directory, in the end you want to delete something, when to keep a cool head.

Rm wrote in the manual: use rm to delete the file it is possible to recover the file content, if either restore the deleted files, consider using the shred command. (_Warning_: If you use rm 'to remove a file, it is usually possible to recover the contents of that file. If you want more assurance that the contents are truly unrecoverable, consider using shred'.) As for specifically how to recover rm deleted files, there are articles devoted. But...

0 0
17

Alright, so all hope is apparently lost for my git history (the .git file that I foolishly obliterated) -- HOWEVER! All hope has not ultimately been lost because following the sage advice of Lincoln Spector, I was able to recover all of my deleted working directories, most of which were in their most current state, and the rest of which (and I'm still incredibly grateful for these) were just a couple of days out of date. Recuva Portable, which was just one strategy recommended there, has just saved me several days of work and several million strands of hair.

Thanks for all the answers. I'm just throwing this in because the best I got told me to use System Recovery/Windows Backup/restore points of some form or another which would have been great if only I'd been using those features prophylactically. Alas, I was not. So I had to go the dirty route. So if anyone is smart enough to have already been using those features, by all means go the routes offered in the other answers,...

0 0
18

### Recover Folder Deleted using RM command

Mac systems have a program called terminal from where the files saved in your Mac system, can be managed. It is somewhat like command prompt in Windows Operating Systems. Many users prefer to install, delete files from command prompt as it is considered as the safest way to do so. Consider a scenario; you were deleting some unwanted files from your Mac OS, but by mistake you deleted an important one. You might also remove some files using the rm command and later realizes that the files were important. Sometimes users even delete some files after taking a proper backup but due to some reasons, the backup gets corrupted and they lose the access to all the files stored in it. In each of these situations, a deleted folder recovery tool is required.

Following command is used to delete a file through Mac terminal –
rm filename

This method of deleting files & folders is considered to be permanent as the deleted...

0 0
19

Following is a recursive deletion of a directory containing an Oracle database and the recovery of the database files :
Recovery by screen shots :
Situation prior execution of 'rm -r':

Saving checksums of files to validate correct undelete later.
Recursive deletion of directory /oracle/database1:

Create new filesystem /recover to restore the deleted files, start free tool for analysis:
Information provided on Oracle tablespace, 10 files recoverable in directory /database1:
Descending into directory, 10 files recoverable:

Undelete of first file control01.ctl, validating checksum:

Creating directory /recover/data1, restore entire directory using command recoverdir

Validating checks before deletion with files recovered:

Successful undelete of Oracle database files.

0 0
20
I accidentaly deleted almost all home directory (the directory itself is remaining, but contains negligible amount of files). I interested in restoring my information, in parcticular in txt, py, ipynb files.

1. After deleteting I booted from the LiveUSB and didn't mount the Ubuntu parition (I did mount the partition containing the second OS - W7)
2. testdisks - advanced utils: restored some files, but not the ones I need
3. extundelete also didn't restored the needed files
4. scalpel failed with a mistake after a one hour of searching (unfortunately, I have not written down the error message: it was something like 'node did not found', and the laptop didn't react at all)

As far as I understand I could try GREP option with mentioning the initial string of the files (in my case it would be either '!#usr', ''', """ or 'import'). Could you please give me any advice about that option.

I also have read that I can restore the partition table via testdisk. But I...

0 0
21

When you find out the shadow copies of the deleted files were never created by your Windows OS, and Windows backups weren't set up properly,

to restore your deleted files and give it a try. You can even

restore files when deleted from the Recycle Bin

, as Windows works that way: deleted files are not physically removed, but just marked as deleted. You may not see them in Windows Explorer, but they may still be present on your hard drive. Until these deleted files are overwritten by other data, you have a good chance to recover them. With powerful Quick and Deep Scans, Lost Partition Search, Catalog Rebuild and other file recovery algorithms, you are in very good hands and have all the chances to get your data back within minutes and completely free (up to...

0 0
22

What happens if you accidently deleted something from your SEAS home directory? No need to worry, CETS has created backups for you. You can easily find them and restore then yourself from your SEAS home directory.

### The Snapshot Directory

The .snapshot directory is a special directory that holds snapshots of your files made over the last couple of weeks. It doesn't show up when you run the ls or dir commands. To get to it, type the following in a command prompt:

cd .snapshot

Inside the .snapshot directory are directories named after the dates and times that the snapshots were taken. Pick one from just before you deleted your files and cd into it. You'll see your files as they were at that time. You can copy them back into your home directory from there. Please note: The snapshots do not count against your SEAS disk usage.

### Accessing your snapshots via WS_FTP

You can access your snapshot directory using WS_FTP. Connection using these instructions,...

0 0
23

You can always access the real rm by using one of the following method You are looking for extundelete utility to recover deleted files from .You can always access the real rm by using one of the following method You are looking for extundelete utility to recover deleted files from ext ext . You will have to use data recovery software to try to recover the data from the hard drive. Can files directories deleted with rm be restored?. Is it possible to restore files directories which was deleted from terminal using rm command? If a file is deleted from graphical interface, it could . Suggested Read How to Recover Deleted Files Directories Using Scalpel Tool The i switch, when used with rm and also other file manipulation tools such as cp After foremost has finished executing, the recovered file if recovery was Be warned, however, that foremost can take quite a while to run .

How To Recover A Deleted File In Linux

Kami tidak menemukan hasil untuk data recovery can...

0 0
24

### Module 2: The Hadoop Distributed File System

#### Introduction

HDFS, the Hadoop Distributed File System, is a distributed file system designed to hold very large amounts of data (terabytes or even petabytes), and provide high-throughput access to this information. Files are stored in a redundant fashion across multiple machines to ensure their durability to failure and high availability to very parallel applications. This module introduces the design of this distributed file system and instructions on how to operate it.

#### Goals for this Module:

Understand the basic design of HDFS and how it relates to basic distributed file system concepts Learn how to set up and use HDFS from the command line Learn how to use HDFS in your applications

#### Outline

Introduction Goals for this Module Outline Distributed File System Basics Configuring HDFS Interacting With HDFS Common Example Operations HDFS Command Reference DFSAdmin Command...
0 0
25

As briefly mentioned in Section 1.17, “Alternative front-ends”, VBoxManage is the command-line interface to VirtualBox. With it, you can completely control VirtualBox from the command line of your host operating system. VBoxManage supports all the features that the graphical user interface gives you access to, but it supports a lot more than that. It exposes really all the features of the virtualization engine, even those that cannot (yet) be accessed from the GUI.

You will need to use the command line if you want to

use a different user interface than the main GUI (for example, VBoxSDL or the VBoxHeadless server);

control some of the more advanced and experimental configuration settings for a VM.

There are two main things to keep in mind when using VBoxManage: First, VBoxManage must always be used with a specific "subcommand", such as "list" or "createvm" or "startvm". All the subcommands that VBoxManage supports are ...

0 0