1. 创建目录/data/laoxin,并且在该目录下创建文件laoxin.txt,然后在文件“laoxin.txt”里写入内容“inet addr : 10.0.0.8 Bcast : 10.0.0.255 Mask : 255.255.255.0 ”(不包含引号)
[root@hspEdu01 data]# mkdir -p /data/laoxin
[root@hspEdu01 data]# echo "inet addr : 10.0.0.8 Bcast : 10.0.0.255 Mask : 255.255.255.0" > ./laoxin/laoxin.txt
[root@hspEdu01 data]# cat ./laoxin/laoxin.txt
inet addr : 10.0.0.8 Bcast : 10.0.0.255 Mask : 255.255.255.0
2. 脚本计算1+2+3…. +100=?
[root@hspEdu01 linux基础30题]# cat sum.sh
#!/bin/bash
SUM=0
for i in {1..100};
do
SUM=$[$SUM+$i]
done
echo sum=$SUM;
echo '---------------'
echo sum=$(($(seq -s+ 1 100)));
[root@hspEdu01 linux基础30题]# ./sum.sh
sum=5050
---------------
sum=5050
3. 统计一下/usr/local/nginx/log/access.log 日志中访问量最多的前十个IP?
[root@hspEdu01 linux基础30题]# cat /usr/local/nginx/logs/access.log | awk '{print $1}' | sort | uniq -c | sort -r| head -10
747 192.168.10.1
16 127.0.0.1
12 client
1
4. 怎么查看当前系统中每个IP的连接数
[root@hspEdu01 linux基础30题]# netstat -ntu | awk '{print $5}' | cut -d: -f1 | uniq -c | sort
1 192.168.10.1
1 Address
1 servers)
5. 查看磁盘的IO
[root@hspEdu01 linux基础30题]# iostat
Linux 3.10.0-1160.119.1.el7.x86_64 (hspEdu01) 2025年05月22日 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.07 0.00 0.20 0.02 0.00 99.70
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 6.68 257.19 46.43 949970 171504
sdb 0.43 16.32 0.00 60280 0
scd0 0.00 0.28 0.00 1028 0
dm-0 0.02 0.60 0.00 2204 0
6. 写一个脚本,实现批量添加20个用户,用户名为:user1-20,密码为user后面跟着5个随机字符或数字
[root@hspEdu01 linux基础30题]# cat user.sh
#!/bin/bash
for i in {1..20};
do
username="user$i";
password="user$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -1)";
useradd $username;
echo "$password" | passwd --stdin "$username"
done
[root@hspEdu01 linux基础30题]# chmod a+x user.sh
[root@hspEdu01 linux基础30题]# ./user.sh
更改用户 user1 的密码 。
passwd:所有的身份验证令牌已经成功更新。
……
更改用户 user20 的密码 。
passwd:所有的身份验证令牌已经成功更新。
[root@hspEdu01 home]# ls /home/ | grep user
user1
user10
user11
user12
user13
user14
user15
user16
user17
user18
user19
user2
user20
user3
user4
user5
user6
user7
user8
user9
7. 查看网络流量的命令
iftop # 需要安装
# 或
nload # 需要安装
# 或
sar -n DEV 1
8. squid默认缓存的大小是多少
通常是 100 MB,但具体取决于配置文件。
9. 查看linux系统的配置命令
uname -a # 内核信息
cat /etc/*release # 发行版信息
lscpu # CPU信息
free -h # 内存信息
df -h # 磁盘信息
10. 用shell脚本或命令将/opt目录下的大于15KB的文件都移到/data/temp目录下
# 建议使用之前快照,不然文件丢失概不负责
[root@hspEdu01 linux基础30题]# find /opt -type f -size +15k -exec mv {} /data/temp \;
11. 写一个脚本查找最后创建时间是三天前,后缀是*.log的文件并删除
# 建议使用之前快照,不然文件丢失概不负责
[root@hspEdu01 linux基础30题]# find /data/temp/log -type f -name "*.log" mtime +3 -exec rm {} \;
12. 使用tcpdump监听主机为192.168.1.1,tcp端口为80的数据,同时将输出结果保存输出到
tcpdump.log。
[root@hspEdu01 Linux基础30题]# tcpdump host 192.168.10.128 and tcp port 80 -w tcpdump.log
tcpdump: listening on virbr0, link-type EN10MB (Ethernet), capture size 262144 bytes
13.请用shell查询file 里面空行的所在行号
[root@hspEdu01 Linux基础30题]# cat file
line 1
line 2 abc
line 4
line 5 abc
line 7
line 8
line 9 abc
[root@hspEdu01 Linux基础30题]# grep -n '^$' file | cut -d: -f1
3
6
14. 查询file 以abc结尾的行
[root@hspEdu01 Linux基础30题]# grep 'abc$' file
line 2 abc
line 5 abc
line 9 abc
15. 打印出file 文件第1 到第3 行
[root@hspEdu01 Linux基础30题]# sed -n '1,3p' file # head -3 file 效果一样
line 1
line 2 abc
16. 如何将本地80 端口的请求转发到8080 端口,当前主机IP 为192.168.2.1
[root@hspEdu01 Linux基础30题]# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
| 参数或选项 | 具体含义 |
|---|---|
-t nat | 选择要操作的表。这里选择的是nat表,该表主要用于网络地址转换,像端口转发就属于此类操作。 |
-A PREROUTING | 往链中添加规则。此规则会被添加到PREROUTING链里,该链的作用是在数据包刚进入系统、还未进行路由选择时对其进行处理。 |
-p tcp | 对协议进行限制,这里限制的是 TCP 协议。 |
--dport 80 | 限定目标端口为 80,也就是 HTTP 服务的默认端口。 |
-j REDIRECT | 执行重定向操作,将符合条件的数据包重定向到本地的另一个端口。 |
--to-port 8080 | 明确重定向的目标端口为 8080。 |
17. 在10月份内,每天的早上9点到12 点中,每隔3小时执行一次/usr/bin/httpd.sh 怎么实现
[root@hspEdu01 Linux基础30题]# (crontab -l 2>/dev/null; echo "0 9,12 * 10 * /usr/bin/httpd.sh") | crontab -
[root@hspEdu01 Linux基础30题]# crontab -l
0 9,12 * 10 * /usr/bin/httpd.sh
18. 编写个shell 脚本将/usr/local/test 目录下大于100K 的文件转移到/tmp目录下
[root@hspEdu01 Linux基础30题]# find /usr/local/test -type f -size +100k exec mv {} /temp \;
19. 如何查看占用端口8080 的进程
[root@hspEdu01 Linux基础30题]# lsof -i :8080
[root@hspEdu01 Linux基础30题]# netstat -tulnp | grep 8080
20. 仅列出 /home目录下的所有目录,请写出完整命令
[root@hspEdu01 Linux基础30题]# find /home -maxdepth 1 -type d
/home
/home/jack
/home/jerry
/home/tset
/home/milan
/home/www
/home/tom
/home/bbb
[root@hspEdu01 Linux基础30题]# ls -d /home/*/
/home/bbb/ /home/jack/ /home/jerry/ /home/milan/ /home/tom/ /home/tset/ /home/www/
21. umask 022 ,请描述该命令的含义
umask 022表示新创建的文件默认权限是644(666-022),目录默认权限是755(777-022)。
22. 查询并列出 test进程所打开的当前所有文件,请写出完整的操作命令
[root@hspEdu01 Linux基础30题]# lsof -c test
[root@hspEdu01 Linux基础30题]# pid=$(pgrep test) && lsof -p $pid
23. 设置系统当前运行级别中 test服务状态为启动时自动加载,请写出完整操作命令假设运行级别为3级别
[root@hspEdu01 Linux基础30题]# chkconfig --level 3 test on
服务 test 信息读取出错:没有那个文件或目录
24. 常用的Nginx模块,用来做什么
ngx_http_rewrite_module: URL重写
ngx_http_proxy_module: 反向代理
ngx_http_gzip_module: 压缩响应
ngx_http_ssl_module: HTTPS支持
ngx_http_limit_req_module: 请求限速
25. 查看http的并发请求数与其TCP连接状态
[root@hspEdu01 Linux基础30题]# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
ESTABLISHED 2
26.shell下32位随机密码生成。
[root@hspEdu01 Linux基础30题]# cat /dev/urandom | tr -dc 'a-zA-Z0-9@#$&_()' | fold -w32 | head -1
6Zt3cCBPs(JBzQH8r))ok4YCikH27KSD
27. ps aux 中的VSZ代表什么意思,RSS代表什么意思
VSZ: Virtual Memory Size,虚拟内存大小,包括进程使用的所有内存(共享库等)
RSS: Resident Set Size,实际使用的物理内存大小
28. `限制apache每秒新建连接数为1,峰值为3
[root@hspEdu01 ~]# iptables -A INPUT -p tcp --dport 80 -m limit --limit 1/second --limit-burst 3 -j ACCEPT
29. 显示/etc/inittab中包含了:一个数字:(即两个冒号中间一个数字)的行
[root@hspEdu01 Linux基础30题]# grep ":[0-9]:" /etc/inittab
30. 写一个脚本,实现判断192.168.1.0/24网络里,当前在线的IP有哪些,能ping通则认为在线i)
[root@hspEdu01 Linux基础30题]# cat demo.sh
#!/bin/bash
for ip in 192.168.10.{1..254};
do
if ping -c 1 -W 1 $ip &>/dev/null;
then
echo "$ip is online"
fi
done





Pepebetcasino definitely has some unique games. Had a fun time there and they seem to have some interesting bonuses too! Check em out here pepebetcasino.
It’s fascinating how easily accessible online gaming has become, especially in markets like the Philippines. Secure platforms & legit status are key – verification processes are smart! Considering a new app? Check out the winph99 app download for a streamlined experience.
Alright, 9pgame! Heard some whispers about this one. Gonna check it out and see if it lives up to the hype. Hope it’s got some good action! 9pgame
It’s fascinating how gaming mirrors strategic thinking – patience & discipline really do matter. Reminds me of the approach at marlboro ph casino, where skillful play is key. Understanding risk is huge!