Create a file hello.txt by using the following command. $ touch hello.txt Confirm that the file has been created successfully by listing the files. $ ls To create a copy of this file, enter the following. $ cp hello.txt hellocopy.txt List the files to confirm that a copy of the file has been created. $ ls Remove the hellocopy.txt file by entering the following delete command. $ rm hellocopy.txt List the files again to confirm that the file has been removed. $ ls The terminal will blindly carry out your commands without asking you to confirm the file to delete. If you want to be prompted when you delete a file enter the following. $ rm -i hello.txt Press N because there is an additional trick left. Enter the following but this time you will press the tab file. $ rm -i he<PRESS TAB> This should complete the file in the command line to read. $rm -i hello.txt Press Y to delete the file. When create files it is always nice to keep things organised. A directory will do just the job. Enter the following. $ mkdir myfiles Create a file. $ touch suntimebox.txt List the files and folders to confirm that they have been created. $ ls -lF Move the suntimebox.txt file into the myfiles directory. $ mv suntimebox.txt myFiles List the files and folders again and take note that the suntimebox.txt file is missing. $ ls -lF It is missing from the current directory because it was moved into the myFiles directory. Enter the following. $ cd myFiles $ ls -lF The file should appear in the directory that was created. Enter the following. $ cd .. Enter the pwd command to confirm your locations. $ pwd Confirm that you are in the /home/pi directory and enter the following. $ rm myFiles The output displays that you cannot remove ‘myFiles’ because it is a directory. This is because a flag is needed. Enter the following command. $ rm myFiles -r This will attempt to remove any files inside the myFiles directory before removing it.
|