Manipulating Files and Folders


You can manipulate files and folders using the following commands:

  • cp: The cp command will make a copy of a file for you. For example, cp file foo will make an exact copy of file and name it "foo," but the file "file" will still be there. When you use mv, that file would no longer exist, but when you use cp the file stays and a new copy is made.

  • mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: mv file foo will rename the file "file" to "foo." mv foo ~/Desktop will move the file "foo" to your desktop directory but will not rename it. You must specify a new file name to rename a file.

  • To save on typing, you can substitute ~ in place of the home directory.

    Note

    If you are using mv with sudo you will not be able to use the ~ shortcut. Instead, you will have to use the full pathnames to your files.


  • rm: Use this command to remove or delete a file in your directory. It will not work on directories in which there are files.

  • ls: The ls command will show you the files in your current directory. Used with certain options, you can see file sizes, when files were created, and file permissions. For example, ls ~ will show you the files that are in your home directory.

  • mkdir: The mkdir command will allow you to create directories. For example, mkdir music will create a music directory.

  • chmod: The chmod command will change the permissions on the files listed.

Permissions are based on a fairly simple model. You can set permissions for user, group, and world, and you can set whether each can read, write, and execute the file. For an example, if a file had permission to allow everybody to read but only the user could write, the permissions would read rwxr-r-. To add or remove a permission, you append a + or a - in front of the specific permission. For example, to add the capability for the group to edit in the previous example, you could type chmod g+x file.

  • chown: The chown command allows the user to change the user and group ownerships of a file. For example, chown jim file would change the ownership of the file to"Jim."



The Official Ubuntu Book
The Official Ubuntu Book
ISBN: 0132435942
EAN: 2147483647
Year: 2006
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net