Liunx面试题

答案待定

1、请用 shell 查询 file1 里面空行的所在行号
2、编写 ShellScript 查询 file1 以 abc 结尾的行
3、打印出 file1 文件第 1 到第 3 行
4、如何将本地80 端口的请求转发到 8080 端口,当前主机 IP 为 192.168.2.1
5crontab
11 月份内,每天的早上 6 点到 12 点中,每隔 2 小时执行一次 /usr/bin/httpd.sh 怎么
实现
6、编写个shell 脚本将 /usr/local/test 目录下大于 100K 的文件转移到 /tmp 目录下
7、简述raid0 raid1 raid5 三种工作模式的工作原理及特点。
8oracle 数据库备份方式
9、如何查看占用端口8080 的进程
10、请写出apache2.X 版本的两种工作模式,以及各自工作原理。如何查看 apache 当前所支持的模块,并且查看是工作在哪种模式下?
11、你使用过监控软件吗?说说其特点
12linux 下常用的 DNS 服务软件是什么,举出几种常用的 DNS 记录,如果域名 abc.com 配置好了一台邮件服务器,IP 地址为 202.106.0.20,我该如何做相关的解析?是否了解 bind 的智能解析,如果了解请简述一下其原理:
13、通过apache 访问日志 access.log 统计 IP 和每个地址访问的次数,按访问量列出
10 名。
日志格式样例如下
192.168.1.247 – - [02/Jul/2010:23:44:59 +0800] “GET / HTTP/1.1″ 200 19

14、如何用mysql 命令进行备份和恢复?以 test 库为例,创建一个备份,并再用此备份
进行恢复。
15、你认为在系统调优方面都包括哪些工作,以linux 为例,请简明阐述,并举一些参数
为例。
16 有个文件如下:
http://a.domain.com/1.html
http://b.domain.com/1.html
http://c.domain.com/1.html
http://a.domain.com/2.html
http://b.domain.com/2.html
http://a.domain.com/3.html
要求:得到主机名(和域名),并统计哪个网址出现的次数,并排序。可以shell 或 C。
得到的结果应该是:
3 a.domain.com
2 b.domain.com
1 c.domain.com
17 A B 网络是通的,最少列出五种传输文件的服务
18. 假设 Apache 产生的日志文件名为 access_log, 在 apache 正在运行时, 执行命令 mv
access_log access_log.bak, 执行完后, 请问新的 apache 的日志会打印到哪里, 为什么?
19. 在 Shell 环境下, 如何查看远程 Linux 系统运行了多少时间?
20. 如何查看当前 Linux 系统的状态, 如 CPU 使用, 内存使用, 负载情况等.
21read 命令 5 秒后自动退出
22grep -E -P 是什么意思。 -P 不太清楚
shell 脚本编程部分
23.从a.log 文件中提取包含“WARNING”或”FATAL”, 同时不包含“IGNOR”的行,然后,
提取以“:”分割的第五个字段?
24.添加一个新组为class01, 然后,添加属于这个组的 30 个用户,用户名的形式为 stdXX,
其中,XX 从 01 到 30?
25.在每个月的第一天备份并压缩/etc 目录下的所有内容,存放在 /root/backup 目录里,
且文件名为如下形式yymmdd_etc,yy 为年,mm 为月,dd 为日。shell 程序 fileback
存放在/usr/bin 目录下?
26.用shell 编程,判断一文件是不是字符设备文件,如果是将其拷贝到 /dev 目录下?
参考答案:
#!/bin/bash
directory=/dev
for file in anaconda-ks.cfg install.log install.log.syslog
do
if [-f $file]
then
cp $file $directory/$file.bak
echo "HI, $LOGNAME $file is backed up already in $directory !!"
fi
done
27.某系统管理员需要每天做一定的重复工作,编制一个解决方案:
(1). 从下午 4:50 删除 /abc 目录下的全部子目录和全部文件;
(2). 从早上 8:00~下午 6:00 每小时读取 /xyz 目录下 x1 文件中每行第一个域的全部数
据加入到/backup 目录下的 back01.txt 文件内;
(3). 每逢周一下午 5:50 将 /data 目录下的所有目录和文件归档并压缩为文件
backup.tar.gz;
(4). 在下午 5:55 将 IDE 接口的 CD-ROM 缷载(假设 CD-ROM 的设备名为 hdc);
(5). 在早上 8:00 前开机后启动。
---------------------------------------
------------------
28、简述Apache 两种工作模式,以及它们之间的区别。
答案:最主要的两种模式是prefork 模式与 worker 模式。prefork 每个子进程只有一个线
程,效率高但消耗内存大,是unix 下默认的模式;worker 模式每个子进程有多个线程,
内存消耗低,但一个线程崩溃会牵连其它同子进程的线程。
2、用 iptables 添加一个规则允许 192.168.0.123 访问本机 3306 端口
iptables -I INPUT 1 -p tcp -m tcp --dport 3306 -s 192.168.0.123 -j ACCEPT
3、如何对一台 Linux 服务器进行系统性能调优,列举出参数。
4、DNS 服务器的工作原理。
5、修改第一块网卡的路径是什么。
/etc/sysconfig/network-scripts/ifcfg-eth0
7、使用 shell,建立 class1 用户组,再批量建立 stu1--stu30 的用户,并指定用户组为
class1。
vi autoaddusr
#!/usr/bin/php -q

