Teman bule saya memberitahukan saya tentang tips ini. Yaitu cara untuk membypass suatu command yang sudah disetting menggunakan alias. Berikut contohnya:
[root@test1 newfolder]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Seperti diatas, Redhat membuat default alias pada perintah rm menjadi rm -i. Sehingga apabila kita ingin menghapus suatu file menggunakan perintah rm, maka sebenarnya perintah yang dijalankan adalah rm -i, yang artinya interactive mode. Dengan options ini, setiap file yang akan kita pilih akan melakukan konfirmasi apakah kita benar ingin menghapus file ini atau tidak. Kita harus mengetikkan “y” bila ingin melanjutkan menghapus filenya.
[root@test1 newfolder]# rm newfile1
rm: remove regular empty file `newfile1'? y
[root@test1 newfolder]#
Default alias ini sebenarnya sangat berguna demi keamanan. Agar tidak terjadi menghapus file secara tidak sengaja.
Tapi bila kita sudah yakin dengan file yang akan kita hapus, dan kita tetap menginginkan perintah rm tersebut tetap dialias. Jadi yang kita inginkan saat itu adalah menjalankan perintah rm tersebut tanpa options interactive yang tentunya akan bertanya setiap file yang akan kita hapus.
[root@test1 newfolder]# ll
total 0
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile2
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile3
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile4
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile5
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile6
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile7
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile8
-rw-r--r-- 1 root root 0 Oct 8 02:19 newfile9
[root@test1 newfolder]# rm newfile*
rm: remove regular empty file `newfile2'? y
rm: remove regular empty file `newfile3'? y
rm: remove regular empty file `newfile4'? y
rm: remove regular empty file `newfile5'? y
rm: remove regular empty file `newfile6'? y
rm: remove regular empty file `newfile7'? y
rm: remove regular empty file `newfile8'? y
rm: remove regular empty file `newfile9'? y
[root@test1 newfolder]# ll
total 0
[root@test1 newfolder]#
Untuk itu yang kita perlukan adalah mem-bypass alias tersebut. Berikut cara mudahnya:
[root@test1 newfolder]# ll
total 0
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile1
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile2
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile3
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile4
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile5
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile6
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile7
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile8
-rw-r--r-- 1 root root 0 Oct 8 02:31 newfile9
[root@test1 newfolder]# \rm newfile*
[root@test1 newfolder]# ll
total 0
[root@test1 newfolder]#
Ya benar, cukup gunakan “\” backslash untuk membypass perintah rm tersebut agar tidak menggunakan alias rm -i.
Semoga bermanfaat. 🙂