e a directory that contains not other directories or files To delete the folder

E a directory that contains not other directories or

This preview shows page 8 - 11 out of 11 pages.

command is used to remove an empty directory (i.e., a directory that contains notother directories or files). To delete thefolderthat we created, type in the following command:rmdir folderUse thelscommand to confirm that the directory no longer exists. You should also see that it nolonger exists in your graphical window either. 8
Image of page 8
6.8 Your home directory - the ‘ ’ shortcut There’s one last shortcut that you should know - the shortcut to your home directory. Your home directory can be referred to by the tilde character. For example, if you want to change directories to your home directory, regardless of what your current working directory is, you can simply do: cd This shortcut will also come in handy later when you want to type in long paths that begin with your home directory. 7 Commands to manipulate files This section builds upon what you learnt in Section 6, allowing you to do some basic operations on files. 7.1 Copying files - the ‘cp’ command The ‘cp’ command is used to copy files. Two arguments must be supplied: the first is the path to the file that you wish to copy, and the second is the path to the file you wish to create. The file will be named whatever name you specify at the end of the second path. If you do not specify a file name at the end of the path, but just a directory, it will automatically be named with the same name as the original file. For example, you can copy the C program hello.c , which is located in the directory /share/copy/aps105s , to your home directory with the following command (try it): cp /share/copy/aps105s/hello.c Note that we used the tilde shortcut here for supplying the path to our home directory. Perform an ls within your home directory to confirm that the copy exists, and also check in the GUI window. If you wanted to copy the same file (into your home directory), but name the copy goodbye.c , you would use the following command: cp /share/copy/aps105s/hello.c /goodbye.c 7.2 Moving files and directories - the ‘mv’ command The mv command is used to move files. Two arguments must be supplied: the first is the path to the file that you wish to move, and the second is the path to the directory you wish to move it into. Try moving the file hello.c from your home directory into your Desktop by using the following command: 9
Image of page 9
mv /hello.c /Desktop The directory called Desktop within your home directory is the actual graphical desktop of the Linux machine, so you should see the file hello.c now appear in the Desktop. 7.3 Renaming files and folders with ‘mv’ The mv command can also be used to move files. In the previous step, the second argument to the command was a path to a directory. If, instead, we supply a path to a folder and then append a file name to the end of that path, the original file will be moved to that location and it’s name will be changed to whatever you specified. So, for example, if we wanted to rename the file hello.c (that now exists on the Desktop), we can use the following command to rename it to hello2.c : mv /Desktop/hello.c /Desktop/hello2.c 7.4 Removing (deleting) Files with the rm command The rm command is used to remove (i.e., delete) files. The single argument to
Image of page 10
Image of page 11

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture