$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
今いるディレクトリを消すとどうなる
Search
Osumi, Yusuke
March 13, 2021
Technology
1
370
今いるディレクトリを消すとどうなる
「新しい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
380
gitサービス3兄弟
ozuma
0
390
簡体字は楽
ozuma
0
450
ソフトウェアは固定資産
ozuma
0
420
ASCIIコードの小話
ozuma
0
430
名前付きパイプ FIFO
ozuma
0
520
文章、作文技法 リモートワーク
ozuma
1
890
CentOSの今後のリリース(簡易説明)
ozuma
0
390
AndroidでもLinux動いてるよ
ozuma
0
420
Other Decks in Technology
See All in Technology
AWSに革命を起こすかもしれない新サービス・アップデートについてのお話
yama3133
0
500
AI時代のワークフロー設計〜Durable Functions / Step Functions / Strands Agents を添えて〜
yakumo
3
2.1k
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
130
ハッカソンから社内プロダクトへ AIエージェント「ko☆shi」開発で学んだ4つの重要要素
sonoda_mj
6
1.6k
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
19
7.5k
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
230
『君の名は』と聞く君の名は。 / Your name, you who asks for mine.
nttcom
1
110
【開発を止めるな】機能追加と並行して進めるアーキテクチャ改善/Keep Shipping: Architecture Improvements Without Pausing Dev
bitkey
PRO
1
120
Next.js 16の新機能 Cache Components について
sutetotanuki
0
170
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
220
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
160
Agent Skillsがハーネスの垣根を超える日
gotalab555
6
4k
Featured
See All Featured
Believing is Seeing
oripsolob
0
15
The untapped power of vector embeddings
frankvandijk
1
1.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
710
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
2
65
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
150
sira's awesome portfolio website redesign presentation
elsirapls
0
89
Automating Front-end Workflow
addyosmani
1371
200k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Docker and Python
trallard
47
3.7k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
Prompt Engineering for Job Search
mfonobong
0
120
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コマンドを終了させてしまうと、ファイルは 完全に見えなくなります (ただし直後は台帳から消えただけでディスク上に 残っているので、復旧できる可能性は高いです)