| To compile and run your codes in Dijkstra machine you must be connected to it (see how to do it). Dijkstra machine is operated by Linux, so if you want to learn some basic Linux commands, just check the following part (Basic Linux Commands). | ||
| Before compiling your codes make sure you are in the directory that keeps your codes. To get there you can use cd command. Here is an example: | ||
| cd cs201_spring13/codes | ||
| In that directory suppose you have a cpp file example.cpp. You may want to produce object file in Linux environment using | ||
| g++ -c example.cpp | ||
| -c option produces object files and you will have example.o file. Executable file is produced using | ||
| g++ -o executable example.o | ||
| -o option produces the executable file named as executable. Running your own software is as easy as | ||
| ./executable | ||
| Simply you can compile .cpp files directly (without producing object files) and run using | ||
| g++ example.cpp | ||
| It will create an executable file named “a.out”, and you can run it as : | ||
| ./a.out | ||
| To compile all .cpp files (e.g. GradeBook.cpp, main.cpp, and GradeBook.h just like in the Recitation 1), simply use the following command (no need to do for .h files) | ||
| g++ *.cpp -o GradeBook.out | ||
| It will create an executable file named "GradeBook.out", and you can run it as : | ||
| ./GradeBook.out | ||
| ls | ||
| ls (list) lists all files and directories in your current directory. | ||
| Sample usage: | ls –al (list all the files including hidden ones and list their properties) |
|
| cd | ||
| cd (change directory) allows you to move into and out of directories, much like double-clicking on folders on your PC. | ||
| Sample usage: | cd subdirectory (move into the folder subdirectory) |
|
cd .. (move one folder above in the directory listing) |
||
| mkdir | ||
| mkdir (make directory) lets you create new directories (folders) on your current directory | ||
| Sample usage: | mkdir new_directory_name |
|
| cp | ||
| cp (copy) command allows you to copy files to new files, or copy files and directories to new directories | ||
| Sample usage: | cp index.html index2.html (copy index.html file as index2.html) |
|
cp index.html \public (copy index.html file to public directory) |
||
| rm | ||
| rm (remove) is the Linux command to delete files and, sometimes, directories. It's short for "remove". Be very careful when deleting stuff with this command, as Linux usually has no recycle bin - once you've deleted something, it's gone forever! | ||
| Sample usage: | rm index.html (remove the file index.html) |
|
| more | ||
| The more command is a quick and easy way to view the contents of a text file on your server. Press the Enter key to scroll through one line at a time, or the Space bar to scroll one page at a time. To terminate action, press the key q. | ||
| man | ||
| man (manual) is the help system for Linux servers. | ||
| Sample usage: | man ls (show help file for ls command) |
|
| chmod, pwd, mv, rmdir, … | ||
You may want to check these commands out on your favorite search engine or just use man command. Two files (linux-commands.pdf, linux-commands2.pdf) are available at here and here. |
||
Thanks to Akif Burak Tosun who prepared the original content.