Copy Command
--------------------- >>>copy file9 from root to Directory with full path
cp /home/haritaraka12078/file9 /home/haritaraka12078/abc3
---------------------- >>>copy file10 from root to Directory directly without specify directory path
cp /home/haritaraka12078/abc3/file10 ../hari_training
---------------------- >>>For Acknowledge copy(-v)
cp -v /home/haritaraka12078/tee4 /home/haritaraka12078/file.txt
Output: ‘/home/haritaraka12078/tee4’ -> ‘/home/haritaraka12078/file.txt’
---------------------- >>>For Acknowledge & Override confirmation(-vi)
cp -vi /home/haritaraka12078/tee4 /home/haritaraka12078/file.txt
OUTPUT:
cp: overwrite ‘/home/haritaraka12078/file.txt’? yes
‘/home/haritaraka12078/tee4’ -> ‘/home/haritaraka12078/file.txt’
---------------------- >>>For Backup (tee2 file to tee2bak file)
cp -b tee2 tee2bak
---------------------- >>>For copy full direcctory to another direcctory
cp -r /home/haritaraka12078/hari_training /home/haritaraka12078/hari_dir
Output:
ls -l
drwxr-xr-x 2 haritaraka12078 haritaraka12078 4096 May 31 15:07 hari_training
---------------------- >>>All files copy from one direcctory to another direcctory
cp -r /home/haritaraka12078/hari_training/* /home/haritaraka12078/hari_dir
Output:
cd hari_dir/
-rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 15:09 file1
-rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 15:09 file10
drwxr-xr-x 2 haritaraka12078 haritaraka12078 4096 May 31 15:07 hari_training
MOVE Command
To move and Rename the file
- mv f1 f2
- mv -i f1 f2
- mv -v f1 f2
------------------------->> Move mvfile to file.txt
mv mvfile file.txt
------------------------->> (-i) will ask the override confirmation
mv -i tee1 tee2
Output:
mv: overwrite ‘tee2’? yes
------------------------->> (-i) will ask the override confirmation & (-V) will show the full route
mv -vi tee2 tee3
Output:
mv: overwrite ‘tee3’? yes
‘tee2’ -> ‘tee3’
------------------------>> Moving file from one directory to another directory
mv /home/haritaraka12078/tee3 /home/haritaraka12078/abc4 -
------------------------->> Moving file with 'RENAME', 'tee3' is old file - renaming to 'tee6'
mv tee3 tee6
Output:
ls -ltr
-rw-r--r-- 1 haritaraka12078 haritaraka12078 19 May 31 14:02 tee6
REMOVE Command
- rm filename
- rm -v filename It will the Acknowledgement after remove
- rm -i filename -It will ask to delete the file yes or no
- rm -iv filename -- It will give both Acknowledgement and ask to delete the file yes or no
- rm -f filename -- remove the file forcefully
- rm -rf direcory -- remove the direcory forcefully
- rmdir direcory-name -- It is used to remove the empty directory
- rm -r a{1..5} (To delete multiple files at a time)
----------------------------->> Removing file tee6
- rm tee6
----------------------------->> Removing file tee10 with acknowledgment by using (-V)
- rm -v file10
Output: removed ‘file10’
----------------------------->> Removing file9 with override confirmation by using (-i)
- rm -i file9
Output: rm: remove regular empty file ‘file9’? yes
--------------------->> Removing file8 with override confirmation & Acknowledgment by using (-vi)
- rm -vi file8
Output:
rm: remove regular empty file ‘file8’? yes
removed ‘file8’
-------------------->> removing directory, But if any files exist in that directory, we cannot remove
- rm abc4
Output: rm: cannot remove ‘abc4’: Is a directory
------>> Forcefully removing directory(-r), Even if any files exist in that directory, it can remove
- rm -r abc4
----------------------------->> for empty directory remove
- rmdir abc10
----------------------------->> removing no.of file at a once
- rm -r abc{1..2}