Linux interview questions

面试问题 1、设置 linux 服务器的 IP 地址、网关和 DNS 北京的 DNS IP 地址是 网关是 DNS 是 2、如何查找属主是 CSMAIL 的文件 3、如何查找文件包含 CSMAIL 的文件 4、 打一个文件,那个文件有好几行数字,问你如何找每行结尾数字后面添加 VI 一个 * 号 5、现在想将一个文本中每两行合并成一行,即将每个偶数行连接到奇数行的后 面,如何实现? 6、剪切出 IFCONFIG 输出的 IP 地址 7、你如何知道那个 程序在运行 25 端口,并将这个 程序 KILL 掉 。 8、如何在文字界面下设置时间。 9、如何知道一个文件里有多少行 10.你想远程管理一个 SERVER 但是那是却没有 开 SSH 及 TELNET 你咋办? 如何远程管理那的 SERVER 答: 1.(1)编辑/etc/network/interfaces (2)etc/resolve.conf 里配置 address netmask network

//IP 地址和网关 //DNS

2. 答:find / -user CSMAIL //属主是用户 CSMAIL 的文件 3. 答:find / -type f -exec grep -H CSMAIL {} \; {}: Matches any character contained within the bracket.
\: Means to take the next character serious so you could search for C\ C. find Members/ -type f -print0 | xargs -0 grep "examplestring"

grep -r "search string" /tmp 4. :%s/$/*/g 或 %s/string/replace/g:同样会将全文的 string 字符串取代为 replace 字符串,

$:移到光标所在行的行尾。 g 则是表示全部取代不必确认 5 答:在 VI 的命令模式下,按下面的序列 解释: 1g 是到文件头 p 表示记录宏开始 p 表示把宏记录在 q 寄存器中 J 表示合并两行 j 表示移动倒下一行 q 表示结束纪录宏 1000000 表示运行下一个命令 1000000 次,直到出错。 @ 表示运行宏 q 表示运行 q 寄存器中的宏 6. into the memory. The link will show permissions . rather. 答:wc -l file 1. 答: ifconfig|grep 'inet addr'|awk -F : '{print $2}'|awk '{print $1}' 用 ifconfig 的输出切 IP 7. and tell the system which partition and hard drive to boot from. What is the main advantage of creating links to a file instead of copies of the file? A: The main advantage is not really that it saves disk space (though it does that too) but. It will load the MBR. 答:netstat -antp 找到 PID 之后 ps -anx kill 那个 PID 或 lsof -i :25 取得 pid 再 kill 8.你想远程管理一个 SERVER 但是那是却没有 开 SSH 及 TELNET 你咋办? 如何远程管理那的 SERVER 答:server 拿硬盘出来装 ssh 和 telnet What is LILO? LILO stands for Linux boot loader. master boot record. that a change of permissions on the file is applied to all the link access points. 答:date -s 系统时间 9.

log". the date and the wc -l. B is the output) which produces only one copy of each UID. B then A.log together with the number of distinct users who have processes running on the system at that time. These UIDs are fed into wc -l which counts the lines . If the file . These are fed into the awk which filters out all but the UIDs. you only have to do it on the original. Now to answer the question as to what this command line produces.files. And the output will put into a file call December. What does the following command line produce? Explain each aspect of this line. With copies you have to find all of the copies and change permission on each of the copies. ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity. are appended to the file " this case the number of distinct UIDs running processes on the system. Thus if you want to change the permissions for a command. which is ‘/’.if the list is A. Write a command to find all of the files which have been accessed within the last 30 days. Finally the results of these two commands. find / -type f -atime -30 > December. B. If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s. $ (date . but if it’s A. ‘-atime -30′ will give all the files accessed less than 30 days ago.of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points.uniq only works on sorted data .files This command will find all the files under root. A. This writes the date and time into the file Activity. A will be the output of uniq. A.log A: First let’s dissect the line: The date gives the date and time as the first command of the line. B. this is the ps -ef. this is followed by the a list of all running processes in long form with UIDs listed first. these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort . then A. What is the most graceful way to get to run level single user mode? A: The most graceful way is to use the command init s. such as su. with file type is file.

otherwise the file is created.already exists. then these items are appended to the file. .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.