Basic Unix (linux) ========== You need very few commands to compile and run your C++ programs. Develop your C++ program using whatever application you choose. Completely write, debug, and test all your code. Don't use any fancy I/O, use simple >> and <<. When your program is completely done, and you're ready to turn it in, make sure it compiles under unix using the g++ compiler which is where the linux machines in UW1-320 come in. Execute it too, because using a machine that you don't own, that you're not the administrator for, can help find bugs. On your machine at home, you can write over most memory because it's yours. Under unix, if you try to write to some memory that isn't yours (a bug you don't know you have), your program will probably crash. It's always better for you to find bugs than to have me find them! Crashing under unix/linux ------------------------- If you try to access memory that isn't yours, or you have some garbage address you're trying to access, a bad pointer, the error you get is "Segmentation fault" To solve this, it will take some serious debugging. Draw pictures. Use couts to isolate the problem. To do some simple editing on linus, you can use the pico editor, e.g., pico lab1.cpp There's a menu of simple commands at the bottom of the screen. In pico, Ctrl+c tells you the line number. Infinite loop ------------- To terminate any process under unix, enter Ctrl+c (e.g., you find your program is in an infinite loop). Basic unix commands ------------------- So here are the minimal unix commands you may need. Enter these at the prompt. >list your files: ls >compiles and links all .cpp files (list as many .cpp files as you >have for your program) then creates an executable called a.out: g++ -std=c++11 file1.cpp file2.cpp >execute your program: ./a.out >remove/delete a file, say file1.cpp: rm file1.cpp >copy file1.cpp and name it file2.cpp: cp file1.cpp file2.cpp >move (rename) a file, say file1.cpp to file2.cpp: mv file1.cpp file2.cpp >make a directory (like a folder), say Lab1 mkdir Lab1 >change to a directory, say Lab1 cd Lab1 >change back one directory up cd .. >change back to your home directory from anywhere cd >view a file, say file1.cpp, at the screen, one screen at a time: more file1.cpp ("space" for next screen, "enter" for next line, "q" to quit viewing) >log out of your account: logout