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
re:Inventに行くまでにやっておきたいこと
nagisa53
0
620
プロダクト開発と社内データ活用での、BI×AIの現在地 / Data_Findy
sansan_randd
1
580
デザインとエンジニアリングの架け橋を目指す OPTiMのデザインシステム「nucleus」の軌跡と広げ方
optim
0
120
webpack依存からの脱却!快適フロントエンド開発をViteで実現する #vuefes
bengo4com
4
3.6k
オブザーバビリティと育てた ID管理・認証認可基盤の歩み / The Journey of an ID Management, Authentication, and Authorization Platform Nurtured with Observability
kaminashi
1
1.1k
ラスベガスの歩き方 2025年版(re:Invent 事前勉強会)
junjikoide
0
450
ゼロコード計装導入後のカスタム計装でさらに可観測性を高めよう
sansantech
PRO
1
510
仕様駆動開発を実現する上流工程におけるAIエージェント活用
sergicalsix
3
1.1k
serverless team topology
_kensh
3
240
Open Table Format (OTF) が必要になった背景とその機能 (2025.10.28)
simosako
2
380
Observability — Extending Into Incident Response
nari_ex
1
550
可観測性は開発環境から、開発環境にもオブザーバビリティ導入のススメ
layerx
PRO
4
1.6k
Featured
See All Featured
Balancing Empowerment & Direction
lara
5
700
Art, The Web, and Tiny UX
lynnandtonic
303
21k
YesSQL, Process and Tooling at Scale
rocio
173
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
620
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.7k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
354
21k
The Pragmatic Product Professional
lauravandoore
36
7k
Optimizing for Happiness
mojombo
379
70k
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コマンドを終了させてしまうと、ファイルは 完全に見えなくなります (ただし直後は台帳から消えただけでディスク上に 残っているので、復旧できる可能性は高いです)