Appendix C The Command-Line Interface 225
THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE
Handling files
To practise working with files, change to the Desktop directory and type the following:
touch Test
You’ll see a file called Test appear on the desktop. The touch command is normally used to
update the date and time information on a file, but if – as in this case – the file doesn’t exist, it
creates it.
Try the following:
cp Test Test2
You’ll see another file, Test2, appear on the desktop. This is a copy of the original file,
identical in every way. Delete it by typing:
rm Test2
This removes the file, and you’ll see it disappear.
Next, try:
mv Test Test2
This command moves the file, and you’ll see your original Test file disappear and be
replaced by Test2. The move command, mv, can be used like this to rename files.
When you’re not on the desktop, though, you still need to be able to see what files are in a
directory. Type:
ls
This command lists the contents of the current directory, or any other directory you give it.
For more details, including listing any hidden files and reporting the sizes of files, try adding
some switches:
ls -larth
WARNING!
Unlike deleting files using the graphical File Manager, which stores them in the Wastebasket
for later retrieval, files deleted using rm are gone for good. Make sure you type with care!