天天看點

Sum up - Linux Interview Questions (Updating)

Linux / Shell  interview questions

1.    Write a command that will look for files with anextension “c”, and has the occurrence of the string “apple” in it.

Find ./ -name “*.c” | xargs grep –i “apple”

2.    Xargs 代替一堆parameters,就是把之前的參數都在這次傳進來,比如你想rm一堆你你find到的檔案,likethis:rm`find /path -type f`。但是這樣會報錯,參數太多,是以需要改成這樣find/path -type f -print0 | xargs -0 rm。記住:單純的”|”是不管用的,因為是rm sth而不是sth->指令,是以”|”沒用。

3.    Valid Phone Number:

cat file.txt | grep -E "^(([0-9]{3})|[0-9]{3}-)[0-9]{3}-[0-9]{4}$"

4.    Let’s say you maintains a backup on regularbasis for the company you are working. The backups are maintained in Compressedfile format. You need to examine a log, two months old. What would you suggestwithout decompressing the compressed file?

5.  # zcat ­f phpshell­2.4.tar.gz

6.    You need to track events on your system. Whatwill you do?

Running ‘syslogd‘ application in terminalgenerates log file at the location ‘/var/log/syslog‘. The syslogd applicationis very useful in troubleshooting Linux sytems. A sample log file looks similarto below.

7.    Telnet and SSH both are communication protocolwhich are used to manage remote system. SSH is Secured, which requiresexchanging of key opposite of telnet which transmit data in plain text, whichmeans telnet is less secure than SSH.

8.     You need to search for the string “Tecmint” in allthe “.txt” files in the current directory. How will you do it?

9.  # find -­name “*.txt” | xargs grep “Tecmint”      

繼續閱讀