1 Precept I : Lab Environment, Unix, Bash, Emacs
2 Lab Environment (Linux)Lab machines are administered by TA IP address range (12 machines) ~ Use SSH protocol to communicate with the lab machine PuTTY (Windows) Terminal (Mac OS) ID Your student number Password
3 Cygwin Provide Linux-like environment in Windows Install Cygwin Install Cygwin Download & run setup.exe Choose any URL to download files
4 VMware Player Run another OS (Linux, Windows, etc.) on top of main OShttps://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0 Install VMware Download VMware Player for Windows 32-bit and 64-bit Run downloaded file
5 VMware Player Download Linux (Ubuntu) image file Install Linux on VMware Click on “Create a New Virtual Machine” Click on “Browse…” button Add image file downloaded from website Insert information : username, password, etc. Press “Play virtual machine” button
6 Accessing from Outside KAISTRequire virtual private network (VPN) program At first run, use Internet Explorer! kvpn.kaist.ac.kr Log in Press Start
7 Change Password on All Machines!Connect to the machine with default ID & PASSWORD Type “passwd” In response to “(current) UNIX password:”, type current password In response to “New password:”, type new password. In response to “Retype new password:”, type new password again. Reminder Each machine does not share files It is your responsibility to back up your files Keep the code locally Use the lab machines only for testing and debugging
8 Unix and Bash
9 Bash Commands For details, read the handout Most useful commandsDescription man
10 Emacs Popular editor Already installed in lab machinesIntegrated with GCC compiler driver & GDB debugger Already installed in lab machines emacs test.c
11 Emacs Hotkey Hotkey Description Ctrl-k cut line Ctrl/alt-wcut/copy region Ctrl-y paste copied/cut region Ctrl-x Ctrl-s save file Ctrl-s/r
12 gcc209 –E hello.c > hello.iBuilding C Programs hello.c Source code C language Contains preprocessor directives hello.i Contains declaration of printf() Missing definition of printf() #include
13 Building C Programs hello.s Source code Assembly languageMissing definition of printf() Compile gcc209 –S hello.i C Compiler .section .rodata cGreeting: .asciz “hello, world\n” .section .text .global main .type main: puchl %ebp movl %esp, %ebp pushl %cGreeting call printf addl $4, $esp movl $0, %eax movl %ebp, %esp popl %ebp ret
14 Building C Programs hello.o hello Object code Machine languageMissing definition of printf() hello Assemble gcc209 –c hello.s Assembler … … Link gcc209 hello.o –lc -o hello Linker … gcc209 is an abbreviation for gcc –Wall –ansi –pedantic –m32 –march=i386 Shortcut: gcc209 hello.c –o hello