Jack Wallen continues his Linux 101 series, with an introduction on how to copy files and directories from the command line.
Are you new to Linux? If so, you’ve probably found the command line can be a bit intimidating. Don’t worry–it is for everyone at the beginning. That’s why I’m here to guide you through the process, and today I’m going to show you how to copy files and folders from the command line.
Why would you need to copy files and folders this way? You might find yourself on a GUI-less Linux server and need to make a backup of a configuration file or copy a data directory.
Trust me, at some point you’re going to need to be able to do this. Let’s find out how.
SEE: Linux: The 7 best distributions for new users (free PDF) (TechRepublic)
First we’ll copy a file. Let’s say you’re about to make changes to the Samba configuration file, smb.conf and you want a backup copy just in case something goes wrong. To copy that file, use the cp command to copy the source to the destination like so:
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
You’ve probably already encountered your first problem. Because the smb.conf