|
Everything in UNIX is a "file" -- real files, directories, device drivers, and so forth. This makes it easy to combine files and programs in many different and new ways. Directories are special files that hold the names of other files or other directories. In this way, the UNIX file system looks like a hierarchical tree, similar to DOS. Note that directories are separated by a forward slash ( / ) not a backslash ( \ ) as in DOS. |
|
||||||||||||
|
|
|
||||||||||||
|
Enter ls -l to find the permissions on the files and subdirectories in the current directory. This returns lines that look something like the following: drwx------ 2 bobg comp 512 Jun 7 09:49 mydir -rwxr-xr-x 1 bobg comp 321 May 30 14:36 myscript Each line describes one file. From left to right: the permissions, the number of links, the owner, the group owner, the size in bytes, the date and time of the last modification, and the file's name. The first character of the permissions tells what kind of "file" it is; d for directory, hyphen (-) for regular file. The remaining nine characters are three triplets. The triplets give the read, write, and execute permissions for that file or directory for that file for, respectively, the file's owner, its group owner, and for the public. The r (read), w (write), and x (execute), indicate the presence of read, write and execute permissions; the hyphen (-) indicates their absence. For directories: r permission allows you do list the files in the directory, w permission allows you to create or remove files from the directory, and x permission allows you to cd to the directory. Thus, in this example, both files are owned by bobg and have the group comp as group owner. mydir is a subdirectory in which only bobg can read, write, and execute; and myscript is a file in which bobg can read, write, execute, and everyone else, including those in group comp, can read and execute but not write. The chmod command changes file permissions. For example chmod u+x file adds execute permission to file for the owner (user); use u-x to remove execute permission for the owner. u indicates the file's owner (user), g the owner's group, o the public (other), or a for all three; and r is read permission, w is write permission, and x is execute permission. |
|
||||||||||||
|
ls |
gives a list of filenames in the current directory; |
|
|||||||||||
mv |
rename a file: mv oldfile newfile or mv oldfile newdir |
|||||||||||||
cp |
copy a file: cp oldfile newfile or cp oldfile newdir |
|||||||||||||
chmod |
change permissions; see "File Attributes" above for examples |
|||||||||||||
rm |
remove a file |
|||||||||||||
cd |
change directories |
|||||||||||||
lpr |
print a file: lpr -P printer-name file |
|||||||||||||
pwd |
"print" working directory; returns the current directory |
|||||||||||||
quota |
to see how much disk space you've used |
|||||||||||||
mkdir |
create a new directory |
|||||||||||||
rmdir |
remove a directory |
|||||||||||||
compress |
compress a file into one with a .Z extension; uncompress reverses the process |
|||||||||||||
tar |
package a group of files into one file for moving or archiving; also extracts tar files |
|||||||||||||
|
df |
show disk space usage for the machine |
|
|||||||||||
diff |
compare two files; |
|||||||||||||
gzip |
gzip myfile compresses myfile . The compressed version of myfile has the same name with an appended extension of .gz and when possible has the same file ownerships, access, and modification times |
|||||||||||||
gunzip |
gunzip myfile.ext decompresses (restores to its original form) myfile.ext where ext can be: .gz .taz .tgz .z -z z or .Z . gunzip decompresses files created by: gzip , zip , compress , compress -H , or pack; |
|||||||||||||
logout |
end your UNIX session; |
|||||||||||||
man |
look up a manual page; man ls will tell about the options to the ls command, for example; main online documentation for UNIX |
|||||||||||||
More |
make the output stop after each screenful; Spacebar displays next screenful, Ctrl-b displays the previous screenful, q quits |
|||||||||||||
Passwd |
change your password; |
|||||||||||||
Quota |
check your own disk space usage and quota |
|||||||||||||
|
To extract the contents of the file foo.tar in the current directory. |
|