Some very basic UNIX commands
Last modified Sunday, January 24, 1999 11:40 AM
man
command
- Displays the online manual for command.
- example:
man man
- Displays the online manual describing the man command.
cd
directory
- Changes current working directory to directory.
- example 1:
cd 310programs
- Changes current working directory to 310programs
(assumes that 310programs is a subdirectory of current working directory)
- example 2:
cd ..
- Changes current working directory to next higher parent directory.
ls
- List contents of current working directory.
- example 1:
ls
- Lists the names of all the files and subdirectories in the current
working directory.
- example 2:
ls -a
- Lists the names of all the files and subdirectories in the current
working directory, including "hidden" ones.
mkdir
newDirectoryName
- Creates a new subdirectory named newDirectoryName.
- example:
mkdir 310programs
- Creates a new subdirectory named 310programs.
(assumes that 310programs does not yet exist as a subdirectory of current working directory)
- example 2:
cd ..
- Changes current working directory to next higher parent directory.
rmdir
directory
- Deletes directory (if it is empty).
- example:
rmdir CS_250
- Deletes the directory CS_250 if it is empty.
If not empty, gives an error message.
rm -r
directory
- Deletes directory and all the files and subdirectories in it.
- example:
rm -r CS_250
- Deletes the directory CS_250 and all its contens.
Be very careful with this one.
mv
oldname newname
- Renames a file or directory.
- example:
mv myprog oldmyprog
- Changes the name of myprog to oldmyprog.
If the target (oldmyprog in this example) already exists,
it is replaced. So be careful!
rm
filename
- Deletes a file.
- example:
rm sort.c
- Deletes the file sort.c.
cp
fromname toname
- Copies a file.
- example:
cp dothis.c dothat.c
- Makes a copy of the file dothis.c and names the copy dothat.c.
emacs
filename
- Invokes the emacs text editor, using the file filename.
If filename does not exist, creates it.
- example:
emacs myprog.c
- Opens
myprog.c
in emacs
. If myprog.c
does not exist,
creates it.
emacs
is a very rich text editor with many features to learn.
It is easy, though, to get started.
- Simply type what you want.
- Use the "
delete
" key to delete the previous character.
- You can move around in your text using the arrow keys.
- When you are finished, type
control-x
then control-c
.
You will be presented with a list of options.
The most commonly used one is "y", which saves your work.
- This very short description of
emacs
is very inelegant,
but it will allow you to do the work required in this class.