MV Command in linux explained
Mv means move
To rename
To move
mv [Option] source destination
Note: make sure to wait some time if you are moving large& multiple files
Ex: by renaming /var/www/html/var/www/html/all directories
Renaming file in linux
mv file1.txt desired name.txt
If file exist it’s overwrites, if not it will create.
-i asks for confirmation moving file
-f confirmation for overwriting (if write protected)
-b backup original file ~
mv -b file1 filed
ls
Filed file1~
-n existing file not overwrites
ls
file1.txt file2.txt
mv -n file1.txt xfile.txt
ls -l
file1.txt
file2.txt
xfile.txt
cp command(to copy)
To copy single file
cp source target
ls
file1.txt
cp file1.txt file2.php
ls
file1.txt
file2.php
copying directory
cp dir dir2
copy wordpress instalation direcotry to another
cp -r wordpress1 desiredname
or
cp -r /var/www/html/sarkariresultpro.in /var/www/html/sarkariplex.com
also check directory size
du -sh /path/to/directory
root@instance-1:~# du -sh /var/www/html/sarkariresultpro.in
1.2G
1.2G
copying multiple internal directories recursively
cp -r /var/www/html /etc/home/usr
cp -r /var/www/html/wordpress.in/wp-content/plugins/* /var/www/html/wp2.in/wp-content/plugins/
copy all files from one directory to another linux
-b for backup
-s to specify backup file name
-i overwritten confirmation
-l hardlink instead of creating new file.
–preserve to preserve file attributes &ownership details
delete existing files before copying or overwriting existing
rm -rf /var/www/html/wp.in/wp-content/plugins/*
copying wordpress themes to another wordpress directory in linux
cp -r /var/www/html/wordpress1.in/wp-content/themes/* /var/www/html/woprdpress2.com/wp-content/themes/
CP command to copy wordpress plugin to another website directory
cp -r /var/www/html/wordpress1.in/wp-content/plugins/* /var/www/html/woprdpress2.com/wp-content/plugins/
singe plugin
cp -r /var/www/html/wordpress1.in/wp-content/plugins/pluginname /var/www/html/woprdpress2.com/wp-content/plugins/pluginname
example
cp -r /var/www/html/muralijobs.in/wp-content/plugins/wp-schema-pro /var/www/html/recruitmentsboard.com/wp-content/plugins/wp-schema-pro
check plugins list
/var/www/html/muralijobs.in/wp-content/plugins/
cp -r /var/www/html/muralijobs.in/wp-content/plugins/custcode /var/www/html/railwayvacancy.in/wp-content/plugins/custcode
copy files with overwrite and recursively Linux
cp command to overwrite a copy operation without confirmation in Linux.
errors
cp: cannot stat ‘cp’: No such file or directory
cp: will not overwrite just-created
cp: target ‘/var/www/html/shivajobs.in/wp-content/plugins/*‘ is not a directory