Frequently Asked Linux File Manipulation Interview Questions
1.What is a Linux ISO?
Downloadable binary file containing a CD/DVD disc image of a Linux distribution
2.Given the text “fileone,filetwo,filethree,filefour”,you need to delete all of the .sh files with those names (fileone.sh filetwo.sh…),how can you do it with brace expansion?
In order to use brace expansion,you need to add it to take the list and use it in braces – rm -f {fileone,filetwo,filethree,filefour}.sh.
3.You have a scripts directory called /scripts/ and you want to add it temporarily to your executable path,how can you do that?
Your executable path are extracted from the environment $PATH,you can add temporary item to it on the current shell using – export PATH=$PATH:/scripts.
4.If I have configured the parameter TTL in my domain configuration file (named) to 14400,what does it mean?
The domain TTL configuration is setting the time which name-servers querying the name server will cache the results in their DB before asking the server for new configuration. 14400 seconds is 4 hours.
5.You want to encrypt and password-protect a password file “mysecret.txt”,how can you do it with GPG and then decrypt it to view the contents?
In order to gpg encrypt a file,you type “gpg -c mysecret.txt” and choose your desired password. In order to decrypt it and view the contents,you type “gpg -d mysecret.txt.gpg”
6.You want to run a binary file,you have permissions to it,but it gives you “Access Denied”,what do you need to do?
In order to run an application in Linux you need to add executable permission to the file: in order to change a file mode,you need to use the chmod with the required parameters – chmod +x .
7.Given a CSV file “a.csv” ,how can you get the first column,of all the rows,into a new file called “result.log”?
cat a.csv | awk -F’,’ ‘{print $1}’ >> result.log.
8.You want to create files 1-100.log with the same text “Hello This is a test” in it,how can you do it?
For i in `seq 1 100` ; do echo “Hello this is a test” > $i.log ; done.
9.You have an xml file (myXML.xml) which is all in one line,how do you convert the xml into a well-formatted XML?
You can manipulate XML files using the “xmllint” application – xmllint –format myXML.xml.
10.Given the text file “MyLog.log”,which is written backwards,how can you invert the order of the lines?
cat MyLog.log | nl -ba | sort -rn | cut -f2-
11.What is the recommended size for the swap partition to be (minimum size) if you have 2GB RAM?
The SWAP partition minimum recommended size is RAM
*2 and never less than 32MB,therefore for 2GB RAM you should have 4GB SWAP.
12.How can you add special commands to run after the init process has been completed?
In order to add a command that will run after the system finish its initialization,you can add the command to /etc/rc.local.
13.Explain the following statement: ls -lhrS | grep -i $USER | tail -3 | awk ‘{ print $5,$9; }’
a) List the files (Long list) + human read + reverse + order by size. b) Grep only lines matching my user name c) Get the 3 last results d) Manipulate the string and print the 5th and 9th parameters (size + file name)
14.You want to set global environment and startup programs for all users,where can you set it?
The /etc/profile configuration file holds the global profile parameters and is inherited by the users on login,you can add your configuration there.
15.In which configuration can you set the user prompt automatically to all bash users to look like [user@host][~]#?
You can set bash configuration for all the users in the /etc/bashrc configuration file.
16.How can you find and display only the differences between myconfig.new and myconfig.old?
In order to find differences,we will use sdiff,and in order to see only the differences,we will use the -s argument: sdiff -s myconfig.new myconfig.old
17.How can you set KDE to be the default desktop manager?
You will need to edit the file /etc/sysconfig/desktop and add the following line s: DESKTOP=”KDE” DISPLAYMANAGER=”KDE”
18.When will you encounter a kernel panic issue?
A kernel panic will encounter when the system had found a critical error like – an error communicating with the hardware or a missing OS file.
19.What is an intrid image?
An intrid image is the initial ram disk image that is loaded into the memory after the POST in order to improve the machine’s I/O performance; it will contain a temporary root file system.
20.What is the minimum partitions do you need for a Linux installation?
The minimum partitions that you need in order to install a Linux installation is two(2),root and swap.
21.What is the difference between the commands ping and ping6?
The commands ending with 6 – ping6,traceroute6,tracepath6 have the same meaning,but are intended to use on ipv6 IP addresses.
22.What does an open mail relay server mean?
An Open mail relay server,means that this is a server that everyone can send emails through it without the need to identify first or be a part of the domain group.
23.How do you get additional information about a command – for example get information about mail?
If you want to learn about a command,you can use the commands man mail or info mail to learn more about mail.
24.How can you add an “auto correction” that will automatically fix “cd /homr” to “cd /home”?
You can add the option cdspell to your shell options by typing “shopt -s cdspell”.
25.You want to find all of the “.tmp” files in /home/
* and delete them,how can you do it in a command?
First you need to find the files using find,then delete them using rm – find /home/ -name ‘
*.tmp’ | xargs rm –rf.