(Created page with "thumb|tux")
 
No edit summary
Line 1: Line 1:
[[File:Tux.png|thumb|tux]]
<code>cp</code> adalah perintah untuk melakukan copy file/folder di [[File:Tux.png|thumb|tux]]
{| class="wikitable"
!'''Atribut (Option)'''
!'''Keterangan'''
!'''Contoh Penggunaan Aplikatif'''
|-
|<code>cp file1 file2</code>
|Menyalin file1 menjadi file2
|<code>cp data.txt data_backup.txt</code>
|-
|<code>cp file1 dir/</code>
|Menyalin file ke dalam folder
|<code>cp foto.png /home/user/Pictures/</code>
|-
|<code>-r</code> / <code>-R</code>
|Menyalin direktori beserta isinya (rekursif)
|<code>cp -r /var/www /backup/</code>
|-
|<code>-i</code>
|Interaktif: menanyakan konfirmasi sebelum overwrite
|<code>cp -i file.txt /tmp/</code>
|-
|<code>-f</code>
|Force: menimpa file tanpa konfirmasi
|<code>cp -f config.old config</code>
|-
|<code>-u</code>
|Hanya menyalin jika file sumber lebih baru dari tujuan
|<code>cp -u laporan.doc /backup/</code>
|-
|<code>-v</code>
|Verbose: menampilkan proses penyalinan
|<code>cp -v data.csv /backup/</code>
|-
|<code>-p</code>
|Preserve: mempertahankan permission, owner, timestamp
|<code>cp -p skripsi.doc /backup/</code>
|-
|<code>-a</code>
|Archive mode: copy lengkap (rekursif + preserve), digunakan untuk backup
|<code>cp -a /home/user/ /media/usb/</code>
|-
|<code>-n</code>
|No-clobber: tidak menimpa file yang sudah ada
|<code>cp -n foto.jpg /backup/</code>
|-
|<code>--parents</code>
|Menyalin file dengan struktur direktori mengikuti path lengkapnya
|<code>cp --parents src/images/logo.png /backup/</code>
|-
|<code>--backup</code>
|Membuat backup file jika terjadi overwrite
|<code>cp --backup config.txt /etc/app/</code>
|-
|<code>--remove-destination</code>
|Menghapus file tujuan sebelum menulis file baru
|<code>cp --remove-destination a.txt b.txt</code>
|}

Revision as of 21:32, 31 October 2025

cp adalah perintah untuk melakukan copy file/folder di

tux
Atribut (Option) Keterangan Contoh Penggunaan Aplikatif
cp file1 file2 Menyalin file1 menjadi file2 cp data.txt data_backup.txt
cp file1 dir/ Menyalin file ke dalam folder cp foto.png /home/user/Pictures/
-r / -R Menyalin direktori beserta isinya (rekursif) cp -r /var/www /backup/
-i Interaktif: menanyakan konfirmasi sebelum overwrite cp -i file.txt /tmp/
-f Force: menimpa file tanpa konfirmasi cp -f config.old config
-u Hanya menyalin jika file sumber lebih baru dari tujuan cp -u laporan.doc /backup/
-v Verbose: menampilkan proses penyalinan cp -v data.csv /backup/
-p Preserve: mempertahankan permission, owner, timestamp cp -p skripsi.doc /backup/
-a Archive mode: copy lengkap (rekursif + preserve), digunakan untuk backup cp -a /home/user/ /media/usb/
-n No-clobber: tidak menimpa file yang sudah ada cp -n foto.jpg /backup/
--parents Menyalin file dengan struktur direktori mengikuti path lengkapnya cp --parents src/images/logo.png /backup/
--backup Membuat backup file jika terjadi overwrite cp --backup config.txt /etc/app/
--remove-destination Menghapus file tujuan sebelum menulis file baru cp --remove-destination a.txt b.txt