Working with files

From Oxxus Wiki

Jump to: navigation, search

To copy and move files around the server, you would need to use cp and mv command. Below are few scenarios of use of these commands.

cp - copying files format: cp arg1 arg2 where arg1 is source file and arg2 is destination path, i.e. cp /root/file1 /home/user

To copy a directory containing files you will need to use -r option which would recursively copy files and folders in the folder. For example:

cp -r /var/www/html /root

mv - moving and renaming files and folders

format: mv arg1 arg2 (where arg1 is source and arg2 is destination path).
mv /root/website /var/www/html

rm - removing files and folders

format: rm arg1 (where arg1 is file to be removed. i.e. rm file1)

To remove a directory containing files you would need to use -rf option

rm -rf /root/website
  • -r is a switch to remove content recursively with all the content in the directory as well
  • -f is a switch to force removal without asking you for permission each time it deletes the file

ln - linking files and folders

format: ln arg1 arg2

where arg1 is source file or folder and arg2 is destination path, hard-links these two arguments.

If you delete one, the other will be affected as well.

ln -s arg1 arg2 would make a symbolic link where you can safely remove the link without affecting the source.

ln -s /var/www/html /var/www/htdocs
Contact About Us Support Network Servers Java Hosting Oxxus.net Order Now! Dedicated Servers VPS Hosting Tomcat Hosting Java Hosting Money Back Guarantee Privacy Policy Oxxus.net Terms of 
Service Contact About Us Servers Networks Support Domain Names SSL Certificates Java Wiki Tutorials E-learning 
Platforms