Linux : Perintah cp: Difference between revisions
No edit summary |
m (Protected "Linux : Perintah cp" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]) |
(No difference)
| |
Latest revision as of 21:36, 31 October 2025
cp adalah perintah untuk melakukan copy file/folder di

| 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
|