Which tool can be used to find memory leakage and Invalid memory check
Filed under: C Interview Questions, Linux Programming Interview Questions
Valgrind can be used to find memory leakage. Valgrind is a multipurpose code profiling and memory debugging tool for Linux when on the x86 and, as of version 3, AMD64, architectures.
Below is the example on how to use valgrind:
#include
int main()
{
char *x = malloc(100); /* or, in C++, “char *x = new char[100] */
return 0;
}
% valgrind –tool=memcheck –leak-check=yes example1
This will result in some information about the program showing up, culminating in a list of calls to malloc
that did not have subsequent calls to free:
==2116== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2116== at 0×1B900DD0: malloc (vg_replace_malloc.c:131)
==2116== by 0×804840F: main (in /home/cprogram/example1)
This doesn’t tell us quite as much as we’d like, though — we know that the memory leak was caused
by a call to malloc in main, but we don’t have the line number. The problem is that we didn’t compile
using the -g option of gcc, which adds debugging symbols. So if we recompile with debugging symbols,
we get the following, more useful, output:
==2330== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2330== at 0×1B900DD0: malloc (vg_replace_malloc.c:131)
==2330== by 0×804840F: main (example1.c:5)
What is the difference between User ID and GUID (Group UserID)
Filed under: Shell Scripting Interview Questions, Unix Scripting Interview Questions
User ID and Group ID. They are used for a first-cut security in Unix systems, in that files and programs can be restricted to certain groups, or to certain users. Groups are kept in the /etc/group file, users and the group they belong to are kept in the /etc/passwd file.
How sticky bit works in Solaris?
Filed under: Solaris Interview Questions, Unix Interview Questions
Sticky Bit is a permission bit that protects the files with in a Directory. If the directory has sticky bit set, a file can be deleted by the owner of the file, the owner of the directory or root.
This Prevents a user from deleting other users files from public directories
What is difference between solaris single user mode and multi user mode ?
Filed under: Solaris Interview Questions, Unix Interview Questions
Single User mode: Single user mode is for trouble shooting purpose, in this mode only root user can login to the system.
Multi User Mode: In this mode apart from root user other user can also login to the system and they can access resources and applications of the system.
Single user mode is the maintenance mode where only systems critical files are mounted. Multiuser mode is running the server with full network services including NFS.
