Skip to main content
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.
Source Link
user86219
user86219

Question 1: your command is correct:

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

May be here you ifIf you are copying it using other user than root please use belowdo 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.

NOTE: please make sure you use correct arguments of cp command. To know more about cp use cp --help

Question 1: your command is correct:

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

May be here you if you are copying it using other user than root please use below:

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.

NOTE: please make sure you use correct arguments of cp command. To know more about cp use cp --help

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.

Question 1: your command is correct:

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

May be here you if you are copying it using other user than root please use below:

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-20200401rm /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/mv /var/log/btmp-20200401 /home/test/copyoflogfiles/

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

NOTE: please make sure you use correct arguments of cp command. To know more about cp use cp --help

Question 1: your command is correct:

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.

Question 1: your command is correct:

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

May be here you if you are copying it using other user than root please use below:

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.

NOTE: please make sure you use correct arguments of cp command. To know more about cp use cp --help

Source Link
user86219
user86219

Question 1: your command is correct:

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.