This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * | |
| * mtrace and muntrace example | |
| * | |
| * Running the program and sample output: | |
| * | |
| * gcc -Wall -pedantic -o mtrace_and_muntrace mtrace_and_muntrace.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * calloc and realloc example | |
| * gcc -Wall -pedantic -o calloc_and_realloc calloc_and_realloc.c | |
| * ------------------------------------------------------------ | |
| * export MALLOC_TRACE=/tmp/t | |
| * ------------------------------------------------------------ | |
| * ./calloc_and_realloc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * search for a key in an array, | |
| * if key is found return pointer to key | |
| * else return NULL | |
| */ | |
| #include <stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * ./read_passwd_file root 3 | |
| * | |
| * sample output | |
| * ------------------------------- | |
| * Read /etc/passwd file | |
| * Login name: root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * Read entries in the passwd one at a time using getpwent | |
| */ | |
| #include <pwd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * ./read_group_file sys 0 | |
| * | |
| * sample output | |
| * --------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * Read entries in the groups file one at a time | |
| */ | |
| #include <grp.h> | |
| #include <stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * Refer to Listing 8-2 of LPI book | |
| * | |
| * Authenticate user against the /etc/shadow | |
| * gcc -Wall -pedantic -o check_user_password check_user_password.c -lcrypt | |
| * | |
| * sudo ./check_user_password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| * | |
| * | |
| * uptime command implementation | |
| */ | |
| #include <errno.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Author: NagaChaitanya Vellanki | |
| * | |
| *see listing 10-2 of LPI book | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> |