.Open Computer Science FAQs . What is a FAQ A FAQ (pronounced FACK) is a Frequently Asked Question. They are gathered together into a file and published so that people can look up the answers. The were invented in the early days of the Internet Usenet Newsgroups. . What Hardware or Software should I buy None! All the work in our courses are designed to be done on the CS Department's UNIX systems. You might think about a very cheap PC or Macintosh with a good Internet access as a way to keep in contact with the campus. . What Machines can I use We have specially set up workstations in the 3rd floor of the Jack Brown Hall. Each lab has tables set up for laptops and the labs are on the Campus WiFi Network. The labs are open 9am-10pm except when there is a class in them. The free times are listed on the door of the lab. .Open Can I lose my account Yes. Access to our machines is a privilege not a right. Our goal is to make sure that they can be used for learning about computers and computer science. We will close down or restrict an account that becomes a security risk or causes trouble to the other users of the systems. You can lose access privileges by harassing people (face to face or electronically), breaking any laws, or by hogging resources like disk space, network bandwidth, or CPU time. For example, if you transmit vast quantities of data to everybody on the net we will be forced to do something about it. Our guideline is that you are in trouble when another user (student, faculty, staff,...) has a problem with what you are doing. Be Secure. People using your account can pretend to be you and make your account unusable: * Keep your password a secret. Brothers and sisters have caused a lot of trouble to some of our users. * Never give your password over the phone, send it by EMAIL, or into an unchecked web site. Nobody in this department will ever ask for your password or give you a password over the telephone or EMAIL. * Use the GUI password tool or the 'passwd' command to change your password regularly: .As_is passwd your_user_id .As_is Old Password: .As_is New Password: .As_is New Password: Passwords are input invisibly. * Make your password unguessable. Any English word or name is easily guessed! Include digits and symbols. * Log out before you leave. Beware Internet scams. Don't send money or personal info to people you don't know. Put time to good use. We give you access to these systems so that you can learn from them. If you find that you spend more time chatting to people or downloading graphics and sounds than learning things - start to restrict the wasted time. Don't wait until you get bad grades! Don't remove data you might want later! UNIX is a shared system so it recycles disk space as fast as it can. Once you remove a file(using the `rm` command) the space is reused and the data is lost. We do make backup copies of data at night but this is only for emergencies. .Close . How do I start If you are not in a lab in JBH see .See What Machines can I use above or .See Can I use my PC at home and .See How do I use a different machine below. The screen may be blank. If there is a mouse - move it. Otherwise tap the return key. If this fails look for the on/off switch for the monitor and make sure it is ON. A "login:" window should appear - input your own login name. This is your personal identifier and is made up of your initials and part of your family name. Click the OK button and you'll be invited to input your password. Input your Password and click the Login button. . How do I finish Make sure that you .Box 1. logout from UNIX (CTRL/D or exit) or exit from XWindows via a menu or on screen button. You can turn the screen off. 2. if you dialed in, logout/exit(CTRL/D) from from the dial-in system and close your ssh window... .Close.Box .Open My lab computer stopped - What do I do Take a deep breath and relax. Do other people have the same problem? Look at your screen - what was the last thing that happened on it? Think - what was the last thing you did? Take note of the symptoms and if you don't know what to do, go and find help. .Close . Can I use my PC at home Yes. The most convenient way for small amount of work is to use a modem to dial-in to an Internet Service Provider --(ISP) and use the secure shell application program ($ssh) to write programs etc. The $ssh is the "Secure Shell", and it lets you sed commands to a UNIX computer throught the internet -- securely. The the free Windows SSH client is at: .See http://ftp.ssh.com/pub/ssh/ , and download the latest SSHWinClient-3.x.x.exe file. The host name is .As_is jbh3-1.csci.csusb.edu to get into our network (all other machines are hidden from the Internet). To login to a lab machine type this command in your JBH3-1 terminal window: .As_is ssh jb358-22 to use machine number 22 in room JBH358. You can also use `ssh` to send files from one machine to another. It has a very nice user interface. . How do I access the Zip Drive/CD-ROM drive Look for icons on GUI desktop... Note: remote machines can't read your hardware thru the `ssh` program -- not a secure feature. . How do I access my Flash drive Insert the drive and its icon should appear on the desktop. Double click to open and Right click for a menu of other things you might need to do. To finish use the right-click menu to "Safely Remove". . What are these Ms in my DOS file Sometimes you will see some funny characters in a file that came from a Microsoft computer: ^M and ^Z are special ASCII codes that the MS-DOS system needs. On many of our machines they can be removed by running a command like this: .As_is dos2unix UNIXfile (in 'vi' you can also type in this magic incantation .As_is :g/^V^M/s/// where ^V means "hold down the CTRL key and tap V, and ^M is CTRL/M ) You can put in the special DOS characters like this: .As_is unix2dos >UNIXfile new_file_name Then tell your ssh to Edit->Paste the text copied from a window on you machine. Warning: the CTRL/V short cut doesn't work! To get your own copy, at home, of a file called filename, the command .As_is cat filename displays the file in the terminal and you can copy/paste the content into the application where you need it. The above techniques do not work with binary files. . Can I avoid Learning UNIX If you aren't a CSci major, you may be able to avoid UNIX for the rest of your career. Meanwhile you can use the KDE Graphical User Interface when you are in the labs. Remotely, there is a program that lets you do simple things using a menu. Its called 'umenu'. Dr. Botting and a team of students wrote it to do most of the CSci201 things: .As_is umenu This is a command on our system that gives you a menu of things you might want to do. Try it, if anything is wrong with it let Dr. Botting know. . Can I run my own UNIX at home Yes. But please take CS360 and CS365 first! . Can I copy/change/port our software The source code for Gnu compilers(gcc or g++), our LISP, our Prolog, and our Smalltalk are programs can be copied legally for your own use. You may make copies of some of the software we have written ourselves or obtained from the Internet as Freeware. You should not sell these. Don't let people copy them without making sure that they will not sell them as well. . How do I get on the Internet You are on it the moment you login or dial in! All CS UNIX machines can access the Internet. . How are machines identified Each machine (a.k.a. node) is given a unique Internet Protocol (IP) number and also a unique name. The number is a sequence of four numbers( for example: 139.182.38.10). The first two numbers(139.182) are shared by all the machines at CSUSB. One or two special machines keep track of all the names and numbers and are called the 'name servers'. They forms our Domain Name Service ($DNS). If they don't recognize the name they pass the problem to the CSUSB $DNS, and so on up. Notice that if a number is not in the $DNS data base the machine can not work on the Internet. If the number duplicates another machine's number than both machines can have problems. In a worse case scenario (and this happened) the whole campus network starts to misbehave. An Internet name starts with the machine's local name and then a list of sub-domains and domains. For example 'jb359-11.csci.csusb.edu' was a machine called `jb359-11`, on the Comp. Sci. part(csci) of the CSU San Bernardino domain(csusb) of the EDUcational domain of the Internet(edu). Our name servers(whisper, echo,coyote,...) convert the name into the Internet number '139.182.38.10' for us. . What is my account An account gives you access to machines, an on line identity, and on line data storage. The information about accounts is shared by the Network Information Service (NIS or yp) servers. Accounts are named by a `user-id`. A User Id(public) and Password(secret) lets you log in at any of our workstations and dial-in servers. You get access to similar operating systems (UNIXen) and files. You get a home directory to be hold your files. You will find your mail waiting for you on any machine as well as if it had been delivered there. In some classes your account can be given a special public directory on our World Wide Web Server. . Are my files on all machines in this lab Yes! The Networked File System($NFS) lets us keep your files on a server and export them to all machines in one lab. . Is my password the same on all the machines Yes! The $NIS or Yellow Pages(yp) Servers distribute the account names, passwords, etc. to all systems on the computer science network that needs them. We use 'passwd' to change passwords. Do this as often as you can! . How do I use a different machine Use `ssh` to login because it encrypts your password and other information. To get to a machine called `node` with login name `user_name` try this command: .As_is ssh node -l user_name If `ssh` says that you've not used a machine before and you typed the `node` correctly, answer "yes" (not just "y"!). . What does xyz://wiz.bang.nuts/dir/file.type mean This is a Universal Resource Locator or URL. It tells you and certain programs where and how to find something on the Internet. The first part 'xyz:' identifies how to do it - the protocol: FTP, mailto, news, file,...,http. The next part: '//wiz.bang.nuts' defines which machine to contact. It will be the machine called "wiz" in the "bang.nuts" domain. The last part of the URL looks like this: '/dir/file.type' and indicates where the resource is on the machine. The last part of the file name '.type' indicates the type of data in the file. .Open How do I ... . stop a running program You end a file of data for most C/C++ programs with CTRL/D. This includes inputting a message into `mail`! You can kill most programs by sending a CTRL/C and waiting a while. You can also make a running program suspend and restart it later. Holding down CTRL and tapping the Z suspends the running program and you can then type in commands. The command .As_is fg (foreground) restarts it. .As_is bg lets it continue in the background. . run a command in the background Type an '&' at the end of the command. The command 'jobs' lists your running jobs. The 'kill' command is used to stop jobs in the background. . stop pico/mail/vi/... You quit pico by following the menus. To quit Emacs tap CTRL/X and then CTRL/C. To quit vi , try Esc(CTRL/[) and then ":q!" and tap Enter/Return. To save your work use: ":qw" and tap Enter/Return. . make a new file Input the command .As_is cat >new_file_name then feed it your data (type it, upload it, or paste it). Then tap CTRL/D. If you use an old file name, it is overwritten. A smart programmer keeps a skeleton file for new projects and starts a new one by copying it: .As_is cp project.cpp new_project.cpp . output a file To output a file to your screen use: .As_is cat file_name To look inside a large file: .As_is more file_name A text file is printed to a printer like this .As_is a2ps filename | lpr . find details on a file .As_is ls -l file_name .As_is file file_name . list a directory .As_is ls .As_is ls directory_name . edit a file Every body has a favorite editor. In KDE and other GUIs there are three or four editors and word processors that work well. For beginners using command lines the Pico editor seems to work well: .As_is pico file_name This lists the available commands at the foot of the screen. For power users either `vi` or `emacs` editor seems to work well: .As_is vi file_name .As_is emacs file_name . delete a file To permanently and instantly destroy a file and its contents is as easy as: .As_is rm file_name This is safer: .As_is rm -i file_name To empty a file, use: .As_is cat /dev/null >file_name . do a quick test run of some code We have some simple software that makes it easy to test simple programs. My command .As_is ~dick/bin/Q file chooses the right compiler etc. for you. The program that selects the correct operation is called 'quickie' or 'Q'. If you have a "Makefile" then `Q` searches for 'program' and if it is a target then 'make' is invoked. Given a file name with no known suffix, `Q` can run an interpreter determined by the first line in the file. `Q` is a script that describes how to interpret many different kinds of file. For ed/ex a shell escape `!Q file_name` is used. Similarly for EMACS. `Q` can also be invoked directly at any shell prompt: `$ Q file_name`. . set up a hotkey for Q For 'vi' its easy: Type the command 'Q setup'. A single keystroke('q') is mapped into commands that save the current version of the program, suspend the editor ('vi'), and run the correct interpreter or compiler for the program being worked on. Afterward tap the return key to restart 'vi' as it was before the test run. . learn to be a UNIX power user? Go to one of the CSci Club workshops. Then take CS360. . avoid core dump files To disable the creation of core dumps in ksh and bash, add this line in your .profile and .bash_profile: .As_is ulimit -c 0 If you are using csh or tcsh, put in .cshrc this line .As_is limit coredumpsize 0 If you don't do this you can clean out all existing 'core' files by typing in this command: .As_is find $HOME -type f -name core -exec rm -i '{}' \; .Close How do I ... . What does RTFM mean It means "Read The Famous Manuals". Sadly we don't have .As_is man -k keyword .As_is apropos keyword and have to use the Linux Web based "help" pages. . What do I name files You can use up to 32 characters to name files and there are few limitations on what these characters are. You can not use '/' since this indicates a directory. It is difficult however to use some characters like spaces, $*\?"'`^&(){}; in a file name. However letters, digits, and +-_,. are common. In UNIX either the suffix or first line can determine the language or code used in the file. A file without a suffix is a Bourne shell script if the first line starts with a ':'. If the first line starts with '#! interpreter' then 'interpreter' is used. The interpreter name should be an absolute path name starting with '/'. Programs are put in files with a particular suffix ("extension") at the end of the name. Some are as shown below .Table Language Typical file name Which Machines? .Row C program.c all .Row C++ program.cpp most .Row HTML file.html all -- lynx, lincs,... .Row Java program.java most .Row LISP program.lsp most .Row Pascal program.p none .Row Prolog program.plg most .Row ASCII Text file.txt all .Row MS Word file.doc Try JB360 or OpenOffice .Row Compressed file.type.gz all -- use gunzip .Row " file.Z all - use compress .Row " file.zip all -- use gunzip .Row PostScript file.ps Print or use "ghostScript" .Row Archive file.tar all -- use tar .Row Graphics file.gif most -- use xv, the Gimp, etc .Close.Table To find out more about the languages above take CS320! . Do we have a list of UNIX commands The CS360 class there is a list of typical UNIX commands: .See http://www.csci.csusb.edu/dick/cs360/notes/commands.html There are too many commands for a complete list. You can also add new commands. Indeed if you compile a program you produce a new command! UNIX commands include all the executable files found in a string of directories including: .As_is bin /bin /usr/bin /usr/local/bin /usr/bsd /usr/ucb /usr/bin/X /share/bin Here is a quick list of ones that you'll use most. To master UNIX take CS360. .Set Files .As_is file(guess content), mv(move/rename), .As_is rm(remove), cat(output conCATenated files), .As_is cp(copy), chmod(change mode),... Directories .As_is ls(list), cd(change directory), mkdir(make), .As_is rmdir(remove directory), mv(move/rename directory) Editors .As_is pico,vi,emacs, ex, ed,... Find Out About Users .As_is who, finger, w, top, write, talk,... Mailers .As_is mail, pine,elm, ... Compilers .As_is gcc,g++, javac... Networking .As_is ping(test if alive), ssh, scp, ... WWW .As_is lynx, lincs, netscape, Konqueror Searches .As_is grep, fgrep, egrep, find, ... Interpreters .As_is sed, awk, perl, java, sh, ... .Close.Set . Do we have any more FAQ Yes - lots. .See ./index.html . How do I chat with other users If they are on the same machine type in one of these commands: .As_is write user_name If someone writes or talks to you, respond by a similar command at your terminal. If you don't want to be talked to: .As_is mesg n stops people writing/talking to you. When you use 'write' type short lines. Type .As_is o for 'over' and wait for a reply. Type CTRL/D to sign off/hangup. . Can I run a graphics program remotely If either machine does not run UNIX, and you aren't using Java or a Web Browser to control your window then you can't. With UNIX on both machines it can be done. UNIX includes the `XWindows` system. It was designed (at least 20 years ago) to allow windows to be sent across the Internet. On our UNIX workstations we run `XWindows`. First your `local` machine must let the other `remote` machine use your display. To do this, on `your` machine, run the 'xhost' command for the machine you want to access .As_is xhost name_of_remote_machine The remote machine needs to know two things about your "local" machine: the type of terminal you are using and how to find it on the Internet. An Xterminal has type .As_is xterm so input this command at the command prompt on the `remote` machine .As_is export TERM=xterm Finally tell the remote `node` where you want things displayed: .As_is export DISPLAY=your_machine_name:0 It tells the other machine to send windows and graphics to your machine. .Open Do you have any Advice for Project Work . Compiling and running projects .Key Compiling project code can be done by hand in a terminal window as shown in the classes or using the techniques demonstrated in the labs. Avoid using any software that costs you money. In a terminal window .Box Simple programs can be compiled run and tested with a single command on our computers: .As_is Q p1.cpp if the code is in file `p1.cpp` in your current working directory. On other systems you may have to do the steps in 'Q' by hand: .As_is g++ -o p1 p1.cpp will compile it and .As_is ./p1 will run it. You can repeat the last compilation by typing .As_is !g++ into a terminal or use the arrow keys. Or, for more complex projects with code in many files, you can create a .Key Makefile by using any UNIX editor that contains lines like this .As_is test: p1 .As_is ./p1 .As_is p1 : p1.cpp .As_is g++ -o p1 p1.cpp (be careful to use the key to indent the commands. .Close.Box Then the command .As_is make test will update `p1` and then execute it for you. . Warning -- Do It Yourself You can ask the teachers for help. Anything that looks like another student's work or a file downloaded from the Internet is likely to get a score of zero (0) for plagiarism. We have several tools that spot files copied from the Internet. Each project is matched with an examination. In the examination you will have to answer questions about your latest project. Recently, in CS201, someone desperately downloaded code from the internet that sounded like it might solve the problem. It didn't. It got zero. Again, in a recent Comp. Sci. course, one student got some code from his brother at another university and then let six friends copy it and make small changes. Six students handed in six variations of the code. It was a solution to a different problem. They all got zero. . University Policy on Plagiarism Please read page 51-52 of the catalog. . Do's and Don't's for Projects. .List Put your name and the project description as a comment in the code. Download this file .See ./project.cpp as the starting point for a project. Do the simplest thing that can possibly work. Look out and take note of any productivity and quality tips I mention in class. Put most of the documentation as comments in the code. Explain how a user uses the program -- what do they do and what do the get out of it. For complicated steps: write an algorithm (as a comment) first and then code it. Use variable and function names that say what their purpose is. Check out the links under $Style above. No spelling errors in variable names, outputs, or comments. The command `ispell filename.cpp` will help. When you get to .Key functions: use .See ./function.cpp as an outline with comments defining the function. When you get to .Key classes: use .See ./class.cpp as a model and outline. .Close.List .Key THINK. If you rush into code and patch it until it works you may score less than someone who takes time to think about the problem and possible solutions before writing the code. You can make notes using an editor. Start with: What are inputs and outputs? and/or the givens and goals? and/or the before and after conditions? How are these connected? Make notes on this analysis of the problem. What are some possible ways of solving it (designs or algorithms)? Choose one. Turn your notes into comments at the top of a program. .Key Make it Meaningful. It is up to you to use meaningful identifiers and comments that make it clear why the code is going to work. Don't hand in a separate algorithm or structure chart. Instead your file should include comments that show the design. A function definition should start with a comment saying (1) what it assumes and needs, (2) what it produces or guarantees, plus (3) a very brief algorithm. Make it clear and correct before you make it fast. Check all code before I grade it. If you have a bug: Add comments about the symptoms... remove the comments when fixed. If I find uncommented errors you will loose points. If I find things that I can't understand then you will also loose points. Most .Key Errors occur when people (1) .Key misunderstand the problem, (2) think of .Key efficiency before correctness. Real problems are not obvious and are not clearly specified. The descriptions of the programs in the book are like this. There are several different programs that will fit what the book asks you to do. I leave the interpretation of them to you yet: (1) K.I.S.S. (= Keep It Simple!). (2) Demonstrate the features and topics described in the book and course at that time. (3) If in doubt A.S.K. (= Always Seek Knowledge). (4) Document (in comments) how you interpret the problem(Analysis) . Always Seek Knowledge (ASK) I expect you to come and talk to me or other teachers about projects. You should be careful about talking to other students, however. They do not know enough to give you good advice. Also beware searching the Internet -- you'll probably find a solution to a differnt problem. . Document It As You Go Real problems don't have obvious solutions. Whether you know what the code will look like or not add a comment that says what the program must do -- you can copy the description in the book. This may give you an idea. If not think up a special case that you can see how to solve. Use comments to describe the special case and how it case is solved. Make it compile! Add a simple output to see if the algorithm will work -- nothing else. It will probably have errors. This is normal. Declare variables and recompile and test. Add initial values. Test until it runs. Add comments describing an algorithm. Write code implementing the algorithm. Test. . Divide and conquer Develop code in small iterations. Tackle one complication at a time. Test and retest. Rerun the previous tests. . Don't let the sun rise on bad code! When the current version passes all tests, look for ways to re-factor code. For example use the .Key DRY ( Don't Repeat Yourself ) rule to spot code that can be put in a loop or functions, etc. . Stop! Stop before you are about to run out of time or when it does every thing that the book asked for. . How to Fail a Programming Assignment Carol Edmondson at the University of Tasmania has documented the following techniques students have used to fail her courses: .List Don't submit the assigned work. Submit the work late. Submit the same document as your friend. Submit something you found on the web. Use Email/News/etc to invite someone else to do the work for you. Collect random pieces of code and put them in a file. Submit a program that doesn't compile without comment. Submit a program that produces a run-time error without comment. Submit a program that only works on the given tests. Submit a program that does not meet the specification without comment. .Close.List Any of the above can loose you points. .Close . Working at home with SSH access You can work at home but do not spend money on a C++ system. (1) We require work to be work with the free and standard Gnu C++ system. (2) The expensive stuff adds complications to your code for no added value. The department and the Computer Science Club can provide you with software if you ask. You can access our system by using the same system that I have in the class room and office. This is the free Windows SSH client at: .See http://ftp.ssh.com/pub/ssh/ Download and install the latest SSHWinClient-3.x.x.exe file. Connect it to .As_is jbh3-1.csci.csusb.edu and log in. You then will need to login to a lab computer like this .As_is ssh jb358-10 (you can use any of these machines from JBH3-1). You won't be able to do graphic programs or use KDE to make things easier. A key rule: .Box Tap Enter to end each command! .Close.Box The following UNIX commands work well: .Table Command Purpose .Row cat >f Upload or input a file called f. You can type in the code or copy/paste it from your machine. End with Enter and Control/D .Row cat f List the file f on your screen. .Row g++ -o p p.cpp Compile a program called p .Row ./p Execute/run a program called p in this directory(.) .Row make t Follow a recipe in `Makefile` to make t .Row cd d change working directory(folder) to d .Row pwd Print working directory .Row ls List the file names in this directory .Row file * List the files .Row mkdir d Make a directory called d .Row more f Display a file f one screen at a time .Row rm f Remove a file (dangerous....) .Row mv f n Change f's name to n, or move it to a directory .Row cp f n Copy f to file n .Row pico f Edit a file called f (easy to use but not powerful) .Row vi f Edit a file called f (powerful but not easy to use) .Row emacs f Edit a file called f (powerful and I can't use it) .Row lynx u View a web page with URL u while on JBH3-1. .Row links u View a web page with URL u. .Close.Table . Who can help me Your teacher or lab assistant is the first person to talk to. In the evening and on the weekends an experienced student may be on duty to provide emergency help. Any faculty member with an open door will be interested in a program that isn't working properly -- just bring them a print out of the code and the last test/compilation. Kwon Soo Han(kwhan) and Nam Kim keeps our systems running. . Where can I make suggestions Here .Hole .Close Computer Science FAQs . Glossary In the following I use the the Backus-Naur-Form of definition: .As_is term ::= meaning. By using this form I can easily link terms to their definitions... click on a link to see what it means, and then click the Back button on your browser... ASCII::="American Standard Code for Information Interchange", an way of coding characters (letters, digites, signs) in 8 bits. DNS::= Domain Name Service -- provides the unique $IP address given a machine's name. FAQ::="Frequently Asked Question", or "Frequently Answered Question". ftp::=a file transfer $program and file transfer $protocol, internet::=any collection of one or more $LANs that communicate using the $IP (internet protocols). IP::$protocols=telnet + ftp + rlogin + $SMTP + other $protocols. LANs::=Local Area Networks. NFS::=A system that allows a disk to be physically attached to one machine yet work as if it was attached to a different one. NIS::=Network Information Service -- allows a collection of machines to share common databases like the $passwd file. passwd::=A file on UNIX systems that lists all users and their number+home directory+login shell etc. POP::=Post Office Protocol -- lets one machine (a client) request incoming mail from another machine(a server). program::=a set of instructions that has a name such that inputting the name makes a computer execute the instructions. protocol::=a set of rules defining how something has to be done involving at least two communicating systems and/or people. protocols::=plural of $protocol. server::=any computer that provides a named service to other computers. SMTP::=Simple Mail Transfer Protocol -- how to transmit Email from machine to machine. ssh::program="Secure Shell", A way of controling and aceesing a UNIX computer remotely and securely. The free Windows SSH client is at: .See http://ftp.ssh.com/pub/ssh/ , and download the latest SSHWinClient-3.x.x.exe file. TBA::="To Be Announced". TBD::="To Be Done". TCP::=Transaction Control Protocol -- a set of rules for communicating across a local area network. TCP/IP ::= The basis of an internet: combine $TCP with $IP. UNIX::=a popular operating system for professional developers of software because it runs on all kinds of computers and gives a lot of power to expert users.