What's new

Welcome to Ruzgar.com

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask questions and get answers from our community

Answer

Answer questions and become an expert on your topic

Contact us

Contact the site administrator directly.

Groups

Just like Facebook join them and enjoy.

Centos Lesson 3 Moving, Copying, Deleting Files

ruzgar

Administrator
Staff member
Joined
Oct 3, 2021
Messages
37
Reaction score
0
Points
6
In general, move, copy and delete operations are done with the cp, rm and mv commands.

Linux Copy Command cp
  • cp ruzgar.txt com.txt : Copies the data in the ruzgar.txt file into the com.txt file. If there is no com.txt file, it will create it. If the file exists and is full, it deletes it and creates a new one.
  • cp -i ruzgar.txt com.txt : Writes the data in the ruzgar.txt file into the com.txt file, but warns us if there is a file. He asks if he will change.
  • alias cp=' cp i' : defaults to using the cp command as cp -i. Thus, it makes the copying process safe.
  • cp -r /root/ruzgar /usr/com : This command copies the file named ruzgar and the al folders into the com folder.
  • cp * : Copies all files in the current directory.
  • cp *.jpg *.pdf /ruzgar : All jpg and pdf files in the current folder are copied into the ruzgar folder.
  • cp --backup ruzgar.txt /root/com : The purpose of this code is to prevent copy errors. If there is already a ruzgar.txt file in com, adding ~ saves the file with different names.
Move Command mv in Linux
  • mv ruzgar com : Moves the file named ruzgar into the file named com.
  • mv ruzgar /usr/com: it will also move the file named ruzgar into /usr/com.
  • mv [ruzgar] [com] : It will change the file named ruzgar to com.
Erase Command in Linux rm
  • rm wind : It will delete the wind folder we created in Lesson 2.
1635187091133.png
  • rm *txt: Deletes all txt files in the directory.
  • rm /ruzgar/com: Deletes the com folder in the ruzgar folder.
 
shape1
shape2
shape3
shape4
shape5
shape6
Top