What is the command to copy, read and remove file in linux

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.

Tags:

Linux

Cp

Rm

Files

Logs