Linux/Unix System Programming
Test your knowledge of Linux and Unix system programming including system calls, IPC mechanisms, process management, file systems, and system administration commands
Questions
How can I tell how much memory my system has?
- Use getmemory()
- Use sysctl()
- Use freemem()
- Use malloc()
What is a socket
- A port to connect printer
- A port to connect keyboard
- An abstraction to pass data across processes
- A hardware device
What is a semaphore
- A mechanism to share non-sharable resources
- A mechanism to access memory very fast
- A mechanism to access kernel details
- None
What is a message queue?
- A printer queue
- An IPC mechanism with destructive execute
- An IPC mechanism with destructive write
- An IPC mechanism with destructive read
Difference between shared memory & message queue
- No differences
- IPC mechanism vs Non-IPC mechanism
- Non-destructive read vs destructive read
- Destructive read vs non-destructive read
To delete the last word of each line in the file test1
- sed 's/ */$//' test1
- sed 's/ *$//' test1
- sed 's/ \*$//' test1
- sed 's/ \*$\/\/' test1
How to duplicate file descriptors?
- duplicate()
- dup()
- cp()
- mknod()
How to set the default shell for an user?
- Use chshell command
- update the file /var/passwd
- update the file /etc/users
- update the file /etc/passwd
What is the difference between at & cron?
- Both are Unix scheduling utilities
- at is restricted one and crontab is not restricted
- No difference
- at takes input from user while cron takes from a confiuration file
How to mount a file system temporarily?
- mount -t
- mount -R
- mount
- mount -Rt
How to remove a queued file from the printer queue?
- lpqrm
- lprm
- jobs -r
- lpc -rm
/etc/fstab cannot be altered when the system is running runlevel 6
- True
- False
fork() and exec() are essentially doing the same job
- True
- False
It is possible to process return value of system()
- True
- False
To execute system() one should have root privilege
- True
- False
lpc command is used to
- Add printer and queues
- Add modem & flash drive
- Add printer alone
- Invalid command
What is the difference between select() & poll()?
- select() and poll() have no differences
- poll() is event driven while select() is not
- select() is event driven while poll() is not
- None
What is /proc/kcore process?
- The process file name of init
- The proc file name of RAM
- Invalid file
- The core dump file
Error in loading shared libraries: lib xxx..so. x: cannot open shared object file: No such file or directory
- Resolve by update PATH variable
- Resolve by setting SHELLPATH variable
- Resolve by updating LD_LIBRARY_PATH
- Resolve by setting LIBRARY_PATH variable
Setting user id commands related (setuid) are allowed in Liunx and they work as they work with any Unix system
- True
- False