UNIX File Manipulation
Some Definitions
- file
- -- the basic unit of storage in UNIX. can be text, a program,
a gif (picture), a sound file, etc.
- directory
- -- a special file where the UNIX system stores information
about other files. it's a place to store things, a folder. files and other
directories can be contained in directories, you can work in
directories.
- home directory
- -- this is the directory you are in when you first
log in. My home directory is at
/afs/rpi.edu/home/35/escobj. It's
also referenced as ~escobj.
- current working directory
- -- the directory you are currently working in,
duh! When you first log in, your current working directory (or just ``working
directory'') is your home directory. You can change to another directory, in
which case, the directory you just moved to becomes your current working
directory.
- absolute pathname
- -- The UNIX file system organizes its files and
directories in an inverted tree structure with the
root directory at
the top. An absolute pathname tells you the path of directories you must
travel to get from the root directory to the directory or file you want. In
a pathname, delimit directory names with a slash(/). For example,
/afs/rpi.edu/home/86/steubg/public/idkfa.wad is an absolute path to
the file idkfa.wad which is a cool DOOM wad that my friend Gregg
made last year.
- relative pathname
- -- the pathname of a file or directory relative to
your current working directory. Similar to the absolute pathname, you can
go through more than one directory level by naming the directories along the
path. Use ``..'' to go up the directory tree and use the name of the
directory to go down the directory tree.
Some Commands
- cd
- -- change directory
- pwd
- -- print working directory
- ls
- -- list
- cat
- -- concatenate
- more
- -- just plain ``more''
OK, Now What?
- Once you have somewhat of a grasp on cd, pwd, and ls,
try the following exercise:
- Go to your home directory. Enter cd
- Find your working directory. Enter pwd
- Change to new working directory. Enter cd /usr
- List files in new working directory Enter ls
- Change directory to root and list files. Enter cd /; ls
- Change to a new directory. Enter cd etc
- Give a wrong pathname. Enter cd xqk
- Change to a new directory with Enter cd /usr
absolute pathname.
- List files in another directory. Enter ls /usr/local/bin
- Find your working directory Enter pwd
(Notice that ls didn't change it).
- Return to home directory. Enter cd
- And once you get the idea of cat and more, try poking around
in different directories and looking at files. If you know a friend's home
directory, cd into it and see what's in his/her public directory.
Try to look at the contents of some of the files you find there (using
cat and more of course).