Cp:copy replication
-
Command function:
copy and move files;
2. Command format:
CP [Options] source...source destination//source can have multiple, the target can only have one;
3. Parameter Description:
-f:force forcibly, forcibly copy whether the destination file or directory exists;
-i:interactive interaction, before overwriting, ask the user first;
-p:preserve, preserves the attributes of the source file or directory, including the owner, group, permission, and timestamp;
-r:recursive recursive, recursive replication, together with subdirectories and files under the specified directory;
-r:recursive with-R;
-v:verbose detailed, show the command execution process;
-a:archive file, archive copy, retain all attributes, often used for backup, equivalent to-DPR;
4. Example:
[Email protected] ~]# Cp/etc/inittab.
[email protected] ~]# LL
Total 108
-RW-------. 1 root root 1645 Mar anaconda-ks.cfg
-rw-r--r--. 1 root root 884 Oct 21:13 Inittab
-rw-r--r--. 1 root root 50101 Mar Install.log
-rw-r--r--. 1 root root 10608 Mar Install.log.syslog
[Email protected] ~]# cp-i/etc/inittab.
Cp:overwrite './inittab '? Y
[email protected] ~]# LL
Total 108
-RW-------. 1 root root 1645 Mar anaconda-ks.cfg
-rw-r--r--. 1 root root 884 Oct 21:14 Inittab
-rw-r--r--. 1 root root 50101 Mar Install.log
-rw-r--r--. 1 root root 10608 Mar Install.log.syslog
[Email protected] ~]# cp-r/etc/.
[email protected] ~]# LL
Total 120
-RW-------. 1 root root 1645 Mar anaconda-ks.cfg
Drwxr-xr-x. Root root 12288 Oct 21:18 etc
-rw-r--r--. 1 root root 884 Oct 21:15 Inittab
-rw-r--r--. 1 root root 50101 Mar Install.log
-rw-r--r--. 1 root root 10608 Mar Install.log.syslog
[Email protected] ~]# cp-v/etc/passwd.
'/etc/passwd './passwd '
[email protected] ~]# LL
Total 124
-RW-------. 1 root root 1645 Mar anaconda-ks.cfg
Drwxr-xr-x. Root root 12288 Oct 21:18 etc
-rw-r--r--. 1 root root 884 Oct 21:15 Inittab
-rw-r--r--. 1 root root 50101 Mar Install.log
-rw-r--r--. 1 root root 10608 Mar Install.log.syslog
-rw-r--r--. 1 root root 1676 Oct 21:19 passwd
[Email protected] ~]# cp-a/etc/sudo.conf.
Cp:overwrite './sudo.conf '? Y
[email protected] ~]# LL./sudo.conf/etc/sudo.conf
-rw-r-----. 1 root root 1786 Sep/sudo.conf
-rw-r-----. 1 root root 1786 Sep 2012/etc/sudo.conf
Mv:move Mobile
-
Command function:
Used to move files or rename files, often used to back up files or directories;
2. Command format:
MV [options] Source...source destination
3. Parameter Description:
-f:fource forcibly, if the target already exists will not ask for direct coverage;
-i:interactive interaction, ask before overwriting;
-u:update Update, if the target file already exists and the source file is newer before it is updated;
-t:target target, specify the target directory for MV, which is suitable for moving multiple source files to a target, at which point the target directory is before the source file;
4. Example:
[Email protected] ~]# mv-v./inittab/tmp
'./inittab ', '/tmp/inittab '
[Email protected] ~]# ll/tmp
Total 40
-rw-r--r--. 1 root root 884 Oct 21:15 Inittab
DRWX------. 2 root root 4096 Oct 20:46 keyring-u00hv0
DRWX------. 2 root root 4096 Oct 17:18 KEYRING-UTQ8QB
DRWX------. 2 root root 4096 Oct 20:47 orbit-root
DRWX------. 2 cgy cgy 4096 Mar pulse-fsspasexslkn
DRWX------. 2 root root 4096 Oct 20:46 pulse-tut0vnmaelv9
DRWX------. 2 root root 4096 Oct 20:46 ssh-ahhowr1925
DRWX------. 2 root root 4096 Oct 19:15 VIRTUAL-ROOT.2BGEQZ
DRWX------. 2 root root 4096 Oct 20:46 virtual-root. Nwqzfc
DRWX------. 2 root root 4096 Oct 17:18 virtual-root.wg1kvw
[Email protected]ocalhost ~]# mv-i inittab/tmp
Mv:overwrite '/tmp/inittab '? Y
[Email protected] ~]# Cp/etc/inittab.
[Email protected] ~]# mv-f inittab/tmp
[Email protected] ~]# ll/tmp
Total 40
-rw-r--r--. 1 root root 884 Oct 21:40 Inittab
DRWX------. 2 root root 4096 Oct 20:46 keyring-u00hv0
DRWX------. 2 root root 4096 Oct 17:18 KEYRING-UTQ8QB
DRWX------. 2 root root 4096 Oct 20:47 orbit-root
DRWX------. 2 cgy cgy 4096 Mar pulse-fsspasexslkn
DRWX------. 2 root root 4096 Oct 20:46 pulse-tut0vnmaelv9
DRWX------. 2 root root 4096 Oct 20:46 ssh-ahhowr1925
DRWX------. 2 root root 4096 Oct 19:15 VIRTUAL-ROOT.2BGEQZ
DRWX------. 2 root root 4096 Oct 20:46 virtual-root. Nwqzfc
DRWX------. 2 root root 4096 Oct 17:18 virtual-root.wg1kvw
[Email protected] ~]# MV-T/tmp./sudo.conf
[Email protected] ~]# ll/tmp
Total 48
-rw-r--r--. 1 root root 1676 Oct 21:19 a
-rw-r--r--. 1 root root 884 Oct 21:40 Inittab
DRWX------. 2 root root 4096 Oct 20:46 keyring-u00hv0
DRWX------. 2 root root 4096 Oct 17:18 KEYRING-UTQ8QB
DRWX------. 2 root root 4096 Oct 20:47 orbit-root
DRWX------. 2 cgy cgy 4096 Mar pulse-fsspasexslkn
DRWX------. 2 root root 4096 Oct 20:46 pulse-tut0vnmaelv9
DRWX------. 2 root root 4096 Oct 20:46 ssh-ahhowr1925
-rw-r-----. 1 root root 1786 Sep sudo.conf
DRWX------. 2 root root 4096 Oct 19:15 VIRTUAL-ROOT.2BGEQZ
DRWX------. 2 root root 4096 Oct 20:46 virtual-root. Nwqzfc
DRWX------. 2 root root 4096 Oct 17:18 virtual-root.wg1kvw
File copy and move commands: CP and MV