Unix Essentials

Compiling C programs on Unix.

First login to the CSL Unix server as described in the Submitting your work tutorial.

The commands below may be entered exactly as shown in bold text.

cd Documents
Change to a subdirectory named "Documents"

nano hello.c

Launch the "nano" text editor to create (or modify) a file named "hello.c"

gcc -Wall -ansi -pedantic hello.c
Compile the program, producing an executable file named "a.out."

./a.out
Run the executable file.

cp -i a.out hello.exe
Make a copy of the executable with a new name "hello.exe"

./hello.exe
Run the new executable file.

ls -l
Show the names and permissions of files in the current directory.

rm -i a.out
Remove the executable file "a.out".

cp -i ~graderjd/Public/hello.c $HOME
Copy a file from the grader account into your account's home directory.


Essential Commands Reference

(Italicized words should be replaced with a name of your choosing.)

gcc -lm -Wall -ansi -pedantic filename.c
Compile filename.c and include the math libraries.

ls
Show the names of files in the current directory.

ls -l
Show the names and permissions of files in the current directory.

cat filename
Show the contents of a file.

more filename
Show the contents of a file, a page at a time.

mkdir newfolder
Make a new directory.

cd directory
Change to a subdirectory.

cd ..
Change to the parent of a subdirectory.

cd

Change to your home directory

cp -i existingfile newfile
Copy a file.

mv -i existingfile desiredlocation
Move a file to a different location, or rename a file.

Learn more: