Programming and Graphics

(Kiana) #1

A Unix Primer 315


mkdir koulis Generate a directory named koulis
rmdir kekos Remove the directory named kekos
(a directory can be removed only if empty)
rmdir -R kekos Remove directory kekos and its contents
(the argument -R stands for “recursive”)
mv kekos koulis Rename directory kekos to koulis
cp -R kekos koulis Copy directory kekos to koulis
ls kekos List files and folders in directory kekos
ls -a kekos Include hidden files beginning with a dot
ls -l kekos Long list of directory contents
pwd Print the name of the working directory
cd koulis Go to directory named koulis
(koulis can be the absolute or relative name)
cd / Go to the root directory
cd Go to the home directory
cd .. Go up one directory from working directory
cd ../.. Go up two directories from working directory
~ Home directory
~username A user’s home directory

. Working (current) directory
.. Parent of working directory
../.. Grandparent of working directory
../../.. Ancestor of working directory


Table A.1 Unix commands for manipulating directories. The “working directory”
is an abbreviation of the “current working directory.”


Theabsolute nameof the file or directory named “karaiskakis” in this
tree is:/home/karaiskakis. If we are situated in directory/home,therelative
nameof this file or directory is:karaiskakis.


Assume that the absolute name of a directory is:/usr/local/lib/vogle.
If we are situated in directory/usr/local, the relative name of this directory
is:lib/vogle.


Every user has a home (login) directory accessed at log in, denoted with
a tilde:~.


Unix commands are interpreted by a program called the Unixshell.Ex-
amples are thecsh,thetcsh,thebourne, and thebash(bourne again) shell.
While the basic commands are the same, each shell has its own dialect. We can
change the current shell by typing the name of a new shell. To exit the shell,
we type:exit.


The tables in the rest of this appendix illustrate basic Unix commands.
Free download pdf