一、Linux 操作系统知识
1. 常见的 Linux 发行版本都有什么?你最擅长哪一个?它的官网网站是什么?说明你擅长哪一块?
2.Linux 开机启动流程详细步骤是什么?系统安装完,忘记密码如何破解?
3. 企业中 Linux 服务器系统分区标准是什么?(硬盘为 300G,内存 16G)
4. 某一天突然发现 Linux 系统文件只读,该怎么办呢?完整操作步骤。
5. 安装一台系统使用 DVD 光盘安装,如何安装 50 台 Linux 系统如何安装呢?思考一下。
6. 用虚拟机安装了一台 Linux 系统,突然想克隆一台服务器,克隆后发现无法上网,如何解决?
7.Linux 网卡配置文件路径是什么?要使服务器上外网,必须满足的条件有哪些?需要配置什么?
8. 一般可以使用什么软件远程 linux 服务器?通过什么上传文件和下载文件?
9./mnt 目录主要用于什么?/root 目录跟 root 用户有什么关系?/ 根目录与 /boot 目录有什么联系?
10. 某一天误操作,执行了 rm -rf * ,会有哪些情况发生?请举例。

二、Linux 命令及文件操作
1. 在 /tmp/ 目录下创建 test.txt 文件,内容为: Hello,World! , 用一个命令写出来。
2. 给 test.txt 文件除所有者之外增加执行权限,最终以数字写出文件的权限。
3. 用 vi 命令编辑 test.txt,如何跳转到末行,首行,行首、行末,如何在光标行下一行插入,如何复制 5 行,删除 10 行,查找 jingfeng 的字符、把 jingfeng 替换为 jfedu.net
4. 查找 linux 系统下以 txt 结尾,30 天没有修改的文件大小大于 20K 同时具有执行权限的文件并备份到 /data/backup/ 目录下。
5. 当前 test.txt 所属的用户为 root,组为 abc,请将 test.txt 使拥有者为 abc,组为 root,写出命令。
6. 如何修改 Linux 启动级别为字符模式并永久生效,如何临时、永久关闭 selinux 及防火墙,请分别写出操作方法。
7. 每次开机在 /tmp 目录下创建一个当天的日期文件夹 (提示:当前日期表示的方法为:`date +%Y%m%d`)
8. 如何查看文件内容,命令有哪些?查看文件第 1 行到 3 行,查看文件最后一行。
9. 查看 linux 服务器 IP 的命令,同时只显示包含 ip 所在的行打印出来。
10. 将普通用户 test 加入 root 组的命令是?

三、Linux 磁盘及软件管理操作
1. 如何添加一块新的 50G 硬盘到 linux 服务器系统作为单独的分区,并正在使用?需要哪些操作步骤?
2. 有个金士顿 U 盘,需要往服务器 /var/www/html/ 目录下上传一个 index.html 文件,如何操作并完成。
3. 有一块移动硬盘,上面有 300G 数据,如何快速 cp 到 linux 服务器?
4. 光盘里面有一个 httpd-2.2.15.xx.rpm 包,如何挂载并安装呢?
5. 使用 rpm 命令安装、卸载、删除、更新 ntp-0.7.12.x86_64.rpm 这个软包。
6./var/www/html/ 是网站的发布目录,如何每天凌晨 0 点 30 对其进行自动备份,写出操作步骤?
7. 使用 tar 命令打包并压缩 /root 目录,然后移动到 /tmp 下,将其权限设置其他人只读。
8.Yum 命令与 rpm 命令的区别?如何使用 rpm 安装一个有依赖的包?

9. 在这个月内,每天的早上 6 点到 12 点中,每隔 2 小时创建一个 test.txt 文件,内容为 ok,如何实现?
10. 将 /usr/local/test 目录下大于 100K 的文件转移到 /tmp 目录下。
11. 简述 raid0 raid1 raid5 三种工作模式的工作原理及特点。
12. 如何查看占用端口 8080 的进程。

四、Linux 服务配置及管理
1. 请写出 apache2.X 版本的两种工作模式,以及各自工作原理。如何查看 apache 当前所支持的模块,并且查看是工作在哪种模式下?
2.Linux 下 nfs 在客户端无法挂载,请写出排查步骤?
3.Linux 下已经部署了 dhcp 服务器,客户端无法获取的 IP,如何解决?
4. 常见的 FTP 软件有哪些?Linux 最常用的是?如何共享一个资源让他人使用用户名和密码访问?
5. 如何禁止 FTP 使用匿名用户登录?命令行如何访问 ftp 服务器?
6.ApacheWEB 服务器的发布目录在哪里?
7.ApacheWEB 服务器有几种工作模式,每种模式的简单区别?
8.MySQL 服务器的用途是?Apache 和 mysql 可以安装在一台机器吗?如何查看 apache 和 mysql 端口和进程?
9. 如何在虚拟机上面部署 4 个网站,访问的域名分别为www.a1.com test.a1.com www.a2.com test.a2.com?
10. 假设 Apache 产生的日志文件名为 access_log, 在 apache 正在运行时, 执行命令 mv access_log access_log.bak, 执行完后, 请问新的 apache 的日志会打印到哪里, 为什么?
11. 我们都知道 FTP 协议有两种工作模式,说说它们的大概的一个工作流程?
12.Linux 内核引导时,从哪个文件中读取要加载的文件系统。
13. 写出下面服务的常用端口 ftp http dns snmp pop3、dhcp、nfs、mysql、samba 等服务。
14.Mysql 创建数据库的命令,创建表的命令,插入语句的命令?
15.Mysql 备份命令?Mysql 如何给 root 用户对 jfedu 授权访问,密码为 jfedu.net, 请写出命令?
16.Mysql 忘记密码该如何操作呢?

上海试题

1. DNS 使用的端口号和协议,简单描述一下 DNS 正向解析和反向解析的工作原理和作用还有应用场景?

2.编写IPTABLES使用内网某台机器的80端口可以在公网访问,假设公网IP10.10.1.1 ,实现192.168.1.0/32段的NAT

3.举出三个以上的主流WEB服务器,并简述他们的特性和优缺点不限操作系统?

4,举出两个主流代理服务器,简述工作模式和优缺点?

5,举出两个负载均衡的软件,并简述工作模式和优缺点 ?

6,IE,FF,chrome 游览器最大并发请求数是多少?,

7,简单举例一下 linux 和 windows 系统今年都有哪些漏洞?

8mysql数据库备份都有哪一些,部署一个高可用mysql应用 环境,并说明他的高可用性? 9,什么是裸设备,他的好处是什么?,mysql支持裸设备吗?

10,如果给你一个 100g 的 INNODB 类型数据库,你会用什么备份方案来做备份。 11,写一个简单的 shell 脚本,脚本运行时让 CTRL+C 无法中断的该 shell 脚本? 12,如何快速编译单一的内核模块?

13,如何动态增加 apache 和 PHP 模块?

14、说出 linux 开机流程?

15、具体说说 cacti 的安装过程?

16、cacti 与 nagios 的区别?cacti 如何监控 mysql ?

17、mysql 主从复制如何实现?

18、raid 0 与 raid 的区别?

19、DNS 解析详细过程?从主机访问域名(三家公司都问这个问题)让写出来?20、脚本会多少?掌握程度?sed awk 区别

 

外企

1. Advantages/disadvantages of script vs compiled program.
2. Name a replacement for PHP/Perl/MySQL/Linux/Apache and show main differences.
3. Why have you choosen such a combination of products?
4. Differences between two last MySQL versions. Which one would you choose and when/why?
5. Main differences between Apache 1.x and 2.x. Why is 2.x not so popular? Which one would you choose and when/why?
6. Which Linux distros do you have experience with?
7. Which distro you prefer? Why?
8. Which tool would you use to update Debian / Slackware / RedHat / Mandrake / SuSE ?
9. You’re asked to write an Apache module. What would you do?
10. Which tool do you prefer for Apache log reports?
11. Your portfolio. (even a PHP guest book may work well)
12. What does ‘route’ command do?
13. Differences between ipchains and iptables.
14. What’s eth0, ppp0, wlan0, ttyS0, etc.
15. What are different directories in / for?
16. Partitioning scheme for new webserver. Why?

1. How do you take a single line of input from the user in a shell script?
2. Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.
3. Write a regular expression (or sed script) to replace all occurrences of the letter ‘f’, followed by any number of characters, followed by the letter ‘a’, followed by one or more numeric characters, followed by the letter ‘n’, and replace what’s found with the string “UNIX”.
4. Write a script to list all the differences between two directories.
5. Write a program in any language you choose, to reverse a file.
6. What are the fields of the password file?
7. What does a plus at the beginning of a line in the password file signify?
8. Using the man pages, find the correct ioctl to send console output to an arbitrary pty.
9. What is an MX record?
10. What is the prom command on a Sun that shows the SCSI devices?
11. What is the factory default SCSI target for /dev/sd0?
12. Where is that value controlled?
13. What happens to a child process that dies and has no parent process to wait for it and what’s bad about this?
14. What’s wrong with sendmail? What would you fix?
15. What command do you run to check file system consistency?
16. What’s wrong with running shutdown on a network?
17. What can be wrong with setuid scripts?
18. What value does spawn return?
19. Write a script to send mail from three other machines on the network to root at the machine you’re on. Use a ‘here doc’, but include in the mail message the name of the machine the mail is sent from and the disk utilization statistics on each machine?
20. Why can’t root just cd to someone’s home directory and run a program called a.out sitting there by typing “a.out”, and why is this good?
21. What is the difference between UDP and TCP?
22. What is DNS?
23. What does nslookup do?
24. How do you create a swapfile?
25. How would you check the route table on a workstation/server?
26. How do you find which ypmaster you are bound to?
27. How do you fix a problem where a printer will cutoff anything over 1MB?
28. What is the largest file system size in solaris? SunOS?
29. What are the different RAID levels?