cp command in Linux/Unix
cp command is used for copying files or directories from one location to another location. The copied files or directories are entirely independent of the original files or directories.
Syntax of cp command
cp [option] Source Destination
Source
can be one or more than one files or directories as argumentsDestination
can be a single file or directory.
Uses of cp command with example
Copying file to another file
cp command can be used to copy files from one location (source) to another location (destination). If doesn’t exist, the cp command creates it.
cp source_file_name destination_file_name
Copying file to another directory
cp command can be used to copy files from one location (source) to another location (destination). The destination directory must exist. If the destination directory doesn’t exist, the cp command does not create it.
cp source_file_name destination_directory_name
Copying directory to another directory
cp command can be used to copy one or more directories to another directory. To copy from one directory to another directory use the following command.
cp -r source_directory_name destination_directory_name
A |
adduser | addgroup | alias | anacron | apt | aptitude | arp | at | atq | atrm | awk |
B |
basename | banner | batch | bc | bg | bzip |
C |
cat | cal | cd | chgrp | chown | cksum | chmod | clear | cmp | comm | cp |
D |
date | dd | df | diff | dir | dmidecode | du |
E |
echo | eject | env | exit | expr |
F |
factor | find | free |
G |
grep | groups | gunzip | gzip |
H |
head | history | hostname | hostnamectl | htop | hwclock | hwinfo |
I |
id | ifconfig | ionice | iostat | ip | iptables | iw | iwlist |
J |
K |
kill | kmod |
L |
last | less | ln | locate | login | lp | ls | lshw | lscpu | lsof | lsusb |
M |
man | mdsum | mkdir | more| mv |
N |
nano | nc | neofetch | netcat | netstat | nice | nmap | nproc |
O |
openssl |
P |
passwd | pidof | ping | pr | ps | pwd | pstree |
Q |
R |
rdiff-backup | reboot | rename | rm | rmdir | rnmod |
S |
scp | shred | shutdown | sleep | sort | split | ssh | stat | su | sudo | sum |
T |
tac | tail | talk | tar | tee | time | tree | top | touch | tr |
U |
unalias | uname | uniq | unzip | uptime | users |
V |
vim | vi |
W |
w | wall | watch | wc | wget | whatis | whereis | which | who | whoami |
X |
xargs |
Y |
yes | youtube-dl |
Z |
zcmp | zdiff | zip | zz |