CP (Copy) File Settings in Linux and Unix

Many of today’s dedicated servers run Linux distributions (such as CentOS) or Unix-like operating systems (such as FreeBSD). Therefore, it is very important to be familiar with Unix commands and how to get the most out of them, even if you spend most of your time managing your server from the comfort of a web-based control panel. On some occasions, you will need to log in to your server via SSH and get your hands a little dirty on the command line.

The copy command is a powerful tool that you can use put files exactly where you need them to be. The command for copy is “cp”. The most basic copy command is to copy from one location to another:

cp /home/user/fileone /home/user/backup/fileone

In order to copy multiple files, you can use the “*” wildcard. For example:

cp /home/user/* /home/user/backup

In this example, it will copy the files in the parent directory to the backup directory, but it will not copy the backup directory as well. Instead it will say:

cp: omitting directory: '/home/user/backup'

To copy directories, use the “-r” (recursive) option:

cp -r /home/user/directory1 /home/user/backup

The copy command has many other options that you can use. For a full list of them and complete information regarding their functions, type “man cp” from the command line or visit the manual page online.











Comments: