Reference book: “Understanding Linux Kernel” by Bovet & Cesati
ls
, cat
, cp
, ….read
, write
, fork
, …..Following is a simple classification for some of the Linux commands. Read them and do the following lab problems. To access the lab server, you need to download putty.exe from the internet. For korean language support, get 한글 putty and set window>translation to UTF-8. Among the commands, use “man” to find out the meaning/usage of commands or system calls. For example,
man man -- shows the usage of “man” command
man ls -- shows the usage of “ls” command
man read -- shows the usage of “read” system call
man kill -- shows the usage of "kill" command
man 2 kill -- shows the usage of "kill" system call
man 3 printf -- shows the usage of "printf" c-library function
general: man
process:
ps : listing processes
gcc : c compiler
kill : stop a process
^c : stop a process
file :
vi : editor
ls : listing files and directories in the current directory
cat : show the contents of a file
more : show the contents of a file screen by screen
xxd : show the contents of a file in binary
cp, rm, mv : copy, remove, change the name
echo : echo
grep : search given string in a given file
cd : change directory
rmdir, mkdir : remove a directory, create a directory
vi
:editorvi x.c
: edit file x.c
vi
has three modes.
j
(down), k
(up), h
(left), l
(right)x
(delete one character), dd
(delete a line)3yy
: copy “3” lines starting from the current line - p
: paste them after the current line
recover - u
: recover what you have just deletedi
, a
, o
i
: start insertion from the current cursora
: start insertion after the end of the current lineo
: insert a new line/
or :
:q!
: quit without saving:w
: write:wq
: save and exit/pat
: search the pattern in “pat”:set number
: display line numbersgcc -o myx x.c
will compile x.
c and produce the executable file “myx”. You can run “myx” by typing “myx” and hit the enter key. x.c
will look like as follows.
#include <stdio.h>
int main(){
printf("hello\n");
return 0;
}