Jack Wallen carries on his Linux 101 series, with an introduction on how to duplicate documents and directories from the command line.
Are you new to Linux? If so, you’ve got most likely identified the command line can be a bit daunting. You should not fear–it is for everybody at the commencing. Which is why I’m below to information you via the procedure, and right now I’m likely to show you how to copy information and folders from the command line.
Why would you need to copy data files and folders this way? You may well find by yourself on a GUI-fewer Linux server and have to have to make a backup of a configuration file or copy a facts listing.
Trust me, at some stage you might be going to want to be in a position to do this. Let us obtain out how.
SEE: Linux: The 7 ideal distributions for new people (free PDF) (TechRepublic)
To start with we’ll copy a file. Let us say you’re about to make changes to the Samba configuration file, smb.conf and you want a backup copy just in case a little something goes erroneous. To duplicate that file, use the cp command to copy the resource to the location like so:
cp /and many others/samba/smb.conf /and many others/samba/smb.conf.bak
You’ve got possibly presently encountered your initial problem. Because the smb.conf file is in /etcetera/, you’ll want to use sudo privileges to make the copy. So the suitable command is:
sudo cp /etc/samba/smb.conf /and many others/samba/smb.conf.bak
In this case in point, smb.conf is our resource and smb.conf.bak is our place. You may well want to maintain the file attributes (this kind of as listing and file manner, ownership, and timestamps) throughout the duplicate. For that we use the -a choice as in:
sudo cp -a /and so forth/samba/smb.conf /etcetera/samba/smb.conf.bak
Copying a directory is finished in the exact same way, only you use the -R selection, for recursive. Let us say you want to make a backup of the entire /etc/samba listing and you want to duplicate it to your residence directory. That command would be:
sudo cp -R /and so forth/samba ~/samba.bak
To preserve the characteristics, while copying the listing, the command would be:
sudo cp -aR /and many others/samba ~/samba.bak
And that’s all there is to it. You have just copied your first documents and directories from the Linux command line. Now, go out and celebrate this victory, you’ve gained it.
Subscribe to TechRepublic’s How To Make Tech Operate on YouTube for all the most current tech advice for business enterprise professionals from Jack Wallen.