Linuxで削除されたファイルを復元するにはどうすればよいですか?
Linux で削除されたファイルを復元するにはどうすればよいですか?次の記事では、Linux で削除されたファイルを復元する方法を紹介します。一定の参考値があるので、困っている友達が参考になれば幸いです。
Linux には Windows のようなごみ箱がなく、基本的に rm -rf **
を使用してファイルを取得することはできません。
それでは、質問は次のとおりです:
Linux で誤って削除されたファイルについては、本当にソフトウェアを使って復元することはできないのでしょうか?
答えはもちろんノーです。削除されたファイルは次の可能性があります。ソフトウェアを介して回復することもできます。誤って削除したファイルの復元は、次の 2 つの状況に分類できます。
1 つは、削除後のプロセスに削除情報が存在する場合です。
もう 1 つは、削除 将来、プロセスは見つからなくなり、ツールを使用してのみ復元できます。
次に、例を使用して、誤って削除した場合の 2 つの異なる回復方法を説明します。
ファイルを誤って削除したプロセスがまだ残っている状況:
これは通常、アクティブなプロセスに継続的な標準入力または出力があることを意味します。ファイルが削除された後も、プロセス PID はまだ存在します。これは、一部のサーバーが一部のファイルを削除してもディスクが解放されない理由でもあります。
ターミナルを開いて、テスト ファイルに対して cat append 操作を実行します:
[root@docking ~]# echo "This is DeleteFile test." > deletefile.txt [root@docking ~]# ls deletefile.txt [root@docking ~]# cat >> deletefile.txt Add SomeLine into deletefile for fun.
別のターミナルを開いてファイルを表示すると、内容がはっきりと確認できます:
[root@docking ~]# ls deletefile.txt [root@docking ~]# cat deletefile.txt This is DeleteFile test. Add SomeLine into deletefile for fun.
At this次に、ファイルを削除します。 rm -f deletefile.txt
[root@docking ~]# rm -f deletefile.txt [root@docking ~]# ls #命令查看这个目录,文件已经不存在了,那么现在我们将其恢复出来。
lsof は、削除されたファイル プロセスがまだ存在するかどうかを確認します。
- #インストールされていない場合は、
yum install lsof
または
apt-get install lsof ## 1. 同様の状況では、まず lsof を使用して、削除されたファイルがまだ存在するかどうかを確認します
[root@docking ~]# lsof | grep deletefile cat 21796 root 1w REG 253,1 63 138860 /root/deletefile.txt (deleted)
2. Recovery
cp /proc/pid/fd/1 /指定されたディレクトリ/ファイル名
現在の状況のプロセス ディレクトリ (通常は /proc/pid/fd/) を入力します:
[root@docking ~]# cd /proc/21796/fd [root@docking fd]# ll 总用量 0 lrwx------ 1 root root 64 1月 18 22:21 0 -> /dev/pts/0 l-wx------ 1 root root 64 1月 18 22:21 1 -> /root/deletefile.txt (deleted) lrwx------ 1 root root 64 1月 18 22:21 2 -> /dev/pts/0
リカバリ操作:
[root@docking fd]# cp 1 ~/deletefile.txt.backup [root@docking fd]# cat ~/deletefile.txt.backup This is DeleteFile test. Add SomeLine into deletefile for fun.
3。リカバリが完了しました。
誤って削除したファイル プロセスはもう存在しません。ツールを使用して復元してください。いくつかのファイル ディレクトリを準備します
#准备一份挂载的盘 mkdir backuptest cd backuptest mkdir deletetest mkdir deletetest/innerfolder echo "Delete a folder test." > deletetest/innerfolder/deletefile.txt echo "tcpdump:x:172:72::/:/sbin/nologin" > tmppasswd
最終的に準備されたディレクトリ構造は次のとおりです。次のように:
taroballs@taroballs-PC:/media/taroballs/taroballs/backuptest$ cd .. taroballs@taroballs-PC:/media/taroballs/taroballs$ tree backuptest/ backuptest/ ├── deletetest │ └── innerfolder │ └── deletefile.txt └── tmppasswd 2 directories, 2 files
ここでディレクトリの削除を開始します
rm -rf Backuptest/<pre class='brush:php;toolbar:false;'>taroballs@taroballs-PC:/media/taroballs/taroballs$ rm -rf backuptest/
taroballs@taroballs-PC:/media/taroballs/taroballs$ ls -l
总用量 0</pre>
この場合、通常はデーモンが存在しないか、バックグラウンド プロセスがデータを入力し続けます。したがって、削除は実際に削除されます。 lsof もそれを認識できないため、ツールを使用して復元する必要があります。
次に、誤って削除したファイルの回復を開始します。
私たちが使用するツールは、extundelete サードパーティ ツールです。リカバリ手順と注意事項は次のとおりです。
- i ノードが上書きされないように、現在のパーティションに対する操作を停止します。 i ノードが上書きされた場合、基本的には復元されます。
- 大げさに言うと、たとえば、パーティションが配置されているサービスを停止し、ディレクトリが配置されているデバイスをアンインストールし、必要に応じてネットワークを切断します。
- サードパーティ ソフトウェアの回復失敗によるデータ損失を防ぐために、dd コマンドを使用して現在のパーティションをバックアップします。
- データが非常に重要な状況に適しています。これは例なので、バックアップはありません。バックアップの場合は、次の方法を検討できます: dd if=/path/filename of=/dev/vdc1
- umount コマンドを使用して、現在のデバイス パーティションをアンマウントします。または、fuser コマンド umount /dev/vdb1
- を使用します。デバイスがビジーであることを示すプロンプトが表示された場合は、fuser コマンドを使用してアンインストールを強制できます: fuser -m -v -i - k ./
- サードパーティ ツールの extundelete インストールをダウンロードし、誤って削除されたファイルを検索して復元します
extundelete のダウンロード アドレス: http://extundelete.sourceforge.net/
wget https://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2
ファイルを解凍します
tar jxvf extundelete-0.2.4.tar.bz2 このエラーが報告された場合
[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2 tar (child): bzip2:无法 exec: 没有那个文件或目录 tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now
問題を解決するには、
yum -y install bzip2 を使用してください。<pre class='brush:php;toolbar:false;'>[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2
extundelete-0.2.4/
extundelete-0.2.4/acinclude.m4
extundelete-0.2.4/missing
extundelete-0.2.4/autogen.sh
extundelete-0.2.4/aclocal.m4
extundelete-0.2.4/configure
extundelete-0.2.4/LICENSE
extundelete-0.2.4/README
...................................................</pre><pre class='brush:php;toolbar:false;'>cd extundelete-0.2.4
./configure</pre>
この手順でエラーが報告された場合
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4 configure: error: in `/root/extundelete-0.2.4': configure: error: C++ compiler cannot create executables See `config.log' for more details
使用
yum -y install gcc-c解決策.前の手順を実行した後もエラーが発生する場合は、
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4 configure: error: Can't find ext2fs library
を使用してください
yum -y install e2fsprogs e2fsprogs-devel これを解決します。 #Ubuntu の解決策は sudo apt-get install e2fslibs-dev e2fslibs-dev
予期せぬことが何も起こらなければ、configure はここで正常に完了できるはずです。
[root@docking extundelete-0.2.4]# ./configure Configuring extundelete 0.2.4 Writing generated files to disk [root@docking extundelete-0.2.4]#
最後に
makeその後、make install
<pre class='brush:php;toolbar:false;'>[root@docking extundelete-0.2.4]# make
make -s all-recursive
Making all in src
extundelete.cc: 在函数‘ext2_ino_t find_inode(ext2_filsys, ext2_filsys, ext2_inode*, std::string, int)’中:
extundelete.cc:1272:29: 警告:在 {} 内将‘search_flags’从‘int’转换为较窄的类型‘ext2_ino_t {aka unsigned int}’ [-Wnarrowing]
buf, match_name2, priv, 0};
^
[root@docking extundelete-0.2.4]# make install
Making install in src
/usr/bin/install -c extundelete &#39;/usr/local/bin&#39;</pre>
extundeleteインストールが完了しました。
df -lh
を使用してマウントを表示します: <pre class='brush:php;toolbar:false;'>taroballs@taroballs-PC:~$ df -lh
文件系统 容量 已用 可用 已用% 挂载点
udev 1.9G 0 1.9G 0% /dev
tmpfs 387M 1.8M 385M 1% /run
/dev/sda2 92G 61G 26G 71% /
tmpfs 1.9G 49M 1.9G 3% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 104G 56G 44G 57% /home
tmpfs 387M 40K 387M 1% /run/user/1000
/dev/sda4 70G 20G 47G 30% /media/taroballs/d8423f8c-d687-4c03-a7c8-06a7fb57f96d
/dev/sdb1 6.8G 4.1G 2.8G 60% /media/taroballs/taroballs
/dev/sr0 4.0G 4.0G 0 100% /media/taroballs/2018-01-16-12-36-00-00
taroballs@taroballs-PC:~$ cd /media/taroballs/taroballs/
taroballs@taroballs-PC:/media/taroballs/taroballs$</pre>
ディレクトリ /media/taroballs/taroballs
が / にマウントされていることがわかります。 dev/sdb1 このファイル システム内。
マウント ディスクをマウントします。例:
taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1 /dev/sdb1 6.8G 4.1G 2.8G 60% /media/taroballs/taroballs
このディレクトリをマウントします
taroballs@taroballs-PC:~$ umount /media/taroballs/taroballs taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1 taroballs@taroballs-PC:~$ #记得删除一定要后umount哦,不然二次写入谁也帮不了你呢。
inode ノードによる復元
taroballs@taroballs-PC:~$ mkdir recovertest
taroballs@taroballs-PC:~$ cd recovertest/
taroballs@taroballs-PC:~/recovertest$
リカバリの実行
<pre class='brush:php;toolbar:false;'>taroballs@taroballs-PC:/media/taroballs/taroballs$ sudo extundelete /dev/sdb1 --inode 2
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Group: 0
Contents of inode 2:
.
.省略N行
File name | Inode number | Deleted status
. 2
.. 2
deletetest 12 Deleted
tmppasswd 14 Deleted</pre>
削除したフォルダーはスキャンによって発見されました。ここで回復操作を実行します。
(1) 単一ファイルのリカバリ tmppasswd
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-file passwd NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Successfully restored file tmppasswd
リカバリされたファイルは、現在のディレクトリ RECOVERED_FILES に配置されます。
復元されたファイルを表示します:
taroballs@taroballs-PC:~/recovertest$ cat tmppasswd tcpdump:x:172:72::/:/sbin/nologin
(2) ディレクトリを復元します deletetest
extundelete /dev/sdb1 --restore-directory deletetest NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Searching for recoverable inodes in directory deletetest ... 5 recoverable inodes found. Looking through the directory structure for deleted files ...
(3) すべてを復元します
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-all NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Searching for recoverable inodes in directory / ... 5 recoverable inodes found. Looking through the directory structure for deleted files ... 0 recoverable inodes still lost. taroballs@taroballs-PC:~/recovertest$ tree backuptest/ ├── deletetest │ └── innerfolder │ └── deletefile.txt └── tmppasswd 2 directories, 2 files
(4) 指定された i ノードを復元します
taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-inode 14 NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. taroballs@taroballs-PC:~/recovertest$ cat file.14 tcpdump:x:172:72::/:/sbin/nologin #注意恢复inode的时候,恢复 出来的文件名和之前不一样,需要单独进行改名。
最後に
extundelete: 推荐:《linux教程》 以上がLinuxで削除されたファイルを復元するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。 の使用法を添付します。
$ extundelete --help
Usage: extundelete [options] [--] device-file
Options:
--version, -[vV] Print version and exit successfully.
--help, Print this help and exit successfully.
--superblock Print contents of superblock in addition to the rest.
If no action is specified then this option is implied.
--journal Show content of journal.
--after dtime Only process entries deleted on or after 'dtime'.
--before dtime Only process entries deleted before 'dtime'.Actions:
--inode ino Show info on inode 'ino'.
--block blk Show info on block 'blk'.
--restore-inode ino[,ino,...]
Restore the file(s) with known inode number 'ino'.
The restored files are created in ./RECOVERED_FILES with their inode number as extension (ie, file.12345).
--restore-file 'path' Will restore file 'path'. 'path' is relative to root
of the partition and does not start with a '/'
The restored file is created in the current
directory as 'RECOVERED_FILES/path'.
--restore-files 'path' Will restore files which are listed in the file 'path'.
Each filename should be in the same format as an option
to --restore-file, and there should be one per line.
--restore-directory 'path'
Will restore directory 'path'. 'path' is relative to the
root directory of the file system. The restored
directory is created in the output directory as 'path'.
--restore-all Attempts to restore everything.
-j journal Reads an external journal from the named file.
-b blocknumber Uses the backup superblock at blocknumber when opening
the file system.
-B blocksize Uses blocksize as the block size when opening the file
system. The number should be the number of bytes.
--log 0 Make the program silent.
--log filename Logs all messages to filename.--log D1=0,D2=filename Custom control of log messages with comma-separated
Examples below: list of options. Dn must be one of info, warn, or --log info,error error. Omission of the '=name' results in messages --log warn=0 with the specified level to be logged to the console.
--log error=filename If the parameter is '=0', logging for the specified
level will be turned off. If the parameter is
'=filename', messages with that level will be written
to filename.
-o directory Save the recovered files to the named directory.
The restored files are created in a directory
named 'RECOVERED_FILES/' by default.

ホットAIツール

Undress AI Tool
脱衣画像を無料で

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

Google Chromeにファイルをアップロードするのに問題がありますか?これは迷惑かもしれませんよね?電子メールにドキュメントを添付したり、ソーシャルメディアで画像を共有したり、仕事や学校の重要なファイルを送信したりするかどうかにかかわらず、スムーズなファイルのアップロードプロセスが重要です。したがって、Windows PCのChromeでファイルのアップロードが引き続き失敗している場合、イライラする可能性があります。お気に入りのブラウザを放棄する準備ができていない場合は、Windows Google Chrome 1にファイルをアップロードできない修正のヒントをいくつか紹介します。高度なトラブルシューティングのヒントについて学ぶ前に、ユニバーサル修理から始めて、以下に説明する基本的なソリューションを試すのが最善です。インターネット接続の問題のトラブルシューティング:インターネット接続

Linuxユーザーグループを管理するには、表示、作成、削除、変更、およびユーザー属性の調整の操作をマスターする必要があります。ユーザーグループ情報を表示するには、cat/etc/groupまたはgetentgroupを使用して、グループ[username]またはid [username]を使用して、ユーザーが属するグループを表示できます。 GroupAddを使用してGroupを作成し、GroupDelを使用してGIDを指定します。 GroupDelを使用して、空のグループを削除します。 USERMOD-AGを使用してユーザーをグループに追加し、USERMOD-Gを使用してメイングループを変更します。 USERMOD-Gを使用して、 /etc /groupを編集するか、VIGRコマンドを使用してグループからユーザーを削除します。 GroupMod-N(名前を変更)またはGroupMod-G(GIDの変更)を使用してグループプロパティを変更し、関連するファイルの許可を更新することを忘れないでください。

Linux Systemsでは、1。IPAまたはHOSTNAME-Iコマンドを使用してプライベートIPを表示します。 2。CurlifConfig.meまたはcurlipinfo.io/ipを使用して、パブリックIPを取得します。 3.デスクトップバージョンは、システム設定を介してプライベートIPを表示でき、ブラウザは特定のWebサイトにアクセスしてパブリックIPを表示できます。 4.一般的なコマンドは、クイックコールのためにエイリアスとして設定できます。これらの方法はシンプルで実用的で、さまざまなシナリオでのIP表示のニーズに適しています。

linuxcanrunonModesthardwarewithspecificminimumrequirements.a1ghzprocessor(x86orx86_64)が必要であり、 amshouldbeatleast512mbforcommand-lineuseor2gbfordesktopenvironments.diskspacerequiresaminimumof5–10gb、25gbisbetterforad

デジタルの世界の先駆者として、ビットコインのユニークなコード名と基礎となるテクノロジーは、常に人々の注目の焦点でした。その標準コードはBTCであり、国際標準を満たす特定のプラットフォームでXBTとしても知られています。技術的な観点からは、ビットコインは単一のコードスタイルではなく、巨大で洗練されたオープンソースソフトウェアプロジェクトです。そのコアコードは主にCで記述されており、暗号化、分散システム、経済学の原則が組み込まれているため、誰でもコードを表示、レビュー、貢献できます。

PHPコンテナが自動構造をサポートできるようにするために、コアは連続統合(CI)プロセスの構成にあります。 1. DockerFileを使用して、基本的な画像、拡張インストール、依存関係管理、許可設定など、PHP環境を定義します。 2. GitlabciなどのCI/CDツールを構成し、.gitlab-ci.ymlファイルを介してビルド、テスト、展開段階を定義して、自動構造、テスト、展開を実現します。 3. phpunitなどのテストフレームワークを統合して、コードの変更後にテストが自動的に実行されることを確認します。 4. Kubernetesなどの自動展開戦略を使用して、deployment.yamlファイルを介して展開構成を定義します。 5. DockerFileを最適化し、マルチステージ構造を採用します

Linux/MacOSのシャットダウンコマンドは、パラメーターを介してシャットダウン、再起動、およびタイミング操作を行うことができます。 1.すぐにマシンをオフにし、sudoshutdownnowまたは-h/-pパラメーターを使用します。 2。シャットダウンに時間または特定の時点を使用して、-cの使用をキャンセルします。 3. -Rパラメーターを使用して再起動し、タイミングの再開をサポートします。 4. SUDO許可の必要性に注意し、リモート操作に注意し、データの損失を避けてください。

独立したPHPタスクコンテナ環境の構築は、Dockerを通じて実装できます。特定の手順は次のとおりです。1。基礎としてDockerとDockerMomposeをインストールします。 2。DockerFileおよびCrontabファイルを保存するための独立したディレクトリを作成します。 3. dockerfileを書き込み、phpcli環境を定義し、cronと必要な拡張機能をインストールします。 4.タイミングタスクを定義するためにCrontabファイルを書きます。 5。Docker-Compose.ymlマウントスクリプトディレクトリを作成し、環境変数を構成します。 6.コンテナを起動し、ログを確認します。 Webコンテナでタイミングタスクを実行するのと比較して、独立したコンテナには、リソースの分離、純粋な環境、強力な安定性、容易な拡張の利点があります。ロギングとエラーキャプチャを確保するため
