I am trying to learn how to copy a from one folder to other using command prompt using 'cp' command,file is getting copied from "home" folder to "documents" folder but i am unable to copy from "documents" folder to "home" folder.Can someone explain why?
closed as unclear what you're asking by Sylvain Pineau, muru, Rinzwind, steeldriver, Byte Commander♦ Jul 24 '15 at 15:41
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
That depends on what your command actually looks like.
The following would work:
cp /home/$USER/Documents/file /home/$USER
Or as @kos suggested:
cp ~/Documents/file ~/
First go to the location from where the file is to copied using the
cp "foldername" -R ~/"foldername"
You can't copy documents into the
/home folder without
sudo rights. To do that, use this command
sudo cp /home/$USER/Documents/file_name /home
or to save the permissions (thx @kos)
sudo cp --preserve=mode,ownership /home/$USER/Documents/file_name /home
If you meant your
home folder, than use
cp /home/$USER/Documents/file_name ~
cp /home/$USER/Documents/file_name /home/$USER/
To copy from your documents folder try:
cp filenameHere /home/$USER
For example, assuming I am located at the Documents folder:
And I want to copy the file: foo.txt to my home folder:
cp foo.txt /home/$USER
If you are not currently on the Documents foler, you must cd to it first:
Then you can do
ls to list your files, remember, the terminal and linux commands are case sensitive:
After the files are listed, use the
cp command to copy to the location you want.