top of page
Writer's pictureMukesh Chanderia

Linux - Commands Part 4 Remove , Move & Copy

Remove File & Folder


root@localhost ~]# rm abc

rm: remove regular empty file ‘abc’? Yes


root@localhost ~]# rm Folder1

rm: cannot remove ‘Folder1’: Is a directory


use "-r" to remove directory


root@localhost ~]# rm -r Folder1

rm: remove directory ‘heyRam1’? Yes


To remove forcefully directory use "-f"

root@localhost ~]# rm -rf test/


use argument "v" to print


root@localhost ~]# rm -vr "mukesh monu"

rm: remove directory ‘mukesh monu’? y

removed directory: ‘mukesh monu’


To remove all data of particular folder

root@localhost ~]# rm -vrf /tmp *

removed ‘/tmp/yum.log’

removed ‘/tmp/.X11-unix/X0’

removed directory: ‘/tmp/.X11-unix’

removed directory: ‘/tmp/.XIM-unix’


root@localhost ~]# mkdir India

[root@localhost ~]# ls

India

[root@localhost ~]# rename India Udaipur India

[root@localhost ~]# ls

Udaipur


Create multiple empty files with single command


root@localhost ~]# touch abc{1..9}

[root@localhost ~]# ls

abc1 abc2 abc3 abc4 abc5 abc6 abc7 abc8 abc9


Copy File "file1" to folder Udaipur


[root@localhost ~]# cp file1.txt Udaipur/


Copy folder to folder requires "-r"


[root@localhost ~]# cp -r Folder1 Folder2


If files are already present in folder then it will ask if you want to overide


root@localhost ~]# cp -rvf abc* India/

cp: overwrite ‘India/abc1’? Y


Now to say "Not" to overwrite add argument"n" in commad

root@localhost ~]# cp -rvfn abc* India


Move Data


root@localhost ~]# mv abc1 India/

mv: overwrite ‘India/abc1’? Y



25 views0 comments

Recent Posts

See All

Comentarios


bottom of page