Question

This is my first time trying to work with Linux Scripts so this may be something obvious.

Here is what I am trying to do:

  1. Remove all contents from local folder - rm /home/user/Documents/Exercise/
  2. Copy files from a shared windows network drive - cp smb://server/arc/Exercise%20Files/Word/

So from my understanding my command should look like this

  rm /home/user/Documents/Exercise/
  cp smb://server/arc/Exercise%20Files/Word/ /home/user/Documents/Exercise/

But anytime I try and run either of the above commands I get the following error:

  "rm: cannot remove `/home/user/Documents/Exercise/': Is a directory"
  "cp: cannot stat `smb://server/arc/Exercise%20Files/Word/': No such file or directory"

What am I doing wrong?

Kind Regards,

M

Was it helpful?

Solution

Based on your request and your test, let me point what is not written properly:


Remove all contents from local folder

rm /home/user/Documents/Exercise/

Error says rm: cannot remove /home/user/Documents/Exercise/': Is a directory

You should

  rm /home/user/Documents/Exercise/*

which will delete everything inside the directory, but not the directory.


Copy files from a shared windows network drive

  cp smb://server/arc/Exercise%20Files/Word/ /home/user/Documents/Exercise/

Error says cp: cannot stat smb://server/arc/Exercise%20Files/Word/': No such file or directory

You should check if route smb://server/arc/Exercise%20Files/Word/ is correct. Then, use the following:

cp smb://server/arc/Exercise%20Files/Word/* /home/user/Documents/Exercise/

OTHER TIPS

You can't delete a directory if it has content within it. To delete the content and the directory at the same time, use the following command:

rm -r /home/user/Documents/Exercise/

This recursively deletes the directory and any content within it.

To copy the file, I believe you have to mount the directory beforehand, like so:

mount -t cifs //server/share /mnt/mount_directory -o user=username

Can you confirm if that works?

Remove / Delete Command: rm -rfv /home/user/Documents/Exercise/*

Copy Command: cp -rfv /home/user/Documents/ExerciseShare/ExerciseFiles/Word/ /home/user/Documents/Exercise/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top