CSC 308 UNIX Basics
Command | Description |
cp source_file target_file
cp source_file ... target_directory cp _rp source_directory target_directory |
Copy files or directories. The first form copies the single source_file
to the target_file. If the target exists, it is overwritten. If the
target does not exist, it is created.
The second form of cp copies one or more source_files into the target_directory. The target must exist. The third form recursively copies an entire source_directory hierarchy to the target_directory. If the target exists, the source is copied into it. If the target does not exist, it is created. |
mv source target |
Move the source file or directory to the target file or directory. If source is a file, target cannot be an existing directory. |
ln -s source_file target |
Create a symbolic link, i.e., an alias or short cut, from the source_file to the target. If the target is a file, it cannot exist. If the target is a directory, a file of same name as source_file cannot exist. |
mkdir name |
Make a directory of the given name. A file or directory of the given name cannot exist. |
rm file ... rm -r directory rmdir directory |
Remove files or directories. The first form removes one or more file(s). The second form recursively removes an entire directory hierarchy. The third form removes an empty directory. |
cd directory |
Change the current working directory to the given directory. |
pwd |
Print the current working directory. |
chmod permissions file ... chmod -R permissions directory |
Change the permissions mode of the given file(s) to the given permissions. The first form changes one or more files. The second form recursively changes all files in the given directory. The permissions argument is a octal number with values defined as follows: 0400 Allow read by owner. |
ls ls -sal |
List the contents of the current directory. The first form lists just the file names, not including files staring with ".". The second form gives a long-form listing of all files, including their sizes, modification dates, and permissions. |
man command_name |
Print the detailed manual page for the given command_name. |
In the preceding commands, file and directory arguments are specified as a path name, in one of these forms:
Here are some examples of typical commands useful in CSC 308.
Exmaple Command | Description | ||||||
cd - or - cd ~ |
Change to your home directory. Your home directory is the default when you initially log in, so this command is only necessary when you've used cd to change to some other directory. | ||||||
mkdir cpe308 |
Make a directory named "cpe308". | ||||||
chmod 700 cpe308 |
Change the permissions of cpe308 so that no one but you can access the files. | ||||||
cd cpe308 |
Change into the cpe308 directory. | ||||||
cp ~gfisher/classes/308/handouts/unix-commands.html . |