Unix and some c definitions U-MASS Unix nodes: se, jj, eris, ulab (Partial listing) Editor descriptions first emacs, pico, vi, and then commands and utilities ***************************************************************************** ***************************************************************************** Emacs, Glass pages 70-78 cntrl x auto_wrap mode, automatically inserts line breaks when words flow past the end of a line. To leave this mode, enter cntrl x again. cntrl y retrieve previous kill/inserts it. previous kills, use esc y after first using cntrl y. cntrl y get back first kill, while esc y gets back other kills. copy in emacs, escape x set mark command this sets mark at curser Then go to where you want to copy, enter cntrl/w Then you have d Terminates any emacs command buffers when two, to get to another, esc cntrl x b esc k delete a line cntrl, k (powerful!) insert cntrl y cntrl k delete a line from present position insert it cntrl y v move down in text, cntrl v g quit command function, cntrl g esc replace, or change a string, esc cntrl x cntrl f Edit another file fonts, at the command line enter xlsfonts for a listing, to run someone elses fonts emacs -u ~user_id change .emacs file to change your own fonts in emacs or do it in pico, etc repl s Search/Replace a string, exc x followed by "repl s" followed by enter, tutorial cntrl ht cntrl p move cursor up cntrl n move cursor down cntrl f move cursor right one character cntrl b move cursor left one character cntrl a move cursor to start of line esc < end of file esc > beginning of file cntrl V down one screen esc v up one screen cntrl s search for a string (current position to end) cntrl r search for a string (current position to beginning esc x, repl s global search and replace what was found ie, replace "\n" with '\n' every time "\n" was found. spell check esc,x,i,spell,buf cntrl g to end early Windows, multiple: two windows vertical: cntrl x 2 two windows horizontally: cntrl x 3 moving to another windows cntrl x 0 opening a file in another window cntrl x cntrl f emacs prompts you (Glass 75) VERY USEFULL ***************************************************************************** ***************************************************************************** Pico buffers, when two, to get to another, esc cntrl x b delete a line cntrl k move down in text, cntrl v quit command function, cntrl g replace, or change a string, esc replace a file, cntrl x f file.txt Menu driven, see menu in editor. Help is cntrl G ***************************************************************************** ***************************************************************************** The following are VI editor commands vi editor: see Glass pages 60 to 69 text mode i insert text in front of cursor x delete character at cursor R overwrites text a insert text after cursor position Command mode command mode delete: rm -r * removes all directories and files from the point you are in. rm * removes everything in the directory you are in escape/:d delete a line dw delete a word D Delete from current character position to end of line Deletes current character too! :60d Delete line 60 : Copy, or yank, copy lines 60-66: :60,66y :d delete a range, delete lines 60-66: :60-66d escape/:1,$ deletes all the lines in a file escape/1,. deletes all the lines from the start to the current cursor position escape/.,$ deletes all the lines from the current position to the end of the text. save: new file Create a new file by entering vi without giving it a name: enter vi, then when done, to save, enter w file_name This saves the file escape/:w save This displays characters and total number of lines. quit/no save: :q! what line are you on?: :f line number move around text: k up one line j down one line l right one character ^ to the start of the line $ to the end of the line b back one line w forward one word cntrl/D down half a screen cntrl/F done one screen cntrl/U up half a screen cntrl/B down one screen :5 brings you to line 5 copy/paste: copy/paste :y :36,37y copies lines 36 and 37 :4y copies line 4 paste at the cursor position, paste search: from current position, backwards: Current position backwards to the start of the text: in command mode enter ? followed by the string you are looking for, ie: ?string. This searches for string called "string" from current position, going forwards to the end of the text: /string (Glass 66) In file, open new file from command line: You are in hello.c, and wish to open unix.txt, enter You must have saved the other file first! If you go back an forth between files, you return to the position you were. Similar to above: Instead of editing current file, go to another file: :e file_name End vi commands. **************************************************************************** **************************************************************************** Commands specific to Linux, Red Had in particular! Boot disk, to create a boot disk: Format a high density disk (for DOS). Then put the CD rom into the drive. Go into the Dosutils directory in the CD ROM. Copy Rawrite onto your desktop. Windows will make it a DOS icon. Click the icon. Go into the Images directory on the CD ROM. Through boot onto the dos field (Works only on NT or 95 or 98. Hit enter. Type a: as your source disk. Hit enter. DONE **************************************************************************** **************************************************************************** Other commands and utilities//also helpful information -n number # all characters that follow up to a newline are a comment $ accesses a variable $$ pid for the shell you are using < verses >>: > Output redirection, writes standard output to a file << Output redirection, appends standard output to a file > Input redirection, reads standard input from a file. alias, slight differences between Unix, Linux: alias, show all alias, enter at command line alias Unix: alias hello echo "HELLO THERE" #Writes the script "Hello there" in Linux, alias lo="shutdown -h now" to log off Linux wants and "=", Solaris Unix does not want "=" Another Solaris unix example: alias l "ls -al" l get ls-al Linus: alias hello="'echo' string" alias hello="'echo' HEYY0U" ECHOS YOU KNOW WHAT! alias, unalias command enter alias for a list of all aliases enter 'unalias "alias name"' to remove alias al -al, ls -al provides a directory listing of all files including . files append/cat, cat two strings cat file1.txt>>file2.txt This appends file1.txt file2.txt \ or backslash, when a command is longer than a line enter / and continue typing on the next line. .chsrc commands: if a command must be run for each shell that starts up, the command should usuallyu appear in .cshrc. .logout file, the shell reads commands from it when you log out use this command to logout: shutdown -h now .login contains commands that are run only once at log in. These includes commands that affect your terminal settins, like tset, reset, and stty. Environment variables should also be in .login because they are non login shells variables, new shells inherit these values. .files, UNIX treats # as a comment ";" allows multible arguements on one command: Say you are in your root directory which is eris/home/bkonner. Here is how to get to eris/usr/include and to check for the location of malloc: cd ..;cd ..;cd usr/include;grep -n malloc *.* !"whatever", ie while in mail enter !date, and you get the date enter !pico and you enter pico mail. to quit mail, enter q bash shell is called bashrcd. Master bashrc file is located in this directory: /etc/bashrc bits, signed numbers: 0-7 are positive while 8-F are negative 7 is 0111 0 is 0000 8 is 1000 F is 1111 1010 is 10 decimal negative 10, 2's comp number is 1010 0101 is +1 0110 WHY? Take the reverse of 1010 which is 0101, add 1 WHY? 2 = 10, 1 = 1, 0 = 0, -0 = 0, -1 = 11111111 (8 bit number) so, if +1 is 00000001 (8 bit number), to get the negative, 2 comp number: reverse it and add 1: 00000001 becomes 11111110 + 1= 11111111 Another 2's comp example: take reverse, then add 1 2 is 00000010 11111101 +1 11111110 -2 1 is 00000001 11111110 +1 11111111 -1 0 is 00000000 11111111 +1 00000000 -0 (rollover of 1) -0 is 00000000 11111111 +1 00000000 +0 (rollover of 1) -1 is 11111111 00000000 +1 00000001 +1 -2 is 11111110 00000001 +1 00000010 +2 bit operators ~ not changes all bits 1010 becomes 0101 +10 becomes -11, -11 becomes +10 ^ Exclusive Or 1100 becomes 0011 & and | or x y NOTx xORy aANDy xEORy 0 0 1 0 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 Boot block, is the first logical block fo a disk. It contains some executable code that is used when UNIX is first activated. bourne shell, creating a bat file. First of all you have to be in that shell. Now, the first line of any bat program a comment # is not a comment, this is an actual line. You should on the first line show the path of the shell, ie #!/bin/sh -f prompt, set a prompt: PS1=`pwd`, but you need to script and create variables. FOR now, see shell and variables below. Cache speed verse amount of cache. Calendar: to see the date for example March 2006, enter: 'cal 3 2006' cat, short for catenate, takes input and sends it to output (Glass 30) cat 1 2>3 copies 1 and 2 to 3 cat 1 2>>3 same as above cat 1 2>>2 or cat 1 2>2 not allowed. Must do cat 1>2 copies 1 to 2 cd ~poneil/cs240/hw4 return to my directory: cd ~/cs240/exam Once in this directory, to return to my original directory, cd ~/cs240/hw4 change, to, a string in emacs enter esc, x, repl stri then follow instruction. chgrp, allows a user to change the group of files that he owns. (Glass 50). chmod, change the security of a file (Glass 51) modes: r,w,x,s(set upser id/set group id) groups, users: u,g,o(others),a(all) use - to remove, use + to add permission ls -ld shows attributes format: chmod o-r hw1.txt remove read permission from other hw1.txt This can also be done in octal. It works by setting a bit on or off. Permission modes are: drwxrwxrwx First is the directory, the owner, then group, then other. removing security to the group and others but giving full access to owner of file hw.txt would be: 700, because: 111000000 111/000/000 1 is on, or rwx all on for owner, but all are off for group and other chmod 700 *.* changes all files to rwx of owner but removes access to all others to all files in the directory ls -l |grep file_name means get regular expression FURTHER EXAMPLE: CHMOD, information on how to set using the number system It essentially takes the decimal value of the arguement and turns it into binary, see how: directory permissions user group world Binary Decimal 0 0 1 1 01 2 11 3 001 4 101 5 011 6 111 7 0001 8 Permissisons are rwx r==read, w==write x==execute 0 is off 1 is on Binary Decimal r w x 0 0 0 All are off 0 1 0 0 r is on others off 4 0 1 0 w is on others off 2 0 0 1 x is on others off 1 1 0 1 r & x is on w is off 5 1 1 1 r, w & x on 7 So, giving the user total access, and allowing group and world only read, the decimal is: 744, and the command on a file or directory is: chmod 744 file chsh, change shells. Bourne shell is: /bin/sh (Glass 86) Korn /bin/ksh C /bin/csh To execute a shell script, enter csh program_name.csh or: ksh program_name.ksh clear, clears screen (Glass 21) cntrl c, terminates a process, different from cntrl d which is end of input (Glass 26-26) comment, # cp -r os/* ik Copies everything, including directories from ok to ik copy between directories. Directory structure: file is in bkonner/os You want to put it into bkonner command is: cp file.name .. file is in bkonner/os You want to put it into bkonner/personal command is: cp unix.txt ../personal/. (/. is not necessary) debugger, p temp prints full string temp break, break trim, break at this line or function break 51, break at line 51 compile a program: gcc -g prog.c -o prog r Directories, Inode number 2 contains the location of blocks containing the root directory. A UNIX directory contains a list of associations between file names and inode numbers. When a directory is created, it is automatically allocated entries for ".." its parent directory, and "." itself. File names are stored in the directory blocks, not the inode list. Disk controller is a special chip, it moves the read/write head Disk, Unix disk structure: A disk is split up into sectors and further subdivided into concentric rings called tracks. The individual areas bounded by the intersection of sectors and tracks are called blocks. A block is the basic unit of disk storage. A typical Unix block can hold 4K bytes. Many disks have more than one level. Each level is called a platter. They are stacked one upon the other. A collection of tracks with the same index number is called a cylinder. Unix disk, first block is the BOOT BLOCK and contains executable code when UNIX is first activated. The second block is called the SUPERBLOCK, which contains a list of information concerning the disk itself. Following this is a fixed size set of blocks called the INODE LIST that holds all the inodes associated with the files on the disk. There can be quite a few inode blocks. Superblock contains: Total number of blocks in the file system. The number of inodes in the inode free list The free block bitmap which tells if the block is free The size of a block in bytes The number of free blocks The number of used blocks. Inode list is a listing of ten block locations on the disk for each file. After the first ten blocks listed in the inode list, the inode list points to a seperate block called the indirect block, which is a block containing a listing of up to 1024 other blocks that are a part of this file. Remember, each block contains 4k bytes. du disk usage for UNIX echo, sends output to standard output echo a variable, echo $variable_name egrep, egrep -n "what ever you are looking for belongs in quotes" extended regular expression. See grep env, command shows all environment variables exit, kills a process exit values, similar to exit values from functions or programs: 0 means that the process completed successfullyu, and a non zero value indicates failure. All built in commands issue 1 if it failed. fgrep, fixed string only expression, see grep file, describes file type, syntax: file unix.txt File system, Unix file system. Unix file systems are of three types: Regular files, which contain a sequence of bytes that generally corresponds to code or data. They may be referenced via the standard I/O system calls. Directory files, which are stored on disks in a special format and form the backbone of the file system. They may onlly be referenced via directory specific system calls (cd). Special files, which correspond to peripherels such as printers and disks, or interprocess communication mechanism such as pipes and sockets They may be referenced via the standard I/O system calls. The UNIX file system is a linear sequence of bytes. The lseek() system call proves this, because when you are asking to enter a certain file, you are actually looking to be pointed, by the file pointer only in terms of a byte offset. A disk is split up in two ways: 1, It is sliced up like a pizza into areas called sectors, and further subdivided into concentric rings called tracks. The individual areas bounded by the intersection of sectors and tracks are called blocks, and form the basic unit of disk storage. A typical block holds 4K bytes. A special chip called a disk controller moves the read/write head, which is located on the arm (the arm that learches the disk for information) moves the read/write head in response to instructions from the disk device driver, which is a special piece of software located in the UNIX kernel. A platter is the physical, circular disk. Sometimes there can be several platters to the hard drive. There is only one head per platter. The heads on the arms all move synchronously, like a comb moving through the hair. The collection of tracks in a multi platter hard drive are refered to as cylinders. UNIX uses a structure called an inode (Indes NODE) to store information about each file. The inode of a regular or directory file contains the locations of its disk blocks, and the inode of a specifal file contains information that allows the peripheral to be identified. An inode also holds other information associated with a file, such as its permission flags, owner, group and last modification time. An INODE is a fixed size structure of about 120 bytes. All of the inodes associated with the files on a disk are stored in a special area at the start of the disk called the inode list. INODE contents: *The type of the file: regular, directory, block special, etc *File permissions *The owner and group ids *A hard link count *The last modification and last access time *If its a regular or directory file, the location of the blocks *If its a special file, the major and minor device numbers *If its a symbolic link, the value of the symbolic link. An inode contains all the information that you see when you perform an ls -l, except for the file name. Only the location of the first ten blocks of a file are stored directly in the inode. If a file uses more than ten blocks, a single user block is used to hold the location of up to 1024 blocks. This is called an indirect block. Its location is stored in the inode. This approach allows up to 4 megabytes to be addressed. For files greater than 4 megs, a similar double - indirect scheme is used. The first block on a disk is the boot block, the second block is called the superblock, and it contains information about the disk itself. Following this are blocks that hold inodes. There are 40 inodes per block. After the inode blocks are "normal" blocks for storing files, and contains both directories and user files. The SUPERBLOCK contains information pertaining to the entire file system. It includes a bit map of free blocks. A one indicates that a block is free, and a zero means it is being used. The SUPERBLOCK also contains the following information: *The total number of blocks in the file system *The number of inodes in the inode free list *The free block bitmap *The size of a block in bytes *The number of free blocks *The number of used blocks. See directories for a brief discussion of directories findall, good utility that finds all the instances of what ever you are looking for. findall usr/include/malloc.h locates every instance of malloc.h -n option is not allowed findall fseek >> file.out & flags: -i confirm command ftp, using some good commands, user logs on. Then to move around in your directory type lcd To move around users directory type cd To disable prompt signals, enter "prompt" To get all files, type "mput *" grep, regular expression. get regular expression cat file_name|grep string_you_are_looking_for who|grep bkonner in root directory, looking for location of malloc(): cd ..;cd ..;cd usr/include;grep -n malloc *.* grep -n "what ever you are looking for belongs in quotes" fgrep -xn "()" * options: -n line, -i case of patters is ignored, -x output exactly equals to string., -l option displays a list of files that have option example, grep -n nm makefile hidden files or directories (?), begin file with an underscore history, at command prompt gives history based on what is in your .login file ifconfig: The command ifconfig is used to assign an address to a net- work interface or to configure network interface parameters, or both. Inodes, see file system. IP address represents a 32 bit address. Segments are in four bytes. ls, ls -al directory listings, full listing is ls -al (Glass 31) head, displays n lines of a file. THe default is 10 lines (Glass 33) command is: head unix.txt or head 30 unix.txt kernel, access is by system calls. Example of system calls to the kernel: open a file system call is open close a file system call is close send a signal system call is kill terminate a process exit fork exec kill exit A system call can be thought of as a low level request to the operating system. The Unix kernel acts as a mediator for your programs and your hardware. The UNIX kernel is part of the UNIX operating system that contains the code for: sharing the CPU and RAM between competing processes. process all system calls. handling peripherals. The kernel is the core of the operating system. The kernel facilitates four basic types of services: Creation and management of processes A file system Communication A means to start the system The kernel is a program that is loaded from disk into RAM when the computer is first turned on. It always stays in RAM and runs until the system is turned off. It is written mostly in C, though some parts are written in assembly language.. User programs make use of the kernel via the system call interface. The kernel facilities are divided into several subsystems: memory management process management interprocess communication (IPC) input/output file management In UNIX, files are containers of information that processes read and write. Processes may talk to each other via signals, pipes, and sockets. Talking to the kernel: Processes access kernel facilities via the system call interface, and peripherals (speciqal files) communicate with the kernel via hardware interrupts. System calls and hardware interrupts are the only ways that the outside world can talk to the kernel. Processes >>use system calls to access the kernel>>kernel Peripherals>>use IRQ's or hardware interrups to access the>>kernel There are two modes in UNIX: USER MODE: when a user process is running. KERNEL MODE: Executes any machine instructions. Machine instructins are issued through system calls. The only way for a user to enter kernel mode is to execute a system call. Interrups are the way that hardware devices notify the kernel that they would like some attention. Devices are allocated an interrupt priority based on their relative importance. For example, interrups from the system clock have a higher priority than those from the keyboard. When an interrupt occurs, the current process is suspended and the kernel determines the source of the interrupt. It then examines its interrupt vector table, located in low kernel memory. to find the location of the code that processes the interrupt. The code is ececuted, and then the current process is resumed. Higher priority interrups can interrups lower priority interrupts. Interestingly, if a lower priority interrups occurs, the incoming interrups is ignored and discarde Interrupt handlers are therefore designed to be very fast. kill a job, kill -9 pid #, ie pid # is 10234: kill -9 10234 korn shell, to execute a script, enter ksh hello.ksh. hello.ksh would be the executable and apparently you need to use ksh first. To start the korn shell enter: /bin/ksh Korn shell alias: hw="cd unixchp5" Korn shell double precison integer math functions: use let, ie let r=2,s=3; let y=2*r+s; echo $y last, last -10, $ last -10 wdf lpq, displays the print status of a job, if -p option not specified, then the default option printer is used. -l generages extra information (Glass 42) line numbers, $cat -n file.txt prints out line number before each line ln, soft link: ln -s /courses/cs241/f98/eoneil/bkonner/cs241 cs241 cs241 does not exist in your source directory during soft link another example: ln -s cs241/hw4 hw links hw to cs241/hw4 lprm, cancels print jobs (-p option) (Glass p 42) loops, similar to c, except the end of a loop (and beginning) there are no braces. syntax: for color in red yellow green blue do echo one color is $color done #comment output is below $for.sh one colr is red one color is yellow one color is green one color is blue ls -F lists executables mail, reading from a non mail file, for example, say mail get damaged and you copy from /var/mail/your_user_id DO THE FOLLOWING TO READ: 1, The first line in mail must say FROM: remove any signature file or what ever. ie, I have a signature file that presents the signature first, remove this and anything up to from: 2, To read mail, enter at the prompt: mail -f mail_file_name If the mail was renamed: mail_recovered, then enter: mail -f mail_recovered mail, forward mail. Just create a file named '.forward' (single quotes not included of course). The data in the file just needs to be where the mail is to be forwarded. mail, size of directory in eris: `ls -l /spool/mail/$USER` mail, from the command line: mail bkonner < unix.txt mails unix.txt to me mars print from mars printer to purple printer: lp -d purple Memory, virtual, swapping and paging. Physical memory refers to all the writable memory location in the computer. Virtual memory uses the hard disk and swaps data between the hard disk and physical memory. Virtual memory enables multitasking. Utilizing virtual memory involves paging and swapping. Swapping is done by the kernel. When memory space is running low the kernel looks for a process that is not likely to run in the near future. That process is written entirely to disk, and the newly freed memory is reassinged to another process or job. Messages, posting on eris, send a message to eris.cs.umb.edu using the mail utility Message, call back a previous message, enter at the prompt$ msgs mesg_# Mischief: mtip -l /dev/devicename start typing cntrl/j for carriage return setenv DISPLAY .ncd15c10.cs.umb.edu:0.0 program& mod 28 mod 32= 28 23 mod 22= 1 module, lists information about loaded modules msgs on Eris, command is "msgs number" -n, see line numbers netscape --h gives you help for netscape page down, pine and emacs: cntrl/v page, works like more but clears the screen before displaying each page (Glass 33) passwd, change password utility (Glass 25) path, set your path in .cshrc: set path=( ~$user/bin \ /usr/local/bin \ /usr/ucb \ /bin \ /usr/bin \ /usr/local/gnu/bin \ /usr/local/X11/bin \ /usr/local/hosts \ . \ ) permission modes: - --- --- --- | | | |-------- Other = anyone on the machine can access | | |------------ Group = certain groups can access | |---------------- User = only the owner can access |------------------ Directory Mark chmod og-r unix.txt change group and other read from unix.txt chmod g+x unix.txt change group add execute from unix.txt chmod 777 unix.txt change all groups to rwx chmod 700 unix.txt change other and group to no access. pid, in eris: just ps, kill a job, kill -9 #id number in mars: ps -u userid (gets a list of pids, kill a job, kill -9 #id number pine mail, cntrl -t command allows you to view directory structure and make a file attachment. pipe allows a user to specify that the output of one process is to be used as the input of another (Glass page 11) Example of a pipe: ls -al|sort example of a great pipe: finger bkonner|write>fperi ping -s ip_address #define is a macro or token substition. Replaces the token with a set of instructions. #include is replaced by the contents of what is in the file. #include "filename" searches for a file typically where the source program was found. #include command on Eris, ps -a pwd, print working directory (Glass 28) printing, lpr (In Mars lp) (Glass 41) Printing from eris, laser printer: lp -d lj2 list_legal_move.c also, lpc printer_name process, to kill, enter exit A process is the execution of a program. In UNIX, an execution is called a process. Processes often spawn other processes by using the fork system call. processes, to show all processes, type at the prompt: top prompt, set prompt for time: set prompt %T prompt, set prompt bash shell: PS1="whatever" \u for user \w for location \t for time prompt, set prompt for .cshrc set prompt="%m%/>>>" This shows location within directory as your prompt print, line printer in unix lab, command: mpage -1UH -Plj2 file_name 1UH means one page per piece of paper, 2UH means two pages per one printed page RAM: Static Ram is SRAM rm "xyz" removes specific file rm -i, shell asks user to confirm he wants to delete the file rm: rm -r * removes everything from this directory forward. careful with this command! rmdir "xyz" removes directory (directory must be empty of all files) ruptime, tells you about the host and other information search in emacs cntrl s, enter string setenv TERM vt100 setting the terminal environment for vt100 shell: A shell is a program that is basically an initialization. The shell interprets a line of user input, does what ever it says, and waits for another user input line. Shells terminate when the user types control-D or exit. shell, protects user from operating system (and operating system from user). Most popular Unix shells: Bourne Shell Korn Shell C Shell Bash shell, what shell are you ising? ho $shell (displays shell type) bourne shell, to enter: /bin/sh enter sh to enter Bourne shell see variables for information about bourne shell variables Korn shell, to enter: /bin/ksh c shell, to enter: /bin/csh to exit, type exit, returns to your shell Each shell has its own programming language. THe shell's language is tailored specifically for manipulating files and processes on the Unix system. See chps 3-6 (Glass) To create a new shell, type shell, To exit the new shell type exit. Notice that I have lost my prompt that I am using. When I exit the shell, I return to the directory I was working in. The command to do this is $shell shell, change: chsh Signals are one way that processes communicate with each other and with the kernel. Signals are used to inform processes of unexpected external events such as a time out or forced terminaltion of a process. size of variables on our unix system: short int is 2 bytes int is 4 bytes long int is 4 bytes unsigned int is 4 bytes double is 8 bytes float is 4 bytes (I would have thought this would be larger than a double) char is one byte sleep sleep 20 teminal put to sleep for 20 seconds. Break it with cntrl c. syntax is: sleep(5) puts the terminal a sleep for 5 seconds. sort, used with a pipe, ie, who|sort, provides a sort of users on the Unix system (Glass page 11) source, update .login, .crshrc (source filename) Similar to @login on the Vax. The command is $source .login or $source .cshrc stty: stty -a, stty all, stty everything displays your current terminal settings. Use stty to change terminal settings, ie setting CTRL-C command: %stty intr ^c system calls, UNIX system calls. System calls are the programmer's functional interface to the kernel. They are subbroutines that reside inside the UNIX kernel, and support basis system functions such as: open: open a file code number 1 close: close a file code number 2 read/write: perform I/O socket: create a socket. etc. Every system call is allocated a code number. tail, tail utility is the reverse of head, it displays the last n lines of a file, the default is 10. tail 33 hw.txt displays the last 3 lines of hw.txt. (Glass 34) Tar, to tar a file: tar cf ./jinsen.tar jinsen listing the contents of the file: tar tf jinsen.tar Tar, unzip->tar -xvf filename gzip create a gzip file gunzip unzips it tar and zip verbose means the program will tell you the name as it extracts. tar -xzf (x=extract, z=filter through gzip, f=specify file name) if you include v, it also tells the file name another way, "gunzip -cd filename |tar xvfc -" the first c puts the name in the buffer, the second c puts it into a file. simple remove tar command is: >tar -xf file.tar the f flag must always be last, it stands for file to tar a directory recursively use this command: tar cvf canton /home/bkonner/public_html/cantonhs . You must be in the directory you wish tar. It creates a tar file called canton from the path specified See unzip Tracert, UNIX command is traceroute www.sabena.com tset is a utility that tries to determine your terminal's type (Glass 55) 2comp(N) see bits ulab, reset at ulab prompt$ mresel all Undelete in emacs cntrl/shift/underscore UNIX Anatomy: The Hardware can only converse with the kernel. The Kernel can converse with the hardware and shell. The shell can converse with the operating system, users, utilities, and the kernel, but not hardware. Unix utilities converse with the shell and indirectly with the kernel. Utilities use system calls to request services from the kernel. Unzip, Unix, command> unzip file_name to unzip a file: gunzip -d pine.tar.gz This unzips the pine.tar.gz file and becomes pine.tar variables, (Glass 103+) Variables only work in the shell they were assigned! OR they are in your .cshrc, or proper .file In Bourne shell first enter Bourne shell firstname=Bill lastname=Konnner echo $firstname $lastname (This echos the two variables) Variables work in other shells, ie: tschell `command` Command substitution quotes, single There is a difference between: "`" and "'" the date command requires: "`date`" where as name requires: "$name" set hwdir=~poneil/cs240/hw7 set hwdir="cd ~poneil/cs240/hw7" $hwdir gets you into this directory no spaces allowed between = and ~ set return="cd ~/cs240/hw7" $return returns to original directory to echo the variable type: echo $hwdir to unset a variable, type unset hwdir environment variables: to set, command is setenv These variables are know not only by the shell, but also by programs run in the shell. Displaying variables at the command line enter set or setenv echo a variable, command is $echo variable_name if a variable is undefined, the result will say variable_name: Undefined variable To unset a variable use either unset or unsetenv xv, a viewer to look at jpgs, gifs etc w similar to who command but tells what user is doing wait() suspends a process for the time allotted. whence==location of something, ie whence emacs, result is the location of emacs in Unix. who, or who r list of users on system (glass page 11) whois ? gives you information on what the parameter is ie, whois canton lists know canton addresses wildcards *.*, rm *.c removes all c files write user_name This command allows you to send messages on our Unix system to other users directly to the screen. Mars does not support this I have been told. mesg N turns off message mesg Y turns on message write between nodes mars:: DONE UNIX.TXT