Unix commands are intentionally short, often only two or three characters in length, in order to minimize typing.
The general format for a Unix command is:
cmd -options other arguments
where "cmd" is the name of some command followed by a number of options or other arguments.
Options are generally single characters that represent specific options. The minus sign "-" should be entered before an option. Observe the format of the option in the man command in the following table.
Unix is case-sensitive, so be sure you enter the options and arguments in the proper case. Generally lower case is used for commands.
A few commands you should become familiar with:
cd path |
change directory. |
cd |
change to home directory |
cp path1 path2 | Copy file(s). |
chmod permissions path |
change the mode, the permissions, on a file or directory.
|
ls |
to get a listing of files in a directory |
man command |
to get a Unix Manual entry for a command. |
man -k topic |
use the -k option to find all the entries for a specific topic. |
mkdir path | make a directory |
more command | When the command is executed, more pauses the output when the screen is full. You can view the next screenful or just the next line. Look for the instructions at the bottom of the screen. Enter q to exit more. |
mv file1 file2 |
move file1 to file2 or rename file1 to file2. The original file is deleted. |
passwd | Change your Unix password. |
pwd |
print working directory, i.e. show current path. In other words: where am I in the Unix file system. |
rm path | to delete (remove) a file |
rmdir path |
to delete (remove) a directory. |
script file_name |
cause everything that appears on the screen to be placed in the file_name. |
The following illustration explains how to use several of these Unix commands to create a "Home Page" that can be viewed as an Internet World Wide Web file.
cd |
Ensure that you are in your home directory. |
chmod 711 ~ |
Change the mode of your home directory to make it world readable. |
mkdir public_html |
Make a directory called "public_html"; notice the underscore character. |
chmod 711 public_html |
Make public_html world executable. |
cd public_html |
Change your location to the public_html directory you just created. |
pwd |
Print the current working directory just to make sure you are where you want to be. |
Use an editor to create a file called index.html or copy a sample file from another location. |
|
ls -l |
Get a long listing of your current files. If you had used nano to create the file, you will see something like this: |
chmod 644 index.html |
Change the file mode so that others can read the file. |
ls -l |
Get a long listing to make sure the file permissions are set properly. |
© Department of Computer Science, University of Regina.