Kabeh file ing Linux kalebu direktori. Direktori mung klompok file.
Utamane ana rong prentah sing mbusak file lan direktori ing linux:
rm
rmdir
Sing rmdir
printah digunakake kanggo mbusak direktori kosong ing linux.
Contone, kode ing ngisor iki mbusak direktori 'gambar' sing ora ana file ing njeroné:
$ rmdir images/
Kita uga bisa nggunakake rm
printah karo -d
pilihan kanggo mbusak direktori kosong:
$ rm -d images/
Cathetan:Yen ana file ing direktori, kita ora bisa nggunakake rmdir kanggo mbusak direktori.Yen kita nyoba prentah ing ndhuwur ing direktori sing ora kosong, kita bakal entuk:
$ rmdir images/ rmdir: images/: Directory not empty
Kanggo mbusak direktori kanthi isine rekursif, gunakake rm
prentah kanthi bantahan -r
.
$ rm -r images/
Sampeyan uga bisa mbusak direktori lan kabeh isine kanthi kuat -rf
bantahan
$ rm -rf images/
Kanggo mbusak file ing linux, cukup nggunakake rm
prentah:
$ rm cat.gif
Kanggo meksa mbusak file, gunakake -f
pilihan nganggo rm
prentah:
$ rm -f cat.gif
Yen sampeyan pengin dijaluk konfirmasi sadurunge mbusak file utawa direktori, gunakake -i
pilihan nganggo rm
prentah:
$ rm -i cat.gif remove cat.gif? y
Kanggo ndeleng output file sing wis digunakake -v
pilihan:
$ rm -v cat.gif cat.gif
Kanggo mbusak sawetara file ing siji operasi, kita nggunakake *
kertu liar
Contone, kode ing ngisor iki mbusak kabeh gambar nganggo .gif
ekstensi:
ls images/ bird.png cat.gif dog.gif rm *.gif ls images/ bird.png
rm [-dfiPRrvW] file ...
Tabel ing ngisor iki nuduhake panggunaan rm
prentah karo kabeh pilihan.
+--------+---------------------------------------------------------------------------------------------------------------------+-----+-----+ | Option | Description
|
|
| +--------+---------------------------------------------------------------------------------------------------------------------+-----+-----+ | -d
| Attempt to remove directories as well as other types of files.
|
|
| | -f
| Attempt to remove the files without prompting for confirmation, regardless of the file's permissions.
|
|
| | -i
| Request confirmation before attempting to remove each file, regardless of the file's permissions
|
|
| | -P
| Overwrite regular files before deleting them.
|
|
| | -R
| Attempt to remove the file hierarchy rooted in each file argument.
|
|
| | -r
| Same as -R
|
|
| | -v
| Be verbose when deleting files, showing them as they are removed.
|
|
| | -W
| Attempt to undelete the named files. Currently, this option can only be used to recover files covered by whiteouts. |
|
| +--------+---------------------------------------------------------------------------------------------------------------------+-----+-----+