- Starting Up the Terminal
- Moving around the Filesystem
- Manipulating Files and Folders
- System Information Commands
- Searching and Editing Text Files
- Dealing with Users and Groups
- Getting Help on the Command Line
- Searching for Man Files
- Using Wildcards
- Executing Multiple Commands
- Moving on to More Advanced Uses of the Command Line
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.
- 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."