|
|
|
|
S.V.N-MCA(cbcs) - UNIX COMMANDS
|
|
Learning How to Use Unix |
|
Once you have opened your ACCC account, what can you do to learn how to use it? The most important ingredient for you is to set aside time to experiment with Unix without being under a harassing deadline.
This Unix how-to gives the basic information you need to use Unix on the ACCC. There's lots more information on using Unix on the Web, from basic info to advanced topics. The Related Links page of this document gives selection.
|
|
|
|
|
And Don't Forget softlist and man Pages |
|
The principle Unix help command is man.
- Enter: man cmdname
- to get information on the command cmdname.
- Enter: man man
- to get more information on the man command itself.
man uses more to display the help one screen at a time. Press the Spacebar to display the next screen, type b to return to the previous screen, or type q to quit. - Enter: apropos keyword(s) (or the equivalent man -k keywords)
- to get a list of man pages related to the keyword(s) you specify.For example:
Enter: apropos mail for a list of commands relating to mail. - Enter: softlist
- to find out what software and utilities are available on any ACCC Unix machine in addition to the Unix standards. It gives a list and brief description of the additional software, and includes links to relevant man pages. The softlist software lists are also available on the World Wide Web.
- tigger:
There are also general information sources on the ACCC Unix machines, principally the Internet. (Though we don't recommend your using them; you're much better off doing your Web browsing on a personal computer.)
- Enter: lynx
- to use the Lynx text-based Unix Web browser when using VT100 communications (such as ssh or telnet), or
- Enter: mosaic & or: netscape &
- to use XMosaic or Netscape when using X Windows.
|
Files |
|
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.
How much disk space are you allowed to use? See ACCC Online Disk Space Policy.
|
|
|
|
|
File Attributes |
|
- file name
- A file name is a string of characters. Unix does not give special relevance to periods or other characters, although some programs expect specific types of filenames.
- full path
- The full path of a file specifies all directories, such as /usr/local/bin/foo.bar. The filename foo.bar can be used for this file when /usr/local/bin is the current directory.
- file permissions
- Each file has an associated owner and group. The owner is a logon account, and the group is a possibly empty group of logon accounts. The read, write, and execute permissions (which can be set by the owner) can be different for the owner, group, and public (other). Permissions apply to directories as well as files.
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 (other). 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 to 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.
|
|
|
|
|
File Commands |
|
ls |
gives a list of filenames in the current directory;
tigger (AIX) man page; icarus (Solaris) man page |
mv |
rename a file: mv oldfile newfile or mv oldfile newdir
tigger (AIX) man page; icarus (Solaris) man page |
cp |
copy a file: cp oldfile newfile or cp oldfile newdir
tigger (AIX) man page; icarus (Solaris) man page |
chmod |
change permissions; see "File Attributes" above for examples
tigger (AIX) man page; icarus (Solaris) man page |
rm |
remove a file;
tigger (AIX) man page; icarus (Solaris) man page |
cd |
change directories;
tigger (AIX) man page; icarus (Solaris) man page |
lpr |
print a file: lpr -P printer-name file
(see Using Unix: Printing for a brief introduction to printing on Unix);
tigger (AIX) man page; icarus (Solaris) man page |
pwd |
"print" working directory; returns the current directory
tigger (AIX) man page; icarus (Solaris) man page |
quota |
to see how much disk space you've used
(on icarus, use: quota -v)
tigger (AIX) man page; icarus (Solaris) man page
How much disk space are you allowed to use? See ACCC Online Disk Space Policy.
|
mkdir |
create a new directory;
tigger (AIX) man page; icarus (Solaris) man page |
rmdir |
remove a directory;
tigger (AIX) man page; icarus (Solaris) man page |
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
tigger (AIX) man page; icarus (Solaris) man page |
|
|
|
|
|
Processes |
|
The shell is a command line interpreter (as well as programming language). The Korn shell, or ksh, is used by default on the ACCC Unix systems. The shell reads the command line, interprets any special characters, and then runs the specified command, usually as a new process (which itself can spawn new processes). |
|
|
|
|
-- Process Commands |
|
ps |
list your current processes; note the PID (process id); you need the PID to change attributes of the processes;
tigger (AIX) man page; icarus (Solaris) man page |
kill |
send a signal to a process; kill -9 pid terminates the process with process id pid
tigger (AIX) man page; icarus (Solaris) man page |
& |
run a command in the background and return immediately with a prompt; put the & at the end of your command |
nohup |
put this command at the beginning to make a background process continue after you break the logon connection;
tigger (AIX) man page; icarus (Solaris) man page |
Ctrl-c |
get prompt back |
Ctrl-d |
end of input; same as logout when in shell |
|
|
|
|
|
-- Special command line characters, i/o redirection |
|
. |
shorthand for the current directory |
.. |
shorthand for the parent of the current directory |
~user |
shorthand for the home directory of user; if user is not specified, then ~ is shorthand your home directory |
* |
match zero or more characters |
? |
match zero or one character |
> file |
send all screen output to file; erase any existing file |
>> file |
append all screen output to file |
< file |
read input from file rather than from the keyboard |
cmd1 | cmd2 |
use cmd1's output as input for cmd2 |
|
|
|
|
|
Miscellaneous but useful commands |
|
df |
show disk space usage for the machine
tigger (AIX) man page; icarus (Solaris) man page |
diff |
compare two files;
tigger (AIX) man page; icarus (Solaris) man page |
find |
recursively search for files;
tigger (AIX) man page; icarus (Solaris) man page |
grep |
search a bunch of files for a string;
tigger (AIX) man page; icarus (Solaris) man page |
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;
tigger (AIX) man page; icarus (Solaris) man page |
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;
tigger (AIX) man page; icarus (Solaris) man page
|
logout
exit |
end your Unix session; tigger (AIX) logout man page
end your Unix session; icarus (Solaris) exit man page |
man |
look up a manual page; man ls will tell about the options to the ls command, for example; main online documentation for Unix;
tigger (AIX) man page; icarus (Solaris) man page |
more |
make the output stop after each screen; Spacebar displays next screen, Ctrl-b displays the previous screen, q quits
tigger (AIX) man page; icarus (Solaris) man page |
quota |
check your own disk space usage and quota
(on icarus, use: quota -v)
tigger (AIX) man page; icarus (Solaris) man page
How much disk space are you allowed to use? See ACCC Online Disk Space Policy. |
sort |
sort the lines of a file;
tigger (AIX) man page; icarus (Solaris) man page |
w |
check system load;
tigger (AIX) man page; icarus (Solaris) man page |
wc |
count words, lines, and characters of a file
tigger (AIX) man page; icarus (Solaris) man page |
|
|
|
|
|
Examples |
|
- who am i
- To do the obvious; just who lists everyone who is logged on; likewise hostname tells you the name of the machine you're using.
(tigger (AIX) man page; icarus (Solaris) man page) - pwd
- To display current directory
- mkdir foo
- To make a new directory called foo.
- cd
- To change to your home directory from anywhere.
- cd bin
- To change to the bin directory under the current directory.
- cd /usr/local/bin
- To change to the /usr/local/bin directory, regardless of what your current directory is; much of the public software is stored in the subdirectories of the usr directory
- ls -l -a -R | more
- To get a list of all files in a directory. -l to get a long listing, with permissions; -a to include files with filenames beginning with a period (.); and -R (note the R is uppercase) to also list the files in all subdirectories of the current directory. And since this is likely to be a long listing, it's "piped" into more so the display pauses at the end of each screen.
- ls -l a*.c
- To get a long listing of all files with filenames starting with a and ending in .c.
- more .profile
- To display your .profile file, when your current directory is your home directory.
(See Using Unix: Customizing Korn Shell for more information about .profile and .env files. - more ~/.profile
- To display your .profile file when your current directory is not your home directory.
- cp ../foobar .
- To copy the file foobar from the parent of the current directory into the current directory.
- rm -i ??
- To remove (erase) all files in the current directory with exactly 2 characters in the filename, verifying each erase with a y or n .
- mv foobar ../newdir/fubar
- To rename the file foobar to fubar and place it in the directory newdir, that is a child of the parent directory of your current directory.
- chmod u+x foobar
- To make the file foobar executable by its owner.
- chmod -R a+r *
- To make all files the current directory and all files in all subdirectories (-R) readable by everyone.
- man ls
- To get information on the command ls and its flags.
- ps -e | more
- To get a list all processes piped into more; without the -e only the processes associated with your session are listed
- nohup cmd < foo.in >> foo.out &
- To run the command cmd, taking input from foo.in, appending output to foo.out, and run the command in the background so that you can log off and have the command continue to run. (Without the >>, nohup puts output in the file nohup.out.)
- grep double *.c
- To search all the C source files for the string "double".
- ls -l | grep ^d | wc -l
- To find the number of subdirectories in the current directory.
- find ~ -name foobar -print
- To search for all files named foobar in your home directory tree.
- uncompress foo.Z
- To uncompress the compressed file foo.Z in the current directory.
(tigger (AIX) man page; icarus (Solaris) man page) - tar -xf foo.tar
- To extract the contents of the file foo.tar in the current directory.
- diff foobar fubar > diffbar
- To find the differences between foobar and fubar and record the differences in a file called diffbar.
- pine consult@uic.edu
- To send a note to consult@uic.edu; enter just: pine for a complete mail management menu.
(tigger (AIX) man page; icarus (Solaris) man page)
|
|
Today, there have been 10 visitors (11 hits) on this page!
|
|
Hi friends external exam is comeing soon study well
best of luck |
|