Linux/Unix Shell Scripting Basics
Quiz covering Unix/Linux file system commands, shell scripting, system variables, and device management.
Questions
You are executing the following commands in a shell $ cp ~/myfile.dat /media/mounted/ext/drive1/newmyfile.dat $ cd /media/mounted/ext/drive1 $ mv newmyfile.dat oldmyfile.dat and now you are asked to display the long listing of the file "newmyfile.dat". Which of the following will you use ?
- ls -lrt !cp:2
- ls -lrt !mv:1
- ls -lrt /media/mounted/ext/drive1/newmyfile.dat
- a and b will give "Command not found error" and c will work fine and all other options are incorrect.
- a,b and c will give correct results.
You are done using your external memory disk (say-KINSTON Pen disk) in Linux and you want to unmount it. But you get an error message like "umount: /media/KINGSTON: device is busy". Which of the following you can use to UNMOUNT IT SAFELY.
- Find the process that is using the drive and kill it safely.
- option a is correct and the following needs to be done to implement it: fuser /media/KINGSTON;fuser -k /media/KINGSTON; umount /media/KINGSTON
- Option a is incorrect and unsafe and you need to hard boot to solve this problem.
- Use a force option on unmount to acheive this : umount -F /media/KINSGTON
- a and b are correct.
You have purchased a dual processor quad-core server and you run the command "cat /proc/cpuinfo | grep processor | wc -l " what will be the output:
- 2
- 16
- 8
- a and b are incorrect. C is correct.
- a or c. result depends on other configuration of the system.
You have 5 mp3 files in a directory and you are planning to rename the all .mp3 files to .ogg files. Will the following Shell script acheive your goal ? for i in ls *.mp3; do mv $i $i.ogg done. Will the above script rename correctly and how many number of files will be present in the directory after execution of the script ?
- Yes. 0 files will be present
- No
- Yes. 5 file or more will be present.
- Yes. Only 5 files will be present.
- All the above are incorrect.
You have 5 mp3 files in a directory and you are planning to rename the all .mp3 files to .ogg files. Will the following Shell script acheive your goal ? for i in ls *.mp3; do mv $i $i.ogg done. Will the above script rename correctly and how many number of files will be present in the directory after execution of the script ?
- Yes. 0 files will be present
- No
- Yes. 5 file or more will be present.
- Yes. Only 5 files will be present.
- All the above are incorrect.
For debugging shell Scripts which command is used?
- set
filename - set -x
- set +x
- set
ls -l
what are the system variables in unix?
- PATH variable
- HOME variable
- IFS variable
- All the above
which commans are used to manipulate the ownership of file or directory?
- chown
- chgrp
- both 1 & 2
- None of the above