Skip to main content
3 of 3
change wording about using sudo, and remvoe the cp --help - that does not work on all *nix like systems - just calling cp with no arguments will give more clues.
user avatar
user avatar

Question 1: your command is correct:

cp /var/log/btmp-20200401 /home/test/copyoflogfiles/

If you do not have the file system privileges to copy the file, then the sudo command can be used to elevate your permissions, for example:

sudo cp /var/log/btmp-20200401 /home/test/copyoflogfiles/

Question 2:

You can use the cp command from any directory to any other directory if you are using full paths so you could run that command in any other directory.

Question 3:

rm /var/log/btmp-20200401

Would remove that file, to be sure you could use rm -i filename which will prompt you for the correct file.

However it might be better to use the mv command rather than cp followed by rm

So your command would change to:

mv /var/log/btmp-20200401 /home/test/copyoflogfiles/

Which would move the file rather than a copy and delete.

user86219