Introduction to Linux shell commands
Chapter 2: Commands
Manipulating Files
Creating and Deleting
WARNING!! Linux does not have a command to undo a delete. Once you delete a file using rm, it is gone… forever…
touch fileName
creates a new file by the name “fileName”. Remember to specify the type of file (touch fileName.py
,touch fileName.txt
, etc…)mkdir dirName
creates a new directory nameddirName
rm fileName
deletesfileName
-i
representing interactive mode where you are asked if you are sure you want to remove the file (pressy
if you want the file to be removed and any other key otherwise)-r
representing recursion in which case, if it is a directory which you have specified to delete, it and all its contents are recursively deleted.
e.g. rm -rf someDirectory
deletes the directory someDirectory
, and recursively deletes all its contents - yeah scary.
Copying and moving
cp
copys a filecp file1 file2
copiesfile1
and names the copyfile2
cp file1 file2 file3 /someParentDirect/someChildDirect/
copiesfile1
,file2
andfile3
to the directorysomeChildDirectory
- to copy a directory and all its contents you need to pass the recursive
-r
argument
- to copy a directory and all its contents you need to pass the recursive
mv
moves files. Apply the same logic forcp
for functionality