Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
今いるディレクトリを消すとどうなる
Search
Osumi, Yusuke
March 13, 2021
Technology
1
350
今いるディレクトリを消すとどうなる
「新しいLinuxの教科書」を読む会 オンライン #11 での発表資料です。
https://linuxbook.connpass.com/event/204816/
Osumi, Yusuke
March 13, 2021
Tweet
Share
More Decks by Osumi, Yusuke
See All by Osumi, Yusuke
本の紹介の補足
ozuma
1
370
gitサービス3兄弟
ozuma
0
380
簡体字は楽
ozuma
0
440
ソフトウェアは固定資産
ozuma
0
410
ASCIIコードの小話
ozuma
0
420
名前付きパイプ FIFO
ozuma
0
500
文章、作文技法 リモートワーク
ozuma
1
880
CentOSの今後のリリース(簡易説明)
ozuma
0
380
AndroidでもLinux動いてるよ
ozuma
0
410
Other Decks in Technology
See All in Technology
Zero Trust DNS でより安全なインターネット アクセス
murachiakira
0
130
GCASアップデート(202508-202510)
techniczna
0
140
AIの個性を理解し、指揮する
shoota
3
550
DMMの検索システムをSolrからElasticCloudに移行した話
hmaa_ryo
0
300
組織全員で向き合うAI Readyなデータ利活用
gappy50
5
1.9k
OPENLOGI Company Profile for engineer
hr01
1
46k
CLIPでマルチモーダル画像検索 →とても良い
wm3
2
670
AI機能プロジェクト炎上の 3つのしくじりと学び
nakawai
0
180
JAWS UG AI/ML #32 Amazon BedrockモデルのライフサイクルとEOL対応/How Amazon Bedrock Model Lifecycle Works
quiver
1
360
オブザーバビリティが育むシステム理解と好奇心
maruloop
3
1.7k
SREのキャリアから経営に近づく - Enterprise Risk Managementを基に -
shonansurvivors
1
500
ラスベガスの歩き方 2025年版(re:Invent 事前勉強会)
junjikoide
0
650
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
A Tale of Four Properties
chriscoyier
161
23k
Side Projects
sachag
455
43k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Speed Design
sergeychernyshev
32
1.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
658
61k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Transcript
今いるディレクトリを 消すとどうなる @ozuma5119 1 「新しいLinuxの教科書」を読む会 オンライン #11 2021/03/13
Windowsの場合 - できない 2
Linuxの場合 - できる 3 $ ls book1.csv secret.txt $ pwd
/home/book/Documents $ rm -v -r /home/book/Documents `/home/book/Documents/secret.txt' を削除しました `/home/book/Documents/book1.csv' を削除しました ディレクトリを削除しました: `/home/book/Documents' $ pwd /home/book/Documents
4 "Documents" フォルダは消えたのにいる! *いしのなかにいる*
いるけど何もできません 5 [book@cent7 Documents]$ pwd /home/book/Documents [book@cent7 Documents]$ rm -v
-rf /home/book/Documents ディレクトリを削除しました: `/home/book/Documents' [book@cent7 Documents]$ [book@cent7 Documents]$ echo "AAA" > a.txt bash: a.txt: そのようなファイルやディレクトリはありません [book@cent7 Documents]$ ls -al 合計 0 [book@cent7 Documents]$ . と .. も無いことに注意
Linuxでファイル・ディレクトリを削除するとは 6 /home/book iノード番号 ファイル名 82490 Documents 33795498 Desktop 51812769
Downloads Documents Desktop Downloads
Linuxでファイル・ディレクトリを削除するとは 7 /home/book iノード番号 ファイル名 82490 Documents 33795498 Desktop 51812769
Downloads Documents Desktop Downloads ディレクトリエントリ(台帳)から消すだけ そのため「迷子」になる
応用編 - 消しちまった! でも別のアプリで開いてる シナリオ 1. Documents/secrets.txt をlessで見ていた 2. [Documents]
フォルダごと消してしまった $ rm -rf Documents 3. lessがopenしているFD(File Discriptor)を/procから探してコピーする 4. 復旧! 参考: https://mag.osdn.jp/06/11/23/0451251 8
9 1. ~/Documents/secrets.txt を 開いている状態で…… 2. Documentsフォルダごと消します
10 1. lessコマンドのプロセスIDを調べて 2. lsofコマンドでファイルを開いている FD(File Descriptor)を探します
11 1. プロセスID=11523, FD=4 をコピーします 2. ファイル復旧できた!
12 lessコマンドを終了させてしまうと、ファイルは 完全に見えなくなります (ただし直後は台帳から消えただけでディスク上に 残っているので、復旧できる可能性は高いです)