Daftar Isi
Di sini, saya menjelaskan tips dasar untuk mengonfigurasi dan mengelola sistem, sebagian besar dari konsol.
Ada beberapa program utilitas untuk membantu aktivitas konsol Anda.
Tabel 9.1. Daftar program untuk mendukung aktivitas konsol
paket | popcon | ukuran | deskripsi |
---|---|---|---|
mc
|
V:57, I:230 | 1508 | Lihat Bagian 1.3, “Midnight Commander (MC)” |
bsdutils
|
V:646, I:999 | 419 | perintah script untuk membuat typescript sesi terminal |
screen
|
V:102, I:268 | 1019 | pemultipleks terminal dengan emulasi terminal VT100/ANSI |
tmux
|
V:38, I:141 | 1045 | pemultipleks terminal alternatif (Gunakan "Control-B" sebagai gantinya) |
fzf
|
V:3, I:9 | 2442 | fuzzy text finder |
fzy
|
V:0, I:0 | 54 | fuzzy text finder |
rlwrap
|
V:1, I:19 | 297 | pembungkus baris perintah fitur readline |
ledit
|
V:0, I:14 | 315 | pembungkus baris perintah fitur readline |
rlfe
|
V:0, I:0 | 49 | pembungkus baris perintah fitur readline |
ripgrep
|
V:3, I:12 | 4298 | pencarian string rekursif yang cepat dalam pohon kode sumber dengan penyaringan otomatis |
Penggunaan sederhana script
(1) (lihat Bagian 1.4.9, “Merekam aktivitas shell”) untuk merekam aktivitas shell
menghasilkan berkas dengan karakter kontrol. Hal ini dapat dihindari dengan
menggunakan col
(1) sebagai berikut.
$ script Script started, file is typescript
Lakukan apapun … dan tekan Ctrl-D
untuk keluar
dari skrip
.
$ col -bx < typescript > cleanedfile $ vim cleanedfile
Ada metode alternatif untuk merekam aktivitas shell:
Menggunakan tee
(dapat digunakan selama proses boot di
initramfs):
$ sh -i 2>&1 | tee typescript
Menggunakan gnome-terminal
dengan penyangga baris yang
dinaikkan untuk gulir balik.
Menggunakan screen
dengan "^A H
"
(lihat Bagian 9.1.2, “Program screen”) untuk melakukan perekaman
konsol.
Menggunakan vim
dengan ":terminal
"
untuk memasuki mode terminal. Gunakan "Ctrl-W N
" untuk
keluar dari mode terminal ke mode normal. Gunakan ":w
typescript
" untuk menulis penyangga ke berkas.
Menggunakan emacs
dengan "M-x shell
",
"M-x eshell
", atau "M-x term
" untuk
memasuki konsol rekaman. Gunakan "C-x C-w
" untuk menulis
penyangga ke berkas.
screen
(1) tidak hanya memungkinkan satu jendela terminal
bekerja dengan beberapa proses, tetapi juga memungkinkan proses shell jarak jauh untuk bertahan dari koneksi yang
terputus. Berikut adalah skenario penggunaan
screen
(1) yang biasa.
Anda masuk ke mesin remote.
Anda memulai screen
pada satu konsol.
Anda menjalankan beberapa program di jendela screen
yang
dibuat dengan ^A c
("Control-A" diikuti oleh "c").
Anda beralih di antara beberapa jendela screen
dengan
^A n
("Control-A" diikuti oleh "n").
Tiba-tiba Anda harus meninggalkan terminal Anda, tetapi Anda tidak ingin kehilangan pekerjaan aktif Anda dengan mempertahankan koneksi.
Anda dapat melepaskan sesi
layar
dengan metode apa pun.
Secara brutal mencabut koneksi jaringan Anda
Mengetik ^A d
("Control-A" diikuti oleh "d") dan keluar
secara manual dari sambungan jarak jauh
Ketik ^A DD
("Control-A" diikuti oleh "DD") agar
layar
terlepas dan log Anda keluar
Anda masuk lagi ke mesin remote yang sama (bahkan dari terminal yang berbeda).
Anda memulai screen
sebagai "screen
-r
".
screen
secara ajaib memasang
kembali semua jendela screen
sebelumnya dengan
semua program aktif berjalan.
![]() |
Tip |
---|---|
Anda dapat menghemat biaya koneksi dengan |
Dalam sesi screen
, semua masukan papan ketik dikirim ke
jendela Anda saat ini kecuali untuk penekanan tombol perintah. Semua
penekanan tombol perintah screen
dimasukkan dengan
mengetik ^A
("Control-A") ditambah satu tombol [ditambah
parameter apa pun]. Berikut adalah hal-hal penting untuk diingat.
Tabel 9.2. Daftar pengikatan tombol untuk screen
pengikatan tombol | arti |
---|---|
^A ? |
memperlihatkan layar bantuan (menampilkan pengikatan tombol) |
^A c |
membuat jendela baru dan beralih ke jendela itu |
^A n |
pergi ke jendela berikutnya |
^A p |
pergi ke jendela sebelumnya |
^A 0 |
masuk ke jendela nomor 0 |
^A 1 |
masuk ke jendela nomor 1 |
^A w |
memperlihatkan daftar jendela |
^A a |
mengirim Ctrl-A ke jendela saat ini sebagai masukan papan ketik |
^A h |
menulis hardcopy jendela saat ini ke berkas |
^A H |
memulai/mengakhiri mencatat jendela saat ini ke berkas |
^A ^X |
mengunci terminal (dilindungi kata sandi) |
^A d |
melepas sesi screen dari terminal |
^A DD |
melepas sesi screen dan log keluar |
Lihat screen
(1) untuk detailnya.
Lihat tmux
(1)untuk fungsionalitas dari perintah
alternatif.
Pada Bagian 1.4.2, “Menyesuaikan bash”, 2 tips untuk memungkinkan navigasi
cepat di sekitar direktori dijelaskan: $CDPATH
dan
mc
.
Jika Anda menggunakan program filter teks fuzzy, Anda dapat melakukannya
tanpa mengetik path yang tepat. Untuk fzf
, sertakan yang
berikut dalam ~/.bashrc
.
FZF_KEYBINDINGS_PATH=/usr/share/doc/fzf/examples/key-bindings.bash if [ -f $FZF_KEYBINDINGS_PATH ]; then . $FZF_KEYBINDINGS_PATH fi FZF_COMPLETION_PATH=/usr/share/doc/fzf/examples/completion.bash if [ -f $FZF_COMPLETION_PATH ]; then . $FZF_COMPLETION_PATH fi
Sebagai contoh:
Anda dapat melompat ke subdirektori yang sangat dalam dengan upaya minimal.
Anda pertama mengetik "cd **
" dan menekan
Tab
. Kemudian Anda akan diberi tampilan path kandidat.
Mengetikkan string path parsial, misalnya, s/d/b foo
,
akan mempersempit path kandidat. Anda memilih path yang akan digunakan oleh
cd
dengan kursor dan tombol return.
Anda dapat memilih perintah dari riwayat perintah dengan lebih efisien
dengan upaya minimal. Anda menekan Ctrl-R
di sapaan
perintah. Kemudian Anda akan dimintai perintah kandidat. Mengetikkan
string perintah parsial, misalnya, vim d
, akan
mempersempit kandidat. Anda memilih yang akan digunakan dengan kursor dan
tombol return.
Beberapa perintah seperti /usr/bin/dash
yang tidak
memiliki kemampuan penyuntingan riwayat baris perintah dapat menambahkan
fungsionalitas tersebut secara transparan dengan berjalan di bawah
rlwrap
atau yang setara.
$ rlwrap dash -i
Ini menyediakan platform yang nyaman untuk menguji titik-titik halus untuk
dash
dengan lingkungan mirip bash
yang
ramah.
Perintah rg
(1) dalam paket ripgrep
menawarkan alternatif yang lebih cepat dari perintah
grep
(1) untuk memindai pohon kode sumber bagi situasi
tipikal. Ini mengambil keuntungan dari CPU multi-core modern dan secara
otomatis menerapkan filter yang masuk akal untuk melewati beberapa berkas.
Setelah Anda mempelajari dasar-dasar vim
(1) melalui Bagian 1.4.8, “Menggunakan vim”, silakan baca "Seven habits of effective text
editing (2000)" dari Bram Moolenaar untuk memahami bagaimana
vim
harus digunakan.
![]() |
Perhatian |
---|---|
Jangan mencoba mengubah pengikatan tombol baku tanpa alasan yang sangat bagus. |
Perilaku vim
dapat diubah secara signifikan dengan
mengaktifkan fitur internalnya melalui perintah mode Ex
seperti "set ...
" untuk mengatur opsi vim.
Perintah mode Ex
ini dapat dimasukkan dalam berkas vimrc
pengguna, "~/.vimrc
" tradisional,
atau"~/.vim/vimrc
" yang ramah git. Berikut adalah contoh
yang sangat sederhana [2]:
colorscheme murphy " from /usr/share/vim/vim??/colors/*.vim filetype plugin indent on " filetype aware behavior syntax enable " Syntax highlight "set spelllang=en_us " Spell check language as en_us "set spell " Enable spell check set autoindent " Copy indent from current line set smartindent " More than autoindent (Drop/Pop after {/}) set nosmarttab " <Tab>-key always inserts blanks set backspace=indent,eol,start " Back space through everything set laststatus=2 " Always show status line set statusline=%<%f%m%r%h%w%=%y[U+%04B]%2l/%2L=%P,%2c%V
Kustomisasi sederhana untuk mengaktifkan model-aman dan IDE klasik dapat diaktifkan dengan memasang paket vim-scripts dan menambahkan yang berikut ini ke berkas vimrc pengguna.
packadd! secure-modelines packadd! winmanager let mapleader = ' ' " Toggle paste mode with <SPACE>p set pastetoggle=<leader>p " IDE-like UI for files and buffers with <space>w nnoremap <leader>w :WMToggle<CR> " Use safer keys <C-?> for moving to another window nnoremap <C-H> <C-W>h nnoremap <C-J> <C-W>j nnoremap <C-K> <C-W>k nnoremap <C-L> <C-W>l
Agar pengikatan tombol di atas berfungsi dengan baik, program terminal perlu
dikonfigurasi untuk menghasilkan "ASCII DEL" bagi tombol
Backspace
dan "Escape sequence" untuk tombol
Delete
.
Sistem paket Vim asli yang baru, bekerja dengan baik dengan
"git
" dan "git submodule
". Salah satu
contoh konfigurasi tersebut dapat ditemukan di repositori git saya: dot-vim. Ini
pada dasarnya:
Dengan menggunakan "git
" dan "git
submodule
", paket eksternal terbaru, seperti
"nama
", ditempatkan ke dalam
~/.vim/pack/*/opt/nama
dan
sejenisnya.
Dengan menambahkan baris :packadd! nama
ke berkas vimrc pengguna, paket-paket ini ditempatkan pada
runtimepath
.
Vim memuat paket-paket ini pada runtimepath
selama
inisialisasinya.
Pada akhir inisialisasinya, tag untuk dokumen yang dipasang diperbarui
dengan "helptags ALL
".
Untuk lebih lanjut, silakan mulai vim
dengan
"vim --startuptime vimstart.log
" untuk memeriksa urutan
eksekusi aktual dan waktu yang dihabiskan untuk setiap langkah.
Paket pengaya eksternal yang menarik dapat ditemukan:
Vim - editor teks di mana-mana -- Situs hulu resmi Vim dan skrip vim
VimAwsome -- Daftar pengaya Vim
vim-scripts -- Paket Debian: kumpulan skrip vim
Cukup membingungkan untuk melihat terlalu banyak cara[3] untuk mengelola dan memuat paket-paket eksternal
ini bagi vim
. Memeriksa informasi asli adalah obat
terbaik.
Tabel 9.3. Informasi tentang inisialisasi vim
ketikan tombol | informasi |
---|---|
:help package |
penjelasan tentang mekanisme paket vim |
:help runtimepath |
penjelasan tentang mekanisme runtimepath |
:version |
keadaan internal termasuk kandidat untuk berkas vimrc |
:echo $VIM |
variabel lingkungan "$VIM " yang digunakan untuk menemukan
berkas vimrc |
:set runtimepath? |
daftar direktori yang akan dicari untuk semua berkas dukungan runtime |
:echo $VIMRUNTIME |
variabel lingkungan "$VIMRUNTIME " digunakan untuk
menemukan berbagai berkas dukungan runtime yang disediakan oleh sistem |
Banyak program tradisional merekam aktivitas mereka dalam format berkas teks
di bawah direktori "/var/log/
".
logrotate
(8) digunakan untuk menyederhanakan administrasi
berkas log pada sistem yang menghasilkan banyak berkas log.
Banyak program baru merekam aktivitasnya dalam format berkas biner
menggunakan layanan Jurnal systemd-journald
(8) di bawah
direktori "/var/log/journal
".
Anda dapat mencatat data ke Jurnal systemd-journald
(8)
dari skrip shell dengan menggunakan perintah
systemd-cat
(1).
Lihat Bagian 3.4, “Pesan sistem” dan Bagian 3.3, “Pesan kernel”.
Berikut adalah penganalisis log terkenal
("~Gsecurity::log-analyzer
" dalam
aptitude
(8)).
Tabel 9.4. Daftar penganalisis log sistem
paket | popcon | ukuran | deskripsi |
---|---|---|---|
logwatch
|
V:14, I:17 | 2276 | penganalisis log dengan keluaran bagus yang ditulis dalam Perl |
fail2ban
|
V:109, I:122 | 2091 | memblokir IP-IP yang menyebabkan beberapa kesalahan otentikasi |
analog
|
V:3, I:103 | 3584 | penganalisis log server web |
awstats
|
V:8, I:13 | 6910 | penganalisis log server web yang kuat dan penuh fitur |
sarg
|
V:2, I:2 | 843 | generator laporan analisis squid |
pflogsumm
|
V:2, I:4 | 111 | Perangkum entri log Postfix |
syslog-summary
|
V:0, I:1 | 30 | merangkum isi berkas log syslog |
fwlogwatch
|
V:0, I:0 | 478 | penganalisis log firewall |
squidview
|
V:0, I:1 | 189 | memantau dan menganalisis berkas access.log squid |
swatch
|
V:0, I:0 | 101 | penampil berkas log dengan pencocokan regex, penyorotan, dan kait |
crm114
|
V:0, I:0 | 1119 | Mutilator Regex dan Filter Spam yang Dapat Dikontrol (CRM114) |
icmpinfo
|
V:0, I:0 | 44 | menafsirkan pesan ICMP |
![]() |
Catatan |
---|---|
CRM114 menyediakan infrastruktur bahasa untuk menulis filter fuzzy dengan perpustakaan regex TRE. Penggunaannya yang populer adalah filter surel spam tetapi dapat digunakan sebagai penganalisis log. |
Meskipun alat pager seperti more
(1) dan
less
(1) (lihat Bagian 1.4.5, “Pager”) dan alat
ubahan untuk menyoroti dan memformat (lihat Bagian 11.1.8, “Menyoroti dan memformat data teks polos”) dapat menampilkan
data teks dengan baik, penyunting tujuan umum (lihat Bagian 1.4.6, “Penyunting teks”) paling serbaguna dan dapat disesuaikan.
![]() |
Tip |
---|---|
Untuk |
Format tampilan baku waktu dan tanggal oleh perintah "ls
-l
" tergantung pada lokal
(lihat Bagian 1.2.6, “Stempel waktu” untuk nilainya). Variabel
"$LANG
" dirujuk terlebih dahulu dan dapat ditimpa oleh
variabel lingkungan "$LC_TIME
" atau
"$LC_ALL
" yang diekspor.
Format tampilan baku aktual untuk setiap lokal tergantung pada versi pustaka
C standar (paket libc6
) yang digunakan. Yaitu, rilis
Debian yang berbeda memiliki baku yang berbeda. Untuk format iso, lihat
ISO 8601.
Jika Anda benar-benar ingin menyesuaikan format tampilan waktu dan tanggal
ini di luar lokal, Anda harus mengatur
nilai gaya waktu dengan argumen
"--time-style
" atau dengan nilai
"$TIME_STYLE
" (lihat ls
(1),
date
(1), "info coreutils 'ls
invocation'
").
Tabel 9.5. Menampilkan contoh waktu dan tanggal untuk perintah "ls
-l
" dengan nilai gaya waktu
nilai gaya waktu | lokal | tampilan waktu dan tanggal |
---|---|---|
iso |
any | 01-19 00:15 |
long-iso |
any | 2009-01-19 00:15 |
full-iso |
any | 2009-01-19 00:15:16.000000000 +0900 |
locale |
C |
Jan 19 00:15 |
locale |
en_US.UTF-8 |
Jan 19 00:15 |
locale |
es_ES.UTF-8 |
ene 19 00:15 |
+%d.%m.%y %H:%M |
any | 19.01.09 00:15 |
+%d.%b.%y %H:%M |
C atau en_US.UTF-8 |
19.Jan.09 00:15 |
+%d.%b.%y %H:%M |
es_ES.UTF-8 |
19.ene.09 00:15 |
![]() |
Tip |
---|---|
Anda dapat menghilangkan mengetik opsi panjang pada baris perintah menggunakan alias perintah (lihat Bagian 1.5.9, “Alias perintah”): alias ls='ls --time-style=+%d.%m.%y %H:%M' |
Shell echo ke sebagian besar terminal modern dapat diwarnai menggunakan
kode escape ANSI (lihat
"/usr/share/doc/xterm/ctlseqs.txt.gz"
).
Misalnya, coba yang berikut ini
$ RED=$(printf "\x1b[31m") $ NORMAL=$(printf "\x1b[0m") $ REVERSE=$(printf "\x1b[7m") $ echo "${RED}RED-TEXT${NORMAL} ${REVERSE}REVERSE-TEXT${NORMAL}"
Perintah berwarna berguna untuk memeriksa keluaran mereka di lingkungan
interaktif. Saya memasukkan yang berikut dalam
"~/.bashrc
".
if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=always' alias ll='ls --color=always -l' alias la='ls --color=always -A' alias less='less -R' alias ls='ls --color=always' alias grep='grep --color=always' alias egrep='egrep --color=always' alias fgrep='fgrep --color=always' alias zgrep='zgrep --color=always' else alias ll='ls -l' alias la='ls -A' fi
Penggunaan alias membatasi efek warna pada penggunaan perintah interaktif.
Ini memiliki keuntungan dibandingkan mengekspor variabel lingkungan
"export GREP_OPTIONS='--color=auto'
" karena warna dapat
dilihat di bawah program pager seperti less
(1). Jika
Anda ingin meniadakan warna saat menyalurkan ke program lain, gunakan
"--color=auto
" sebagai gantinya dalam contoh di atas
untuk "~/.bashrc
".
![]() |
Tip |
---|---|
Anda dapat mematikan alias mewarnai ini di lingkungan interaktif dengan
memanggil shell memakai " |
Anda dapat merekam aktivitas penyunting untuk pengulangan yang kompleks.
Untuk Vim, sebagai berikut.
"qa
": mulai merekam karakter yang diketik ke dalam
register bernama "a
".
… aktivitas penyunting
"q
": mengakhiri rekaman karakter yang diketik.
"@a
": jalankan isi register "a
".
Untuk Emacs, sebagai berikut.
"C-x (
": mulai mendefinisikan makro papan ketik.
… aktivitas penyunting
"C-x)
": akhir mendefinisikan makro papan ketik.
"C-x e
": jalankan makro papan ketik.
Ada beberapa cara untuk merekam gambar grafis dari aplikasi X, termasuk
tampilan xterm
.
Tabel 9.6. Daftar alat manipulasi gambar grafis
paket | popcon | ukuran | layar | perintah |
---|---|---|---|---|
gnome-screenshot
|
V:29, I:281 | 1134 | Wayland | aplikasi tangkapan layar untuk GNOME |
flameshot
|
V:7, I:13 | 2590 | Wayland | aplikasi tangkapan layar dengan steroid |
gimp
|
V:61, I:300 | 19827 | Wayland + X | tangkapan layar di menu GUI |
x11-apps
|
V:29, I:461 | 2437 | X | xwd (1) |
imagemagick
|
I:353 | 221 | X | import (1) |
scrot
|
V:7, I:74 | 126 | X | scrot (1) |
Ada alat khusus untuk merekam perubahan dalam berkas konfigurasi dengan bantuan DVCS dan untuk membuat snapshot sistem di Btrfs.
Tabel 9.7. Daftar paket yang dapat merekam riwayat konfigurasi
paket | popcon | ukuran | deskripsi |
---|---|---|---|
etckeeper
|
V:27, I:31 | 176 | menyimpan berkas konfigurasi dan metadatanya dengan Git (baku), Mercurial, atau Bazaar (baru) |
timeshift
|
V:3, I:5 | 3142 | utilitas pemulihan sistem menggunakan snapshot rsync atau BTRFS |
snapper
|
V:2, I:3 | 2170 | Alat manajemen snapshot sistem berkas Linux |
Anda juga dapat mempertimbangkan pendekatan skrip lokal Bagian 10.2.3, “Cadangan pribadi”.
Aktivitas program dapat dipantau dan dikendalikan menggunakan alat khusus.
Tabel 9.8. Daftar alat untuk memantau dan mengendalikan aktivitas program
paket | popcon | ukuran | deskripsi |
---|---|---|---|
coreutils
|
V:898, I:999 | 17372 | nice (1): menjalankan program dengan prioritas penjadwalan
yang dimodifikasi |
bsdutils
|
V:646, I:999 | 419 | renice (1): memodifikasi prioritas penjadwalan dari proses
yang berjalan |
procps
|
V:743, I:999 | 1656 | Utilitas sistem berkas "/proc ": ps (1),
top (1), kill (1),
watch (1), … |
psmisc
|
V:412, I:821 | 793 | Utilitas sistem berkas "/proc ":
killall (1), fuser (1),
peekfd (1), pstree (1) |
time
|
V:12, I:214 | 129 | time (1): menjalankan program untuk melaporkan penggunaan
sumber daya sistem sehubungan dengan waktu |
sysstat
|
V:160, I:182 | 1923 | sar (1), iostat (1),
mpstat (1), …: alat kinerja sistem untuk Linux |
isag
|
V:0, I:4 | 117 | Grafer Aktivitas Sistem Interaktif untuk sysstat |
lsof
|
V:388, I:944 | 451 | lsof (8): daftar berkas yang dibuka oleh proses berjalan
menggunakan opsi "-p " |
strace
|
V:15, I:141 | 2367 | strace (1): melacak panggilan sistem dan sinyal |
ltrace
|
V:1, I:19 | 363 | ltrace (1): melacak panggilan pustaka |
xtrace
|
V:0, I:0 | 353 | xtrace (1): melacak komunikasi antara klien dan server X11 |
powertop
|
V:11, I:210 | 672 | powertop (1): informasi tentang penggunaan daya sistem |
cron
|
V:814, I:996 | 263 | menjalankan proses sesuai dengan jadwal di latar belakang dari daemon
cron (8) |
anacron
|
V:404, I:475 | 107 | penjadwal perintah seperti cron untuk sistem yang tidak berjalan 24 jam sehari |
at
|
V:136, I:240 | 169 | at (1) atau batch (1): menjalankan
pekerjaan pada waktu tertentu atau di bawah tingkat beban tertentu |
![]() |
Tip |
---|---|
Paket |
Menampilkan waktu yang digunakan oleh proses yang dipanggil oleh perintah.
# time some_command >/dev/null real 0m0.035s # time on wall clock (elapsed real time) user 0m0.000s # time in user mode sys 0m0.020s # time in kernel mode
Suatu nilai nice digunakan untuk mengontrol prioritas penjadwalan untuk proses tersebut.
Tabel 9.9. Daftar nilai nice untuk prioritas penjadwalan
nilai nice | prioritas penjadwalan |
---|---|
19 | proses prioritas terendah (nice) |
0 | proses prioritas sangat tinggi untuk pengguna |
-20 | proses prioritas yang sangat tinggi untuk root (tidak-nice) |
# nice -19 top # very nice # nice --20 wodim -v -eject speed=2 dev=0,0 disk.img # very fast
Terkadang nilai nice yang ekstrem lebih berbahaya daripada baik untuk sistem. Gunakan perintah ini dengan hati-hati.
Perintah ps
(1) pada sistem Debian mendukung fitur BSD dan
SystemV dan membantu mengidentifikasi aktivitas proses secara statis.
Tabel 9.10. Daftar gaya perintah ps
gaya | perintah tipikal | fitur |
---|---|---|
BSD | ps aux |
display %CPU %MEM |
System V | ps -efH |
tampilkan PPID |
Untuk proses anak zombie (mati), Anda dapat membunuh mereka dengan id proses
induk yang diidentifikasi di bidang "PPID
".
Perintah pstree
(1) menampilkan pohon proses.
top
(1) pada sistem Debian memiliki fitur yang kaya dan
membantu mengidentifikasi proses apa yang bertindak aneh secara dinamis.
Ini adalah program layar penuh interaktif. Anda bisa mendapatkan bantuan penggunaannya dengan menekan tombol "h" dan menghentikannya dengan menekan tombol "q".
Anda dapat mencantumkan semua berkas yang dibuka oleh proses dengan ID proses (PID), misalnya 1, dengan yang berikut ini.
$ sudo lsof -p 1
PID=1 biasanya adalah program init
.
Anda dapat melacak aktivitas program dengan strace
(1),
ltrace
(1), atau xtrace
(1) untuk
panggilan dan sinyal sistem, panggilan pustaka, atau komunikasi antara klien
dan server X11.
Anda dapat melacak panggilan sistem dari perintah ls
sebagai berikut.
$ sudo strace ls
![]() |
Tip |
---|---|
Gunakan skrip strace-graph yang ditemukan di /usr/share/doc/strace/examples/ untuk membuat tampilan pohon yang bagus |
Anda juga dapat mengidentifikasi proses yang menggunakan berkas dengan
fuser
(1), misalnya untuk
"/var/log/mail.log
" dengan berikut ini.
$ sudo fuser -v /var/log/mail.log USER PID ACCESS COMMAND /var/log/mail.log: root 2946 F.... rsyslogd
Anda melihat bahwa berkas "/var/log/mail.log
" dibuka
untuk ditulis oleh perintah rsyslogd
(8).
Anda juga dapat mengidentifikasi proses menggunakan soket dengan
fuser
(1), misalnya untuk "smtp/tcp
"
dengan yang berikut.
$ sudo fuser -v smtp/tcp USER PID ACCESS COMMAND smtp/tcp: Debian-exim 3379 F.... exim4
Sekarang Anda tahu sistem Anda menjalankan exim4
(8) untuk
menangani koneksi TCP ke port SMTP (25).
watch
(1) mengeksekusi program berulang kali dengan
interval konstan sambil menunjukkan keluarannya di layar penuh.
$ watch w
Ini menampilkan siapa yang masuk ke sistem, diperbarui setiap 2 detik.
Ada beberapa cara untuk mengulangi perintah atas berkas yang cocok dengan
beberapa kondisi, misalnya pencocokan pola glob "*.ext
".
Metode for-loop shell (lihat Bagian 12.1.4, “Loop shell”):
for x in *.ext; do if [ -f "$x"]; then command "$x" ; fi; done
Kombinasi find
(1) dan xargs
(1):
find . -type f -maxdepth 1 -name '*.ext' -print0 | xargs -0 -n 1 command
find
(1) dengan opsi "-exec
" dengan
suatu perintah:
find . -type f -maxdepth 1 -name '*.ext' -exec command '{}' \;
find
(1) dengan opsi "-exec
" dengan
skrip shell pendek:
find . -type f -maxdepth 1 -name '*.ext' -exec sh -c "command '{}' && echo 'successful'" \;
Contoh di atas ditulis untuk memastikan penanganan yang tepat dari nama
berkas aneh seperti yang berisi spasi. Lihat Bagian 10.1.5, “Idiom untuk pemilihan berkas” untuk penggunaan
find
(1) pada tingkat lanjut.
Untuk antarmuka baris perintah
(CLI), program pertama dengan nama yang cocok yang ditemukan di
direktori yang ditentukan dalam variabel lingkungan $PATH
dijalankan. Lihat Bagian 1.5.3, “Variabel "$PATH
"”.
Untuk antarmuka pengguna grafis
(GUI) yang sesuai dengan standar freedesktop.org, berkas
*.desktop
di direktori
/usr/share/applications/
memberikan atribut yang
diperlukan untuk tampilan menu GUI dari setiap program. Setiap paket yang
sesuai dengan sistem menu xdg Freedesktop.org memasang data menu yang
disediakan oleh "*.desktop" di bawah "/usr/share/applications/". Lingkungan
desktop modern yang sesuai dengan standar Freedesktop.org menggunakan data
ini untuk menghasilkan menu mereka menggunakan paket xdg-utils. Lihat
"/usr/share/doc/xdg-utils/README".
Misalnya, berkas chromium.desktop
mendefinisikan atribut
untuk "Peramban Web Chromium" seperti "Name" untuk nama program, "Exec"
untuk path eksekusi program dan argumen, "Icon" untuk ikon yang digunakan,
dll. (lihat Spesifikasi Entri
Desktop) sebagai berikut:
[Desktop Entry] Version=1.0 Name=Chromium Web Browser GenericName=Web Browser Comment=Access the Internet Comment[fr]=Explorer le Web Exec=/usr/bin/chromium %U Terminal=false X-MultipleArgs=false Type=Application Icon=chromium Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https; StartupWMClass=Chromium StartupNotify=true
Ini adalah deskripsi yang terlalu disederhanakan. Berkas
*.desktop
dipindai sebagai berikut.
Lingkungan desktop mengatur variabel lingkungan
$XDG_DATA_HOME
dan $XDG_DATA_DIR
.
Misalnya, di bawah GNOME 3:
$XDG_DATA_HOME
tidak ditata. (Nilai baku
$HOME/.local/share
digunakan.)
$XDG_DATA_DIRS
diatur ke
/usr/share/gnome:/usr/local/share/:/usr/share/
.
Jadi direktori dasar (lihat Spesifikasi Direktori Dasar
XDG) dan direktori applications
adalah sebagai
berikut.
$HOME/.local/share/
→
$HOME/.local/share/applications/
/usr/share/gnome/
→
/usr/share/gnome/applications/
/usr/local/share/
→
/usr/local/share/applications/
/usr/share/
→ /usr/share/applications/
Berkas *.desktop
dipindai dalam direktori
applications
ini dalam urutan ini.
![]() |
Tip |
---|---|
Entri menu GUI ubahan pengguna dapat dibuat dengan menambahkan berkas
|
![]() |
Tip |
---|---|
Demikian pula, jika berkas |
![]() |
Tip |
---|---|
Demikian pula, jika berkas |
Some programs start another program automatically. Here are check points for customizing this process.
Menu konfigurasi aplikasi:
Desktop GNOME3: "Pengaturan" → "Sistem" → "Detail" → "Aplikasi Baku"
Desktop KDE: "K" → "Pusat Kontrol" → "Komponen KDE" → "Pemilih Komponen"
Peramban Iceweasel: "Sunting" → "Preferensi" → "Aplikasi"
mc
(1): "/etc/mc/mc.ext
"
Environment variables such as "$BROWSER
",
"$EDITOR
", "$VISUAL
", and
"$PAGER
" (see environ
(7))
Sistem update-alternatives
(1) untuk program seperti
"editor
", "view
",
"x-www-browser
", "gnome-www-browser
",
dan"www-browser
" (lihat Bagian 1.4.7, “Menyiapkan penyunting teks default”)
isi berkas "~/.mailcap
" dan
"/etc/mailcap
" yang mengaitkan jenis MIME dengan program (lihat
mailcap
(5))
The "~/.mime.types
" and
"/etc/mime.types
" file contents which associate file name
extension with MIME type (see
run-mailcap
(1))
![]() |
Tip |
---|---|
|
![]() |
Tip |
---|---|
The |
![]() |
Tip |
---|---|
In order to run a console application such as # cat /usr/local/bin/mutt-term <<EOF #!/bin/sh gnome-terminal -e "mutt \$@" EOF # chmod 755 /usr/local/bin/mutt-term |
![]() |
Tip |
---|---|
GUI application can be executed easily under specific environment variables
if the program for "Exec" in its corresponding # cat /usr/local/bin/kitty <<EOF #!/bin/sh GLFW_IM_MODULE=ibus exec /usr/bin/kitty "\$@" EOF # chmod 755 /usr/local/bin/kitty This |
Use kill
(1) to kill (or send a signal to) a process by
the process ID.
Use killall
(1) or pkill
(1) to do the
same by the process command name and other attributes.
Tabel 9.11. Daftar sinyal yang sering digunakan untuk perintah bunuh
nilai sinyal | nama sinyal | aksi | catatan |
---|---|---|---|
0 | --- | tidak ada sinyal yang dikirim (lihat kill (2)) |
memeriksa apakah proses sedang berjalan |
1 | SIGHUP | mengakhiri proses | disconnected terminal (signal hang up) |
2 | SIGINT | mengakhiri proses | interupsi dari papan ketik (CTRL-C ) |
3 | SIGQUIT | terminate the process and dump core | berhenti dari papan ketik (CTRL-\ ) |
9 | SIGKILL | mengakhiri proses | unblockable kill signal |
15 | SIGTERM | mengakhiri proses | sinyal pengakhiran yang dapat diblokir |
Jalankan perintah at
(1) untuk menjadwalkan pekerjaan satu
kali dengan yang berikut.
$ echo 'command -args'| at 3:40 monday
Use cron
(8) to schedule tasks regularly. See
crontab
(1) and crontab
(5).
You can schedule to run processes as a normal user,
e.g. foo
by creating a crontab
(5) file
as "/var/spool/cron/crontabs/foo
" with "crontab
-e
" command.
Here is an example of a crontab
(5) file.
# use /bin/sh to run commands, no matter what /etc/passwd says SHELL=/bin/sh # mail any output to paul, no matter whose crontab this is MAILTO=paul # Min Hour DayOfMonth Month DayOfWeek command (Day... are OR'ed) # run at 00:05, every day 5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 # run at 14:15 on the first of every month -- output mailed to paul 15 14 1 * * $HOME/bin/monthly # run at 22:00 on weekdays(1-5), annoy Joe. % for newline, last % for cc: 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%.%% 23 */2 1 2 * echo "run 23 minutes after 0am, 2am, 4am ..., on Feb 1" 5 4 * * sun echo "run at 04:05 every Sunday" # run at 03:40 on the first Monday of each month 40 3 1-7 * * [ "$(date +%a)" == "Mon" ] && command -args
![]() |
Tip |
---|---|
For the system not running continuously, install the
|
![]() |
Tip |
---|---|
For scheduled system maintenance scripts, you can run them periodically from
root account by placing such scripts in
" |
Systemd has low level capability to schedule
programs to run without cron
daemon. For example,
/lib/systemd/system/apt-daily.timer
and
/lib/systemd/system/apt-daily.service
set up daily apt
download activities. See systemd.timer
(5) .
Pressing Alt-SysRq (PrtScr) followed by one keys does the magic of rescuing control of the system.
Tabel 9.12. List of notable SAK command keys
tombol setelah Alt-SysRq | deskripsi tindakan |
---|---|
k |
kill all processes on the current virtual console (SAK) |
s |
sync all mounted filesystems to avoid data corruption |
u |
remount all mounted filesystems read-only (umount) |
r |
restore the keyboard from raw mode after X crashes |
See more on Linux kernel user’s and administrator’s guide » Linux Magic System Request Key Hacks
![]() |
Tip |
---|---|
From SSH terminal etc., you can use the Alt-SysRq feature by writing to the
" |
The current (2021) Debian amd64 Linux kernel has
/proc/sys/kernel/sysrq=438=0b110110110
:
2 = 0x2 - enable control of console logging level (ON)
4 = 0x4 - enable control of keyboard (SAK, unraw) (ON)
8 = 0x8 - enable debugging dumps of processes etc. (OFF)
16 = 0x10 - enable sync command (ON)
32 = 0x20 - enable remount read-only (ON)
64 = 0x40 - enable signaling of processes (term, kill, oom-kill) (OFF)
128 = 0x80 - allow reboot/poweroff (ON)
256 = 0x100 - allow nicing of all RT tasks (ON)
Anda dapat memeriksa siapa yang ada di sistem dengan berikut ini.
who
(1) menunjukkan siapa yang sedang log masuk.
w
(1) menunjukkan siapa yang sedang log masuk dan apa yang
mereka lakukan.
last
(1) menampilkan daftar pengguna terakhir yang masuk.
lastb
(1) shows listing of last bad logged in users.
![]() |
Tip |
---|---|
" |
Anda dapat mengirim pesan ke semua orang yang masuk ke sistem dengan
wall
(1) dengan berikut ini.
$ echo "We are shutting down in 1 hour" | wall
For the PCI-like devices (AGP, PCI-Express,
CardBus, ExpressCard, etc.), lspci
(8)
(probably with "-nn
" option) is a good start for the
hardware identification.
Atau, Anda dapat mengidentifikasi perangkat keras dengan membaca isi
"/proc/bus/pci/devices
" atau meramban pohon direktori di
bawah "/sys/bus/pci
" (lihat Bagian 1.2.12, “procfs dan sysfs”).
Tabel 9.13. Daftar alat identifikasi perangkat keras
paket | popcon | ukuran | deskripsi |
---|---|---|---|
pciutils
|
V:216, I:991 | 196 | Utilitas PCI Linux: lspci (8) |
usbutils
|
V:73, I:862 | 325 | Utilitas USB Linux: lsusb (8) |
nvme-cli
|
V:6, I:12 | 1105 | Utilitas NVMe untuk Linux: nvme (1) |
pcmciautils
|
V:10, I:16 | 97 | PCMCIA utilities for Linux: pccardctl (8) |
scsitools
|
V:0, I:3 | 375 | collection of tools for SCSI hardware management:
lsscsi (8) |
procinfo
|
V:0, I:11 | 136 | system information obtained from "/proc ":
lsdev (8) |
lshw
|
V:13, I:96 | 906 | information about hardware configuration: lshw (1) |
discover
|
V:38, I:951 | 98 | sistem identifikasi perangkat keras: discover (8) |
Although most of the hardware configuration on modern GUI desktop systems such as GNOME and KDE can be managed through accompanying GUI configuration tools, it is a good idea to know some basics methods to configure them.
Tabel 9.14. Daftar alat konfigurasi perangkat keras
paket | popcon | ukuran | deskripsi |
---|---|---|---|
console-setup
|
V:109, I:963 | 420 | Fonta konsol Linux dan utilitas keytable |
x11-xserver-utils
|
V:295, I:524 | 570 | X server utilities: xset (1),
xmodmap (1) |
acpid
|
V:118, I:242 | 169 | daemon to manage events delivered by the Advanced Configuration and Power Interface (ACPI) |
acpi
|
V:13, I:227 | 45 | utilitas untuk menampilkan informasi pada perangkat ACPI |
sleepd
|
V:0, I:0 | 86 | daemon to put a laptop to sleep during inactivity |
hdparm
|
V:304, I:561 | 256 | optimasi akses hard disk (lihat Bagian 9.6.9, “Optimalisasi hard disk”) |
smartmontools
|
V:174, I:229 | 2117 | mengontrol dan memantau sistem penyimpanan menggunakan S.M.A.R.T. |
setserial
|
V:5, I:8 | 117 | koleksi alat untuk manajemen port serial |
memtest86+
|
V:1, I:26 | 2451 | koleksi alat untuk manajemen perangkat keras memori |
scsitools
|
V:0, I:3 | 375 | koleksi alat untuk manajemen perangkat keras SCSI |
setcd
|
V:0, I:1 | 35 | compact disc drive access optimization |
big-cursor
|
I:1 | 28 | kursor tetikus yang lebih besar untuk X |
Here, ACPI is a newer framework for the power management system than APM.
![]() |
Tip |
---|---|
CPU frequency scaling on modern system is governed by kernel modules such as
|
The following sets system and hardware time to MM/DD hh:mm, CCYY.
# date MMDDhhmmCCYY # hwclock --utc --systohc # hwclock --show
Times are normally displayed in the local time on the Debian system but the hardware and system time usually use UTC(GMT).
If the hardware time is set to UTC, change the setting to
"UTC=yes
" in the "/etc/default/rcS
".
The following reconfigure the timezone used by the Debian system.
# dpkg-reconfigure tzdata
If you wish to update system time via network, consider to use the NTP service with the packages such as
ntp
, ntpdate
, and
chrony
.
![]() |
Tip |
---|---|
Under systemd, use
|
Lihat yang berikut.
![]() |
Tip |
---|---|
|
There are several components to configure character console and
ncurses
(3) system features.
The "/etc/terminfo/*/*
" file
(terminfo
(5))
The "$TERM
" environment variable
(term
(7))
setterm
(1), stty
(1),
tic
(1), and toe
(1)
If the terminfo
entry for xterm
doesn't work with a non-Debian xterm
, change your
terminal type, "$TERM
", from "xterm
"
to one of the feature-limited versions such as "xterm-r6
"
when you log in to a Debian system remotely. See
"/usr/share/doc/libncurses5/FAQ
" for more.
"dumb
" is the lowest common denominator for
"$TERM
".
Device drivers for sound cards for current Linux are provided by Advanced Linux Sound Architecture (ALSA). ALSA provides emulation mode for previous Open Sound System (OSS) for compatibility.
Application softwares may be configured not only to access sound devices directly but also to access them via some standardized sound server system. Currently, PulseAudio, JACK, and PipeWire are used as sound server system. See Debian wiki page on Sound for the latest situation.
There is usually a common sound engine for each popular desktop environment. Each sound engine used by the application can choose to connect to different sound servers.
![]() |
Tip |
---|---|
Use " |
![]() |
Tip |
---|---|
If you can not get sound, your speaker may be connected to a muted output.
Modern sound system has many outputs. |
Tabel 9.15. Daftar paket suara
For disabling the screen saver, use following commands.
Tabel 9.16. List of commands for disabling the screen saver
lingkungan | perintah |
---|---|
Konsol Linux | setterm -powersave off |
The X Window (turning off screensaver) | xset s off |
X Window (menonaktifkan DPMS) | xset -dpms |
The X Window (GUI configuration of screen saver) | xscreensaver-command -prefs |
One can always unplug the PC speaker to disable beep sounds. Removing
pcspkr
kernel module does this for you.
The following prevents the readline
(3) program used by
bash
(1) to beep when encountering an alert character
(ASCII=7).
$ echo "set bell-style none">> ~/.inputrc
There are 2 resources available for you to get the memory usage situation.
The kernel boot message in the "/var/log/dmesg
" contains
the total exact size of available memory.
free
(1) and top
(1) display information
on memory resources on the running system.
Berikut adalah contohnya.
# grep '\] Memory' /var/log/dmesg [ 0.004000] Memory: 990528k/1016784k available (1975k kernel code, 25868k reserved, 931k data, 296k init) $ free -k total used free shared buffers cached Mem: 997184 976928 20256 0 129592 171932 -/+ buffers/cache: 675404 321780 Swap: 4545576 4 4545572
You may be wondering "dmesg tells me a free of 990 MB, and free -k says 320 MB is free. More than 600 MB missing …".
Do not worry about the large size of "used
" and the small
size of "free
" in the "Mem:
" line, but
read the one under them (675404 and 321780 in the example above) and relax.
Untuk MacBook saya dengan DRAM 1GB=1048576k (sistem video mencuri sebagian dari ini), saya melihat yang berikut.
Tabel 9.17. Daftar ukuran memori yang dilaporkan
laporan | ukuran |
---|---|
Ukuran total dalam dmesg | 1016784k = 1GB - 31792k |
Bebas di dmesg | 990528k |
Total di bawah shell | 997184k |
Bebas di bawah shell | 20256k (tetapi efektifnya 321780k) |
Pemeliharaan sistem yang buruk dapat mengekspos sistem Anda ke eksploitasi eksternal.
Untuk pemeriksaan keamanan dan integritas sistem, Anda harus mulai dengan yang berikut.
Paket debsums
, lihat debsum
(1) dan
Bagian 2.5.2, “Berkas "Release" tingkat puncak dan keaslian”.
Paket chkrootkit
, lihat chkrootkit
(1).
Keluarga paket clamav
, lihat
clamscan
(1) dan freshclam
(1).
Tabel 9.18. Daftar alat untuk pemeriksaan keamanan dan integritas sistem
paket | popcon | ukuran | deskripsi |
---|---|---|---|
logcheck
|
V:7, I:9 | 102 | daemon untuk mengirimkan anomali dalam berkas log sistem ke administrator |
debsums
|
V:5, I:41 | 108 | utilitas untuk memverifikasi berkas-berkas paket yang dipasang terhadap checksum MD5 |
chkrootkit
|
V:5, I:22 | 960 | detektor rootkit |
clamav
|
V:12, I:53 | 775 | utilitas anti-virus untuk Unix - antarmuka baris perintah |
tiger
|
V:2, I:3 | 7822 | melaporkan kerentanan keamanan sistem |
tripwire
|
V:2, I:3 | 11730 | pemeriksa integritas berkas dan direktori |
john
|
V:2, I:11 | 460 | active password cracking tool |
aide
|
V:1, I:1 | 248 | Advanced Intrusion Detection Environment - biner statis |
integrit
|
V:0, I:0 | 329 | program verifikasi integritas berkas |
crack
|
V:0, I:1 | 152 | program menebak kata sandi |
Berikut adalah skrip sederhana untuk memeriksa salah izin berkas sehingga dapat ditulis oleh siapapun.
# find / -perm 777 -a \! -type s -a \! -type l -a \! \( -type d -a -perm 1777 \)
![]() |
Perhatian |
---|---|
Karena paket |
Mem-boot sistem Anda dengan CD live Linux atau CD debian-installer dalam mode penyelamatan memudahkan Anda untuk mengonfigurasi ulang penyimpanan data pada perangkat boot Anda.
You may need to umount
(8) some devices manually from the
command line before operating on them if they are automatically mounted by
the GUI desktop system.
Penggunaan ruang disk dapat dievaluasi oleh program yang disediakan oleh
paket mount
, coreutils
, dan
xdu
:
mount
(8) melaporkan semua sistem berkas yang dikait (=
disk).
df
(1) melaporkan penggunaan ruang disk untuk sistem
berkas.
du
(1) melaporkan penggunaan ruang disk untuk pohon
direktori.
![]() |
Tip |
---|---|
You can feed the output of |
For disk partition configuration,
although fdisk
(8) has been considered standard,
parted
(8) deserves some attention. "Disk partitioning
data", "partition table", "partition map", and "disk label" are all
synonyms.
Older PCs use the classic Master Boot Record (MBR) scheme to hold disk partitioning data in the first sector, i.e., LBA sector 0 (512 bytes).
Recent PCs with Unified Extensible Firmware Interface (UEFI), including Intel-based Macs, use GUID Partition Table (GPT) scheme to hold disk partitioning data not in the first sector.
Although fdisk
(8) has been standard for the disk
partitioning tool, parted
(8) is replacing it.
Tabel 9.19. List of disk partition management packages
paket | popcon | ukuran | deskripsi |
---|---|---|---|
util-linux
|
V:881, I:999 | 5037 | miscellaneous system utilities including fdisk (8) and
cfdisk (8) |
parted
|
V:379, I:558 | 307 | GNU Parted disk partition resizing program |
gparted
|
V:15, I:119 | 2109 | GNOME partition editor based on libparted |
gdisk
|
V:335, I:516 | 874 | penyunting partisi untuk disk hibrid GPT/MBR |
kpartx
|
V:20, I:33 | 86 | program untuk membuat pemetaan perangkat bagi partisi |
![]() |
Perhatian |
---|---|
Although |
![]() |
Catatan |
---|---|
Untuk beralih antara GPT dan MBR, Anda perlu menghapus beberapa blok pertama isi disk
secara langsung (lihat Bagian 9.8.6, “Menghapus konten berkas”) dan
menggunakan " |
Although reconfiguration of your partition or activation order of removable storage media may yield different names for partitions, you can access them consistently. This is also helpful if you have multiple disks and your BIOS/UEFI doesn't give them consistent device names.
mount
(8) with "-U
" option can mount a
block device using UUID, instead of using its
file name such as "/dev/sda3
".
"/etc/fstab
" (see fstab
(5)) can use
UUID.
Boot loaders (Bagian 3.1.2, “Tahap 2: boot loader”) may use UUID too.
![]() |
Tip |
---|---|
You can probe UUID of a block special device
with You can also probe it and other information with " |
LVM2 is a logical volume manager for the Linux kernel. With LVM2, disk partitions can be created on logical volumes instead of the physical harddisks.
LVM membutuhkan hal-hal berikut.
device-mapper support in the Linux kernel (default for Debian kernels)
the userspace device-mapper support library
(libdevmapper*
package)
the userspace LVM2 tools (lvm2
package)
Please start learning LVM2 from the following manpages.
lvm
(8): Basics of LVM2 mechanism (list of all LVM2
commands)
lvm.conf
(5): Configuration file for LVM2
lvs
(8): Melaporkan informasi tentang volume logis
vgs
(8): Melaporkan informasi tentang grup volume
pvs
(8): Melaporkan informasi tentang volume fisik
For ext4 filesystem, the
e2fsprogs
package provides the following.
The mkfs
(8) and fsck
(8) commands are
provided by the e2fsprogs
package as front-ends to
various filesystem dependent programs (mkfs.fstype
and
fsck.fstype
). For ext4
filesystem, they are mkfs.ext4
(8) and
fsck.ext4
(8) (they are symlinked to
mke2fs
(8) and e2fsck
(8)).
Similar commands are available for each filesystem supported by Linux.
Tabel 9.20. Daftar paket manajemen sistem berkas
paket | popcon | ukuran | deskripsi |
---|---|---|---|
e2fsprogs
|
V:627, I:999 | 1531 | utilitas untuk sistem berkas ext2/ext3/ext4 |
btrfs-progs
|
V:39, I:69 | 4209 | utilitas untuk sistem berkas Btrfs |
reiserfsprogs
|
V:9, I:28 | 1132 | utilitas untuk sistem berkas Reiserfs |
zfsutils-linux
|
V:23, I:25 | 1605 | utilitas untuk sistem berkas OpenZFS |
dosfstools
|
V:141, I:519 | 315 | utilitas untuk sistem berkas FAT. (Microsoft: MS-DOS, Windows) |
exfatprogs
|
V:6, I:120 | 171 | utilitas untuk sistem berkas exFAT yang dikelola oleh Samsung. |
exfat-fuse
|
V:17, I:332 | 75 | driver sistem berkas exFAT (Microsoft) baca/tulis untuk FUSE. |
exfat-utils
|
V:14, I:326 | 231 | utilitas untuk sistem berkas exFAT yang dikelola oleh penulis exfat-fuse. |
xfsprogs
|
V:20, I:99 | 3308 | utilitas untuk sistem berkas XFS. (SGI: IRIX) |
ntfs-3g
|
V:134, I:504 | 1482 | read/write NTFS filesystem (Microsoft: Windows NT, …) driver for FUSE. |
jfsutils
|
V:1, I:11 | 1577 | utilitas untuk sistem berkas JFS. (IBM: AIX, OS/2) |
reiser4progs
|
V:0, I:3 | 1373 | utilitas untuk sistem berkas Reiser4 |
hfsprogs
|
V:0, I:6 | 389 | utilitas untuk sistem berkas HFS dan HFS Plus. (Apple: Mac OS) |
zerofree
|
V:4, I:112 | 25 | program mengisi dengan nol blok bebas dari sistem berkas ext2/3/4 |
![]() |
Tip |
---|---|
Ext4 filesystem is the default filesystem for the Linux system and strongly recommended to use it unless you have some specific reasons not to. Btrfs status can be found at Debian wiki on btrfs and kernel.org wiki on btrfs. It is expected to be the next default filesystem after the ext4 filesystem. Beberapa alat memungkinkan akses ke sistem berkas tanpa dukungan kernel Linux (lihat Bagian 9.8.2, “Memanipulasi berkas tanpa mengait disk”). |
The mkfs
(8) command creates the filesystem on a Linux
system. The fsck
(8) command provides the filesystem
integrity check and repair on a Linux system.
Debian now defaults to no periodic fsck
after filesystem
creation.
![]() |
Perhatian |
---|---|
It is generally not safe to run |
![]() |
Tip |
---|---|
You can run the Check files in " |
Konfigurasi sistem berkas statis dasar diberikan oleh
"/etc/fstab
". Misalnya,
«file system» «mount point» «type» «options» «dump» «pass» proc /proc proc defaults 0 0 UUID=709cbe4c-80c1-56db-8ab1-dbce3146d2f7 / ext4 errors=remount-ro 0 1 UUID=817bae6b-45d2-5aca-4d2a-1267ab46ac23 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
![]() |
Tip |
---|---|
UUID (lihat Bagian 9.6.3, “Mengakses partisi menggunakan UUID”) dapat digunakan untuk
mengidentifikasi perangkat blok alih-alih nama perangkat blok normal seperti
" |
Sejak Linux 2.6.30, baku kernel adalah perilaku yang disediakan oleh opsi
"relatime
".
Lihat fstab
(5) dan mount
(8).
Karakteristik sistem berkas dapat dioptimalkan melalui superblok menggunakan
perintah tune2fs
(8).
Eksekusi "sudo tune2fs -l /dev/hda1
" menampilkan isi
superblok sistem berkas pada "/dev/hda1
".
Eksekusi "sudo tune2fs -c 50 /dev/hda1
" mengubah
frekuensi pemeriksaan sistem bermas (eksekusifsck
selama
boot-up) ke setiap 50 boot pada "/dev/hda1
".
Eksekusi "sudo tune2fs -j /dev/hda1
" menambahkan
kemampuan jurnal ke sistem berkas, yaitu konversi sistem berkas dari ext2 ke ext3 pada
"/dev/hda1
". (Lakukan ini pada sistem berkas yang tidak
dikait.)
Eksekusi "sudo tune2fs -O extents,uninit_bg,dir_index /dev/hda1
&& fsck -pf /dev/hda1
" mengubahnya dari ext3 menjadi ext4 pada
"/dev/hda1
". (Lakukan ini pada sistem berkas yang tidak
dikait.)
![]() |
Awas |
---|---|
Silakan periksa perangkat keras Anda dan baca halaman man
|
Anda dapat menguji kecepatan akses disk dari hard disk, misalnya
"/dev/hda
", dengan "hdparm -tT
/dev/hda
". Untuk beberapa hard disk yang terhubung dengan (E)IDE,
Anda dapat mempercepatnya dengan "hdparm -q -c3 -d1 -u1 -m16
/dev/hda
" dengan mengaktifkan "(E)IDE 32-bit I/O support",
memfungsikan "using_dma flag", pengaturan "interrupt-unmask flag", dan
pengaturan "multiple 16 sector I/O" (berbahaya!).
Anda dapat menguji fitur singgahan tulis dari hard disk, misalnya
"/dev/sda
", dengan "hdparm -W
/dev/sda
". Anda dapat menonaktifkan fitur singgahan tulisnya
dengan "hdparm -W 0 /dev/sda
".
Anda mungkin dapat membaca CDROM yang dicetak dengan buruk pada drive CD-ROM
berkecepatan tinggi modern dengan memperlambatnya memakai "setcd -x
2
".
Solid state drive (SSD) is auto detected now.
Reduce unnecessary disk accesses to prevent disk wear out by mounting
"tmpfs
" on volatile data path in
/etc/fstab
.
You can monitor and log your hard disk which is compliant to SMART with the smartd
(8) daemon.
Install the smartmontools
package.
Identify your hard disk drives by listing them with
df
(1).
Mari kita asumsikan hard disk drive yang akan dipantau sebagai
"/dev/hda
".
Periksa keluaran "smartctl -a /dev/hda
" untuk melihat
apakah fitur SMART benar-benar diaktifkan.
Jika tidak, aktifkan dengan "smartctl -s on -a /dev/hda
".
Fungsikan daemon smartd
(8) agar berjalan dengan cara
berikut.
jadikan bukan komentar "start_smartd=yes
" dalam berkas
"/etc/default/smartmontools
".
jalankan ulang daemon smartd
(8) dengan "sudo
systemctl restart smartmontools
".
![]() |
Tip |
---|---|
Daemon |
Applications create temporary files normally under the temporary storage
directory "/tmp
". If "/tmp
" does not
provide enough space, you can specify such temporary storage directory via
the $TMPDIR
variable for well-behaving programs.
For partitions created on Logical Volume Manager (LVM) (Linux feature) at install time, they can be resized easily by concatenating extents onto them or truncating extents from them over multiple storage devices without major system reconfiguration.
If you have an empty partition (e.g., "/dev/sdx
"), you
can format it with mkfs.ext4
(1) and
mount
(8) it to a directory where you need more
space. (You need to copy original data contents.)
$ sudo mv work-dir old-dir $ sudo mkfs.ext4 /dev/sdx $ sudo mount -t ext4 /dev/sdx work-dir $ sudo cp -a old-dir/* work-dir $ sudo rm -rf old-dir
![]() |
Tip |
---|---|
You may alternatively mount an empty disk image file (see Bagian 9.7.5, “Membuat berkas image disk kosong”) as a loop device (see Bagian 9.7.3, “Mengait berkas image disk”). The actual disk usage grows with the actual data stored. |
If you have an empty directory (e.g., "/path/to/emp-dir
")
on another partition with usable space, you can mount(8) it with
"--bind
" option to a directory (e.g.,
"work-dir
") where you need more space.
$ sudo mount --bind /path/to/emp-dir work-dir
If you have usable space in another partition (e.g.,
"/path/to/empty
" and "/path/to/work
"),
you can create a directory in it and stack that on to an old directory
(e.g., "/path/to/old
") where you need space using the
OverlayFS for Linux kernel 3.18 or newer
(Debian Stretch 9.0 or newer).
$ sudo mount -t overlay overlay \ -olowerdir=/path/to/old-dir,upperdir=/path/to/empty,workdir=/path/to/work
Here, "/path/to/empty
" and
"/path/to/work
" should be on the RW-enabled partition to
write on "/path/to/old
".
![]() |
Perhatian |
---|---|
This is a deprecated method. Some software may not function well with "symlink to a directory". Instead, use the "mounting" approaches described in the above. |
If you have an empty directory (e.g., "/path/to/emp-dir
")
in another partition with usable space, you can create a symlink to the
directory with ln
(8).
$ sudo mv work-dir old-dir $ sudo mkdir -p /path/to/emp-dir $ sudo ln -sf /path/to/emp-dir work-dir $ sudo cp -a old-dir/* work-dir $ sudo rm -rf old-dir
![]() |
Awas |
---|---|
Do not use "symlink to a directory" for directories managed by the system
such as " |
Here, we discuss manipulations of the disk image.
The disk image file, "disk.img
", of an unmounted device,
e.g., the second SCSI or serial ATA drive "/dev/sdb
", can
be made using cp
(1) or dd
(1) by the
following.
# cp /dev/sdb disk.img # dd if=/dev/sdb of=disk.img
The disk image of the traditional PC's master boot record (MBR) (see Bagian 9.6.2, “Konfigurasi partisi disk”) which reside on the first sector
on the primary IDE disk can be made by using dd
(1) by the
following.
# dd if=/dev/hda of=mbr.img bs=512 count=1 # dd if=/dev/hda of=mbr-nopart.img bs=446 count=1 # dd if=/dev/hda of=mbr-part.img skip=446 bs=1 count=66
"mbr.img
": MBR dengan tabel partisi
"mbr-nopart.img
": MBR tanpa tabel partisi
"mbr-part.img
": Tabel partisi MBR saja
If you have an SCSI or serial ATA device as the boot disk, substitute
"/dev/hda
" with "/dev/sda
".
If you are making an image of a disk partition of the original disk,
substitute "/dev/hda
" with "/dev/hda1
"
etc.
The disk image file, "disk.img
" can be written to an
unmounted device, e.g., the second SCSI drive "/dev/sdb
"
with matching size, by the following.
# dd if=disk.img of=/dev/sdb
Similarly, the disk partition image file, "partition.img
"
can be written to an unmounted partition, e.g., the first partition of the
second SCSI drive "/dev/sdb1
" with matching size, by the
following.
# dd if=partition.img of=/dev/sdb1
The disk image "partition.img
" containing a single
partition image can be mounted and unmounted by using the loop device as follows.
# losetup -v -f partition.img Loop device is /dev/loop0 # mkdir -p /mnt/loop0 # mount -t auto /dev/loop0 /mnt/loop0 ...hack...hack...hack # umount /dev/loop0 # losetup -d /dev/loop0
Ini dapat disederhanakan sebagai berikut.
# mkdir -p /mnt/loop0 # mount -t auto -o loop partition.img /mnt/loop0 ...hack...hack...hack # umount partition.img
Each partition of the disk image "disk.img
" containing
multiple partitions can be mounted by using the loop device. Since the loop device does not
manage partitions by default, we need to reset it as follows.
# modinfo -p loop # verify kernel capability max_part:Maximum number of partitions per loop device max_loop:Maximum number of loop devices # losetup -a # verify nothing using the loop device # rmmod loop # modprobe loop max_part=16
Now, the loop device can manage up to 16 partitions.
# losetup -v -f disk.img Loop device is /dev/loop0 # fdisk -l /dev/loop0 Disk /dev/loop0: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x452b6464 Device Boot Start End Blocks Id System /dev/loop0p1 1 600 4819468+ 83 Linux /dev/loop0p2 601 652 417690 83 Linux # mkdir -p /mnt/loop0p1 # mount -t ext4 /dev/loop0p1 /mnt/loop0p1 # mkdir -p /mnt/loop0p2 # mount -t ext4 /dev/loop0p2 /mnt/loop0p2 ...hack...hack...hack # umount /dev/loop0p1 # umount /dev/loop0p2 # losetup -d /dev/loop0
Alternatively, similar effects can be done by using the device mapper devices created by
kpartx
(8) from the kpartx
package as
follows.
# kpartx -a -v disk.img ... # mkdir -p /mnt/loop0p2 # mount -t ext4 /dev/mapper/loop0p2 /mnt/loop0p2 ... ...hack...hack...hack # umount /dev/mapper/loop0p2 ... # kpartx -d /mnt/loop0
![]() |
Catatan |
---|---|
You can mount a single partition of such disk image with loop device using offset to skip MBR etc., too. But this is more error prone. |
A disk image file, "disk.img
" can be cleaned of all
removed files into clean sparse image "new.img
" by the
following.
# mkdir old; mkdir new # mount -t auto -o loop disk.img old # dd bs=1 count=0 if=/dev/zero of=new.img seek=5G # mount -t auto -o loop new.img new # cd old # cp -a --sparse=always ./ ../new/ # cd .. # umount new.img # umount disk.img
If "disk.img
" is in ext2, ext3 or ext4, you can also use
zerofree
(8) from the zerofree
package
as follows.
# losetup -f -v disk.img Loop device is /dev/loop3 # zerofree /dev/loop3 # cp --sparse=always disk.img new.img
The empty disk image "disk.img
" which can grow up to 5GiB
can be made using dd
(1) as follows.
$ dd bs=1 count=0 if=/dev/zero of=disk.img seek=5G
Instead of using dd
(1), specialized
fallocate
(8) may be used here.
You can create an ext4 filesystem on this disk image
"disk.img
" using the loop
device as follows.
# losetup -f -v disk.img Loop device is /dev/loop1 # mkfs.ext4 /dev/loop1 ...hack...hack...hack # losetup -d /dev/loop1 $ du --apparent-size -h disk.img 5.0G disk.img $ du -h disk.img 83M disk.img
For "disk.img
", its file size is 5.0 GiB and its actual
disk usage is mere 83MiB. This discrepancy is possible since ext4 can hold sparse
file.
![]() |
Tip |
---|---|
The actual disk usage of sparse file grows with data which are written to it. |
Using similar operation on devices created by the loop device or the device mapper devices as Bagian 9.7.3, “Mengait berkas image disk”, you can partition this disk image
"disk.img
" using parted
(8) or
fdisk
(8), and can create filesystem on it using
mkfs.ext4
(8), mkswap
(8), etc.
The ISO9660 image file,
"cd.iso
", from the source directory tree at
"source_directory
" can be made using
genisoimage
(1) provided by cdrkit by the following.
# genisoimage -r -J -T -V volume_id -o cd.iso source_directory
Similarly, the bootable ISO9660 image file, "cdboot.iso
",
can be made from debian-installer
like directory tree at
"source_directory
" by the following.
# genisoimage -r -o cdboot.iso -V volume_id \ -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table source_directory
Di sini boot loader Isolinux (lihat Bagian 3.1.2, “Tahap 2: boot loader”) digunakan untuk boot.
You can calculate the md5sum value and make the ISO9660 image directly from the CD-ROM device as follows.
$ isoinfo -d -i /dev/cdrom CD-ROM is in ISO 9660 format ... Logical block size is: 2048 Volume size is: 23150592 ... # dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror | md5sum # dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror > cd.iso
![]() |
Awas |
---|---|
You must carefully avoid ISO9660 filesystem read ahead bug of Linux as above to get the right result. |
![]() |
Tip |
---|---|
DVD is only a large CD to |
You can find a usable device by the following.
# wodim --devices
Then the blank CD-R is inserted to the CD drive, and the ISO9660 image file,
"cd.iso
" is written to this device, e.g.,
"/dev/hda
", using wodim
(1) by the
following.
# wodim -v -eject dev=/dev/hda cd.iso
If CD-RW is used instead of CD-R, do this instead by the following.
# wodim -v -eject blank=fast dev=/dev/hda cd.iso
![]() |
Tip |
---|---|
If your desktop system mounts CDs automatically, unmount it by
" |
If "cd.iso
" contains an ISO9660 image, then the following
manually mounts it to "/cdrom
".
# mount -t iso9660 -o ro,loop cd.iso /cdrom
![]() |
Tip |
---|---|
Sistem desktop modern dapat mengait media lepasan seperti CD terformat ISO9660 secara otomatis (lihat Bagian 10.1.7, “Perangkat penyimpanan lepasan”). |
Here, we discuss direct manipulations of the binary data on storage media.
The most basic viewing method of binary data is to use "od -t
x1
" command.
Tabel 9.21. List of packages which view and edit binary data
paket | popcon | ukuran | deskripsi |
---|---|---|---|
coreutils
|
V:898, I:999 | 17372 | basic package which has od (1) to dump files (HEX, ASCII,
OCTAL, …) |
bsdmainutils
|
V:31, I:673 | 27 | utility package which has hd (1) to dump files (HEX,
ASCII, OCTAL, …) |
hexedit
|
V:1, I:11 | 73 | editor dan penampil biner (HEKSA, ASCII) |
bless
|
V:0, I:3 | 924 | editor heksadesimal berfitur lengkap (GNOME) |
okteta
|
V:1, I:13 | 1508 | editor heksadesimal berfitur lengkap (KDE4) |
ncurses-hexedit
|
V:0, I:2 | 132 | editor dan penampil biner (HEKSA, ASCII, EBCDIC) |
beav
|
V:0, I:0 | 137 | editor dan penampil biner (HEKSA, ASCII, EBCDIC, OKTAL, …) |
![]() |
Tip |
---|---|
HEX is used as an acronym for hexadecimal format with radix 16. OCTAL is for octal format with radix 8. ASCII is for American Standard Code for Information Interchange, i.e., normal English text code. EBCDIC is for Extended Binary Coded Decimal Interchange Code used on IBM mainframe operating systems. |
Ada alat untuk membaca dan menulis berkas tanpa mengait disk.
Software RAID systems offered by the Linux kernel provide data redundancy in the kernel filesystem level to achieve high levels of storage reliability.
There are tools to add data redundancy to files in application program level to achieve high levels of storage reliability, too.
There are tools for data file recovery and forensic analysis.
Tabel 9.24. List of packages for data file recovery and forensic analysis
paket | popcon | ukuran | deskripsi |
---|---|---|---|
testdisk
|
V:2, I:34 | 1430 | utilities for partition scan and disk recovery |
magicrescue
|
V:0, I:3 | 259 | utility to recover files by looking for magic bytes |
scalpel
|
V:0, I:4 | 87 | frugal, high performance file carver |
myrescue
|
V:0, I:3 | 83 | rescue data from damaged harddisks |
extundelete
|
V:0, I:10 | 147 | utility to undelete files on the ext3/4 filesystem |
ext4magic
|
V:0, I:4 | 233 | utility to undelete files on the ext3/4 filesystem |
ext3grep
|
V:0, I:3 | 293 | tool to help recover deleted files on the ext3 filesystem |
scrounge-ntfs
|
V:0, I:3 | 50 | data recovery program for NTFS filesystems |
gzrt
|
V:0, I:0 | 33 | gzip recovery toolkit |
sleuthkit
|
V:2, I:25 | 1602 | alat untuk analisis forensik. (Sleuthkit) |
autopsy
|
V:0, I:1 | 1027 | antarmuka grafis ke SleuthKit |
foremost
|
V:0, I:6 | 101 | aplikasi forensik untuk memulihkan data |
guymager
|
V:0, I:1 | 1035 | alat pembuatan citra forensik berbasis Qt |
dcfldd
|
V:0, I:4 | 106 | enhanced version of dd for forensics and security |
![]() |
Tip |
---|---|
You can undelete files on the ext2 filesystem using
|
When a data is too big to backup as a single file, you can backup its content after splitting it into, e.g. 2000MiB chunks and merge those chunks back into the original file later.
$ split -b 2000m large_file $ cat x* >large_file
![]() |
Perhatian |
---|---|
Please make sure you do not have any files starting with
" |
In order to clear the contents of a file such as a log file, do not use
rm
(1) to delete the file and then create a new empty
file, because the file may still be accessed in the interval between
commands. The following is the safe way to clear the contents of the file.
$ :>file_to_be_cleared
The following commands create dummy or empty files.
$ dd if=/dev/zero of=5kb.file bs=1k count=5 $ dd if=/dev/urandom of=7mb.file bs=1M count=7 $ touch zero.file $ : > alwayszero.file
You should find following files.
"5kb.file
" is 5KB of zeros.
"7mb.file
" is 7MB of random data.
"zero.file
" may be a 0 byte file. If it existed, its
mtime
is updated while its content and its length are
kept.
"alwayszero.file
" is always a 0 byte file. If it
existed, its mtime
is updated and its content is reset.
There are several ways to completely erase data from an entire hard disk
like device, e.g., USB memory stick at "/dev/sda
".
![]() |
Perhatian |
---|---|
Check your USB memory stick location with |
Erase all the disk content by resetting data to 0 with the following.
# dd if=/dev/zero of=/dev/sda
Erase everything by overwriting with random data as follows.
# dd if=/dev/urandom of=/dev/sda
Erase everything by overwriting with random data very efficiently as follows.
# shred -v -n 1 /dev/sda
You may alternatively use badblocks
(8) with -t
random
option.
Since dd
(1) is available from the shell of many bootable
Linux CDs such as Debian installer CD, you can erase your installed system
completely by running an erase command from such media on the system hard
disk, e.g., "/dev/hda
", "/dev/sda
",
etc.
Unused area on an hard disk (or USB memory stick),
e.g. "/dev/sdb1
" may still contain erased data themselves
since they are only unlinked from the filesystem. These can be cleaned by
overwriting them.
# mount -t auto /dev/sdb1 /mnt/foo # cd /mnt/foo # dd if=/dev/zero of=junk dd: writing to `junk': No space left on device ... # sync # umount /dev/sdb1
![]() |
Awas |
---|---|
This is usually good enough for your USB memory stick. But this is not perfect. Most parts of erased filenames and their attributes may be hidden and remain in the filesystem. |
Even if you have accidentally deleted a file, as long as that file is still being used by some application (read or write mode), it is possible to recover such a file.
Misalnya, coba yang berikut ini
$ echo foo > bar $ less bar $ ps aux | grep ' less[ ]' bozo 4775 0.0 0.0 92200 884 pts/8 S+ 00:18 0:00 less bar $ rm bar $ ls -l /proc/4775/fd | grep bar lr-x------ 1 bozo bozo 64 2008-05-09 00:19 4 -> /home/bozo/bar (deleted) $ cat /proc/4775/fd/4 >bar $ ls -l -rw-r--r-- 1 bozo bozo 4 2008-05-09 00:25 bar $ cat bar foo
Execute on another terminal (when you have the lsof
package installed) as follows.
$ ls -li bar 2228329 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:02 bar $ lsof |grep bar|grep less less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar $ rm bar $ lsof |grep bar|grep less less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar (deleted) $ cat /proc/4775/fd/4 >bar $ ls -li bar 2228302 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:05 bar $ cat bar foo
Files with hardlinks can be identified by "ls -li
".
$ ls -li total 0 2738405 -rw-r--r-- 1 root root 0 2008-09-15 20:21 bar 2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 baz 2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 foo
Both "baz
" and "foo
" have link counts
of "2" (>1) showing them to have hardlinks. Their inode numbers are common "2738404". This means they
are the same hardlinked file. If you do not happen to find all hardlinked
files by chance, you can search it by the inode, e.g., "2738404" as the following.
# find /path/to/mount/point -xdev -inum 2738404
Dengan akses fisik ke PC Anda, siapa pun dapat dengan mudah mendapatkan hak istimewa root dan mengakses semua berkas di PC Anda (lihat Bagian 4.6.4, “Mengamankan kata sandi root”). Ini berarti bahwa sistem kata sandi masuk tidak dapat mengamankan data pribadi dan sensitif Anda terhadap kemungkinan pencurian PC Anda. Anda harus menerapkan teknologi enkripsi data untuk melakukannya. Meskipun GNU privacy guard (lihat Bagian 10.3, “Infrastruktur keamanan data”) dapat mengenkripsi berkas, dibutuhkan beberapa upaya pengguna.
Dm-crypt facilitates automatic data encryption via native Linux kernel modules with minimal user efforts using device-mapper.
Tabel 9.25. Daftar utilitas enkripsi data
paket | popcon | ukuran | deskripsi |
---|---|---|---|
cryptsetup
|
V:16, I:79 | 448 | utilities for encrypted block device (dm-crypt / LUKS) |
cryptmount
|
V:3, I:4 | 228 | utilities for encrypted block device (dm-crypt / LUKS) with focus on mount/unmount by normal users |
fscrypt
|
V:0, I:1 | 4316 | utilities for Linux filesystem encryption (fscrypt) |
libpam-fscrypt
|
V:0, I:0 | 4411 | PAM module for Linux filesystem encryption (fscrypt) |
![]() |
Perhatian |
---|---|
Data encryption costs CPU time etc. Encrypted data becomes inaccessible if its password is lost. Please weigh its benefits and costs. |
![]() |
Catatan |
---|---|
Entire Debian system can be installed on a encrypted disk by the debian-installer (lenny or newer) using dm-crypt/LUKS and initramfs. |
![]() |
Tip |
---|---|
Lihat Bagian 10.3, “Infrastruktur keamanan data” untuk utilitas enkripsi ruang pengguna: GNU Privacy Guard. |
You can encrypt contents of removable mass devices, e.g. USB memory stick on
"/dev/sdx
", using dm-crypt/LUKS. You
simply format it as the following.
# fdisk /dev/sdx ... "n" "p" "1" "return" "return" "w" # cryptsetup luksFormat /dev/sdx1 ... # cryptsetup open /dev/sdx1 secret ... # ls -l /dev/mapper/ total 0 crw-rw---- 1 root root 10, 60 2021-10-04 18:44 control lrwxrwxrwx 1 root root 7 2021-10-04 23:55 secret -> ../dm-0 # mkfs.vfat /dev/mapper/secret ... # cryptsetup close secret
Kemudian, dapat dikait seperti biasa pada
"/media/nama_pengguna/label_disk
",
kecuali untuk menanyakan kata sandi (lihat Bagian 10.1.7, “Perangkat penyimpanan lepasan” ) di bawah lingkungan desktop modern
menggunakan paket udisks2
. Perbedaannya adalah bahwa
setiap data yang ditulis padanya dienkripsi. Entri kata sandi dapat
diotomatisasi menggunakan keyring (lihat Bagian 10.3.6, “Password keyring”).
You may alternatively format media in different filesystem, e.g., ext4 with
"mkfs.ext4 /dev/mapper/sdx1
". If btrfs is used instead,
the udisks2-btrfs
package needs to be installed. For
these filesystems, the file ownership and permissions may need to be
configured.
Misalnya, partisi disk terenkripsi yang dibuat dengan dm-crypt/LUKS pada
"/dev/sdc5
" oleh Debian Installer dapat dikait ke
"/mnt
" sebagai berikut:
$ sudo cryptsetup open /dev/sdc5 ninja --type luks Enter passphrase for /dev/sdc5: **** $ sudo lvm lvm> lvscan inactive '/dev/ninja-vg/root' [13.52 GiB] inherit inactive '/dev/ninja-vg/swap_1' [640.00 MiB] inherit ACTIVE '/dev/goofy/root' [180.00 GiB] inherit ACTIVE '/dev/goofy/swap' [9.70 GiB] inherit lvm> lvchange -a y /dev/ninja-vg/root lvm> exit Exiting. $ sudo mount /dev/ninja-vg/root /mnt
Debian distributes modularized Linux kernel as packages for supported architectures.
If you are reading this documentation, you probably don't need to compile Linux kernel by yourself.
Banyak fitur Linux dapat dikonfigurasi melalui parameter kernel sebagai berikut.
Parameter kernel yang diinisialisasi oleh bootloader (lihat Bagian 3.1.2, “Tahap 2: boot loader”)
Parameter kernel diubah oleh sysctl
(8) saat runtime untuk
yang dapat diakses melalui sysfs (lihat Bagian 1.2.12, “procfs dan sysfs”)
Parameter modul yang ditetapkan oleh argumen modprobe
(8)
ketika modul diaktifkan (lihat Bagian 9.7.3, “Mengait berkas image disk”)
See "The Linux kernel user’s and administrator’s guide » The kernel’s command-line parameters" for the detail.
Most normal programs don't need kernel
headers and in fact may break if you use them directly for compiling. They
should be compiled against the headers in
"/usr/include/linux
" and
"/usr/include/asm
" provided by the
libc6-dev
package (created from the
glibc
source package) on the Debian system.
![]() |
Catatan |
---|---|
For compiling some kernel-specific programs such as the kernel modules from
the external source and the automounter daemon ( |
Debian has its own method of compiling the kernel and related modules.
Tabel 9.26. List of key packages to be installed for the kernel recompilation on the Debian system
paket | popcon | ukuran | deskripsi |
---|---|---|---|
build-essential
|
I:491 | 20 | essential packages for building Debian packages: make ,
gcc , … |
bzip2
|
V:161, I:973 | 120 | compress and decompress utilities for bz2 files |
libncurses5-dev
|
I:102 | 6 | developer's libraries and docs for ncurses |
git
|
V:325, I:506 | 37790 | git: distributed revision control system used by the Linux kernel |
fakeroot
|
V:33, I:508 | 228 | provide fakeroot environment for building package as non-root |
initramfs-tools
|
V:340, I:991 | 112 | tool to build an initramfs (Debian specific) |
dkms
|
V:46, I:197 | 293 | dynamic kernel module support (DKMS) (generic) |
module-assistant
|
V:1, I:28 | 391 | helper tool to make module package (Debian specific) |
devscripts
|
V:8, I:50 | 2752 | skrip pembantu untuk pengelola Paket Debian (spesifik Debian) |
If you use initrd
in Bagian 3.1.2, “Tahap 2: boot loader”, make sure to read the related
information in initramfs-tools
(8),
update-initramfs
(8), mkinitramfs
(8)
and initramfs.conf
(5).
![]() |
Awas |
---|---|
Do not put symlinks to the directories in the source tree
(e.g. " |
![]() |
Catatan |
---|---|
When compiling the latest Linux kernel on the Debian
The dynamic kernel module support (DKMS) is a new distribution independent framework designed to allow individual kernel modules to be upgraded without changing the whole kernel. This is used for the maintenance of out-of-tree modules. This also makes it very easy to rebuild modules as you upgrade kernels. |
For building custom kernel binary packages from the upstream kernel source,
you should use the "deb-pkg
" target provided by it.
$ sudo apt-get build-dep linux $ cd /usr/src $ wget http://www.kernel.org/pub/linux/kernel/v3.11/linux-version.tar.bz2 $ tar -xjvf linux-version.tar.bz2 $ cd linux-version $ cp /boot/config-version .config $ make menuconfig ... $ make deb-pkg
![]() |
Tip |
---|---|
The linux-source-version package provides the Linux
kernel source with Debian patches as
" |
For building specific binary packages from the Debian kernel source package,
you should use the
"binary-arch_architecture_featureset_flavour
"
targets in "debian/rules.gen
".
$ sudo apt-get build-dep linux $ apt-get source linux $ cd linux-3.* $ fakeroot make -f debian/rules.gen binary-arch_i386_none_686
Lihat informasi lebih lanjut:
Wiki Debian: KernelFAQ
Wiki Debian: DebianKernel
Buku Pegangan Kernel Debian Linux: https://kernel-handbook.debian.net
The hardware driver is the code running on the main CPUs of the target
system. Most hardware drivers are available as free software now and are
included in the normal Debian kernel packages in the main
area.
The firmware is the code or data loaded on the device attach to the target system (e.g., CPU microcode, rendering code running on GPU, or FPGA / CPLD data, …). Some firmware packages are available as free software but many firmware packages are not available as free software since they contain sourceless binary data. Installing these firmware data is essential for the device to function as expected.
The firmware data packages containing data loaded to the volatile memory on the target device.
firmware-linux-free (main
)
firmware-linux-nonfree (non-free
)
firmware-linux-* (non-free
)
*-firmware (non-free
)
intel-microcode (non-free
)
amd64-microcode (non-free
)
The firmware update program packages which update data on the non-volatile memory on the target device.
fwupd (main
): Firmware
update daemon which downloads firmware data from Linux Vendor Firmware Service.
gnome-firmware (main
): GTK front end for fwupd
plasma-discover-backend-fwupd (main
): Qt front end for
fwupd
Please note that non-free
and contrib
packages are not part of the Debian system. The access configuration to
enable and to disable the non-free
and
contrib
areas is described in Bagian 2.1.4, “Dasar-dasar arsip Debian”. You should be aware of negatives
associated with the use of the non-free
and
contrib
packages as described in Bagian 2.1.5, “Debian adalah perangkat lunak 100% bebas”.
Please also note that the firmware data downloaded by fwupd from Linux Vendor Firmware Service and
loaded to the running Linux kernel may be non-free
.
Use of virtualized system enables us to run multiple instances of system simultaneously on a single hardware.
There are several virtualization and emulation tool platforms.
Complete hardware emulation packages such as ones installed by the games-emulator metapackage
Mostly CPU level emulation with some I/O device emulations such as QEMU
Mostly CPU level virtualization with some I/O device emulations such as Kernel-based Virtual Machine (KVM)
OS level container virtualization with the kernel level support such as LXC (Linux Containers), Docker, ...
OS level filesystem access virtualization with the system library call override on the file path such as chroot
OS level filesystem access virtualization with the system library call override on the file ownership such as fakeroot
OS API emulation such as Wine
Interpreter level virtualization with its executable selection and run-time library overrides such as virtualenv and venv for Python
The container virtualization uses Bagian 4.7.4, “Fitur keamanan Linux” and it is the backend technology of Bagian 7.6, “Sandbox”.
Here are some packages to help you to setup the virtualized system.
Tabel 9.27. Daftar alat virtualisasi
paket | popcon | ukuran | deskripsi |
---|---|---|---|
schroot
|
V:6, I:9 | 2708 | specialized tool for executing Debian binary packages in chroot |
sbuild
|
V:1, I:4 | 282 | tool for building Debian binary packages from Debian sources |
debootstrap
|
V:6, I:62 | 308 | bootstrap a basic Debian system (written in sh) |
cdebootstrap
|
V:0, I:2 | 116 | bootstrap a Debian system (written in C) |
virt-manager
|
V:10, I:43 | 2298 | Virtual Machine Manager: desktop application for managing virtual machines |
libvirt-clients
|
V:44, I:64 | 1287 | programs for the libvirt library |
games-emulator
|
I:0 | 26 | games-emulator: Debian's emulators for games |
bochs
|
V:0, I:1 | 6999 | Bochs: IA-32 PC emulator |
qemu
|
I:29 | 100 | QEMU: fast generic processor emulator |
qemu-system
|
I:22 | 101 | QEMU: full system emulation binaries |
qemu-user
|
V:0, I:9 | 110111 | QEMU: user mode emulation binaries |
qemu-utils
|
V:13, I:107 | 6623 | QEMU: utilitas |
qemu-kvm
|
V:4, I:30 | 107 | KVM: full virtualization on x86 hardware with the hardware-assisted virtualization |
virtualbox
|
V:11, I:14 | 107009 | VirtualBox: x86 virtualization solution on i386 and amd64 |
xen-tools
|
V:0, I:3 | 727 | tools to manage debian XEN virtual server |
wine
|
V:16, I:71 | 191 | Wine: Windows API Implementation (standard suite) |
dosbox
|
V:2, I:17 | 2718 | DOSBox: x86 emulator with Tandy/Herc/CGA/EGA/VGA/SVGA graphics, sound and DOS |
lxc
|
V:9, I:14 | 19661 | Linux containers user space tools |
python3-venv
|
I:55 | 6 | venv for creating virtual python environments (system library) |
python3-virtualenv
|
V:10, I:58 | 435 | virtualenv for creating isolated virtual python environments |
pipx
|
V:0, I:1 | 887 | pipx for installing python applications in isolated environments |
See Wikipedia article Comparison of platform virtual machines for detail comparison of different platform virtualization solutions.
![]() |
Catatan |
---|---|
Default Debian kernels support KVM since
|
Typical work flow for virtualization involves several steps.
Create an empty filesystem (a file tree or a disk image).
The file tree can be created by "mkdir -p
/path/to/chroot
".
Berkas image disk mentah dapat dibuat dengan dd
(1) (lihat
Bagian 9.7.1, “Membuat berkas image disk” dan Bagian 9.7.5, “Membuat berkas image disk kosong”).
qemu-img
(1) can be used to create and convert disk image
files supported by QEMU.
The raw and VMDK file format can be used as common format among virtualization tools.
Mount the disk image with mount
(8) to the filesystem
(optional).
Untuk berkas image disk mentah, kait itu sebagai perangkat loop atau perangkat device mapper (lihat Bagian 9.7.3, “Mengait berkas image disk”).
Untuk image disk yang didukung oleh QEMU, kait mereka sebagai perangkat blok jaringan (lihat Bagian 9.11.3, “Mounting the virtual disk image file”).
Populate the target filesystem with required system data.
Penggunaan program seperti debootstrap
dan
cdebootstrap
membantu proses ini (lihat Bagian 9.11.4, “Sistem chroot”).
Use installers of OSs under the full system emulation.
Run a program under a virtualized environment.
chroot provides basic virtualized environment enough to compile programs, run console applications, and run daemons in it.
QEMU provides cross-platform CPU emulation.
QEMU with KVM provides full system emulation by the hardware-assisted virtualization.
VirtualBox provides full system emulation on i386 and amd64 with or without the hardware-assisted virtualization.
For the raw disk image file, see Bagian 9.7, “Image disk”.
For other virtual disk image files, you can use
qemu-nbd
(8) to export them using network block device protocol and mount
them using the nbd
kernel module.
qemu-nbd
(8) supports disk formats supported by QEMU: QEMU supports
following disk formats: raw, qcow2, qcow,
vmdk, vdi, bochs, cow (user-mode Linux copy-on-write), parallels, dmg, cloop, vpc, vvfat (virtual
VFAT), and host_device.
Perangkat blok jaringan dapat
mendukung partisi dengan cara yang sama seperti perangkat loop (lihat Bagian 9.7.3, “Mengait berkas image disk”). Anda dapat mengait partisi
pertama dari "disk.img
" sebagai berikut.
# modprobe nbd max_part=16 # qemu-nbd -v -c /dev/nbd0 disk.img ... # mkdir /mnt/part1 # mount /dev/nbd0p1 /mnt/part1
![]() |
Tip |
---|---|
You may export only the first partition of " |
If you wish to try a new Debian environment from a terminal console, I
recommend you to use chroot. This enables you
to run console applications of Debian unstable
and
testing
without usual risks associated and without
rebooting. chroot
(8) is the most basic way.
![]() |
Perhatian |
---|---|
Examples below assumes both parent system and chroot system share the same
|
Although you can manually create a chroot
(8) environment
using debootstrap
(1). But this requires non-trivial
efforts.
The sbuild package to build Debian packages
from source uses the chroot environment managed by the schroot package. It comes with helper script
sbuild-createchroot
(1). Let's learn how it works by
running it under script
(1) as follows.
$ sudo mkdir -p /srv/chroot $ sudo sbuild-createchroot -v --include=eatmydata,ccache unstable /srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian
You see how debootstrap
(8) populates system data for
unstable
environment under
"/srv/chroot/unstable-amd64-sbuild
" for a minimal build
system.
You can login to this environment using schroot
(1).
$ sudo schroot -v -c chroot:unstable-amd64-sbuild
You see how a system shell running under unstable
environment is created.
![]() |
Catatan |
---|---|
The " |
![]() |
Catatan |
---|---|
Some programs under chroot may require access to more files from the parent
system to function than |
![]() |
Tip |
---|---|
The |
If you wish to try a new GUI Desktop environment of any OS, I recommend you
to use QEMU or KVM on
a Debian stable
system to run multiple desktop systems
safely using virtualization. These
enable you to run any desktop applications including ones of Debian
unstable
and testing
without usual
risks associated with them and without rebooting.
Since pure QEMU is very slow, it is recommended to accelerate it with KVM when the host system supports it.
Virtual Machine Manager also
known as virt-manager
is a convenient GUI tool for
managing KVM virtual machines via libvirt.
The virtual disk image "virtdisk.qcow2
" containing a
Debian system for QEMU can be created using
debian-installer: Small CDs
as follows.
$ wget http://cdimage.debian.org/debian-cd/5.0.3/amd64/iso-cd/debian-503-amd64-netinst.iso $ qemu-img create -f qcow2 virtdisk.qcow2 5G $ qemu -hda virtdisk.qcow2 -cdrom debian-503-amd64-netinst.iso -boot d -m 256 ...
![]() |
Tip |
---|---|
Running other GNU/Linux distributions such as Ubuntu and Fedora under virtualization is a great way to learn configuration tips. Other proprietary OSs may be run nicely under this GNU/Linux virtualization, too. |
See more tips at Debian wiki: SystemVirtualization.
[2] Contoh penyesuaian yang lebih rumit: "Vim Galore", "sensible.vim", "#vim Recommendations" ...
[3] vim-pathogen populer.