This is the synopsis of the first Linux programming lab.
The description of the problem to be solved
During the whole course one problem should be solved: restore a password from a hash code generated by htpasswd command. The password should be restored using several approaches:
- recursive brute force,
- iterative brute force,
- multi threaded brute force on a machine with several CPUs,
- distributed over the network brute force.
The roadmap of the course
- Hello world application.
- Recursive brute force solution.
- Iterative brute force solution.
- Multi-threaded brute force solution.
- Synchronous thread per client solution.
- Asynchronous thread per client solution.
- Reactor implementation.
Topics covered in the first lab
- Linux shell commands introduction.
- Source code editor.
- Hello world application.
- Stages of program compilation.
- Primitive Makefile for the hello world application.
- GNU coding standards
Linux shell commands introduction
The commands used during the lab are:
- mkdir - create a directory,
- cd - change a directory,
- rm - remove a file,
- ls - list content of a directory,
- gcc - compile source code,
- make - run make utility,
- ./hello_world - run the hello world application.
Source code editor
Emacs is one of orthodox editors for C programming.
Here is a list of the most often commands for editing in Emacs:
- C-x-f - open file
- C-x-s - save file
- C-x-b - switch buffer
- C-x-u - undo
- C-space - set mark
- A-w - copy
- C-w - cut
- C-y - paste (yank)
- C-e - end of line
- C-a - beginning of line
- C-A-q - indent block
- Esc-Esc-Esc - escape
- C-q - cancel key sequence
- A-x - run command:
- shell - run bash,
- compile - run make,
- grep - run grep,
- replace-string - replace.
Hello world application
Solution that was implemented by the end of the first lab:
1 2 3 4 5 6 7 8 9 |
|
Stages of program compilation
GCC manuals You can determine the version of your gcc using command:
1
|
|
Stages of compilation.
- preprocessor - the result is source code file,
- translator - the result is object file,
- linker - the result is executable file.
The command line used to compile the application.
1
|
|
Make utility
The Makefile used to compile the application
1 2 3 |
|
GNU coding standards
References
- The C Programming Language. Kernighan, Brian W.; Ritchie, Dennis M.
- The Practice of Programming. Kernighan, Brian W.; Rob P.
- Advanced Programming in the UNIX Environment.
- Richard Stevens; Stephen A. Rago
- The Unix Programming Environment. Kernighan, Brian W.; Rob P.
- The Art of Unix Programming. Eric S. Raymond
- Advanced Linux Programming. Mark Mitchel; Jeffrey Oldham; Alex Samuel
- The Linux Programming Interface: A Linux and UNIX System Programming Handbook. Michael Kerrisk
- The Standard C Library. Plauger P. J.
- UNIX Network Programming, Volume 1: Networking APIs: Sockets and XTI.
- Richard Stevens
- UNIX Network Programming, Volume 2: Interprocess Communications.
- Richard Stevens