시스템프로그래밍 Lecture3,4 Using VI, Running a C program
*지*
다운로드
장바구니
소개글
수정할 곳 없는 정말 완벽한 보고서입니다.보고서 쓰시는데 도움이 되었으면 좋겠습니다.
목차
Lecture3 : Using VI1) Make a file with vi.
2) Start insertion with ‘i’ key and type following.
3) Return to command mode with ‘esc’. Save and exit with ‘:wq’
4) Reopen the file
5) Use ‘j’, ‘k’, ‘h’, ‘l’ to move the cursor around. Do not use arrows. Move the cursor to the word “first”. Use ‘x’ key to delete the word “first”. The result should be as follows.
6) Insert “third” as follows.
7) Add a new line as follows. Use ‘o’ key.
8) Change the beginning as follows. Use ‘x’ and ‘i’ key.
9) Add more at the end. Use ‘a’ key.
10) Delete the last line. Use ‘dd’.
11) Add few more lines. Use ‘o’.
12) Change the last line.
13) Copy and paste as follows. Use ‘2yy’ to copy two lines at the current cursor; move the cursor to another location and use ‘p’ to paste them at that location.
14) Go to line 6 with ‘:6’ and make change as follows.
15) Type following program.
Lecture4 : Running a C program
1) Login to the system. Show the current directory. Move to your own directory. Show what files are in your directory.
2) Go to “/etc” directory. What option can you use with “ls” command to distinguish directory files from the regular files? "file *" will show the information for all files in the current directory. Combine "file *" and "grep" using the pipe symbol(|) to display information only for text files.
3) Find the location of the password file (“passwd”), the location of C header files such as "stdio.h", and the location of utility programs (or Linux commands) such as “ls”. Use "find" or "locate" command.
4) Go to your home directory and cd to your own directory.
Make ex1.c using vi. Compile it and run.
5) Display the contents of ex1.c using cat, more, and xxd. With xxd, you can see the binary data for each character in ex1.c. Show the binary data for “void”.
6) How can you display the contents of ex1 (the executable file)?
7) Copy ex1.c to ex2.c, ex3.c, and ex4.c. Remove ex2.c. Rename ex3.c to y.c.
8) Make a sub directory. Copy y.c in this sub directory.
본문내용
$ ls –F : ls 명령어에 –F라는 option을 주어 directory file은 파일명 뒤에 /, 링크파일은 @, 실행파일은 *, FIFO 파일은 |, 일반파일은 아무것도 없도록 하여 표시하였다.$ cd 12091637 → cd 명령어를 이용하여 12091637 directory로 이동한다.
$ vi ex1.c 명령어로 ex1.c라는 c 코드 파일을 vi 편집기를 이용하여 만든다.
:wq를 입력하여 ex1.c를 저장시킨 후 빠져나온다.
$ gcc –o ex1 ex1.c 명령어를 이용하여 ex1.c를 컴파일 할 수 있다.
$ ./ex1 명령어를 이용하여 ex1.c가 실행됨을 알 수 있다.
$ cat ex1.c → cat 명령어를 사용하여 ex1.c의 내용을 확인할 수 있다.
$ more. ex1.c → more 명령어를 사용하여 ex1.c의 내용을 페이지 단위로 확인할 수 있다.
$ xxd ex1.c → xxd 명령어를 사용하여 ex1.c의 내용을 16진법으로 표시한다.
<중 략>
$ cp ex1.c ex2.c
$ cp ex1.c ex3.c
$ cp ex1.c ex4.c → cp 명령어를 이용하여 파일 ex1.c를 ex2.c, ex3.c, ex4.c에 복사한다. cat 명령어를 이용하여 그 내용을 확인해 볼 수 있다.
$ rm ex2.c → rm 명령어를 이용하여 ex2.c를 삭제한다. ls 명령어를 이용하여 파일이 삭제되었는지 확인해 볼 수 있다.
$ mv ex3.c y.c → mv 명령어를 이용하여 ex3.c를 y.c로 파일의 이름을 바꾼다. ls 명령어를 이용하여 파일의 이름이 변경되었는지 확인해 볼 수 있다.