第六周作业

1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#;

[[email protected] rc.d]# cp /etc/rc.d/rc.sysinit /tmp
[[email protected] rc.d]# ls /tmp
rc.sysinit
[[email protected] rc.d]# cd /tmp
[[email protected] tmp]# vim /tmp/rc.sysinit
#在末行模式下输入
:%s/^[^[:graph:]]/#&/
:wq
#验证:
[[email protected] tmp]# tail -10 /tmp/rc.sysinit 
==> /tmp/rc.sysinit <==
[ "$PROMPT" != no ] && plymouth --ignore-keystroke=Ii
if strstr "$cmdline" confirm ; then
#	touch /var/run/confirm
fi

# Let rhgb know that we‘re leaving rc.sysinit
if [ -x /bin/plymouth ]; then
#    /bin/plymouth --sysinit
fi

2、复制/boot/grub/grub.conf至/tmp目录中,删除/tmp/grub.conf文件中的行首的空白字符;

[[email protected] tmp]# ls /boot/grub/grub.conf 
/boot/grub/grub.conf
[[email protected] tmp]# cp /boot/grub/grub.conf /tmp
[[email protected] tmp]# vim /tmp/grub.conf
#在进入文本时会有一个提示,选择E,进入文件
#在末行模式下输入:
:%s/^[^[:graph:]]\+//
:wq

3、删除/tmp/rc.sysinit文件中的以#开头,且后面跟了至少一个空白字符的行行的#和空白字符

[[email protected] ~]# vim /tmp/rc.sysinit 
#末行模式下输入
:%/^#[[:space:]]\+//
:wq

4、为/tmp/grub.conf文件中前三行的行首加#号;

[[email protected] ~]# vim /tmp/grub.conf
#末行模式下输入
:1,3s/^/#&/
:wq

5、将/etc/yum.repos.d/CentOS-Media.repo文件中所有的enabled=0或gpgcheck=0的最后的0修改为1;

[[email protected] ~]# vim /etc/yum.repos.d/CentOS-Media.repo 
#末行模式下输入
:%s/enabled=0/enabled=1/g
:%s/gpgcheck=0/gpgcheck=1/g
:wq

6、每4小时执行一次对/etc目录的备份,备份至/backup目录中,保存的目录名为形如etc-201608300202

[email protected] ~]# crontab -e 
[email protected] ~]# /mkdir backup
* */4 * * * cp -a /etc /backup/etc-`date +%Y%m%d%H%M

7、每周2,4,6备份/var/log/messages文件至/backup/messages_logs/目录中,保存的文件名形如messages-20160830

[email protected] ~]# crontab -e 
[email protected] ~]# mkdir /backup/messages_logs
* * * * 2,4,6 /bin/cp -a /var/log/messages /backup/messages_logs/messages-`date +%Y%m%d`

8、每天每两小时取当前系统/proc/meminfo文件中的所有以S开头的信息至/stats/memory.txt文件中

[email protected] ~]# crontab -e 
[email protected] ~]# mkdir /stats
 */2 * * * /bin/egrep ‘^s|S‘ /proc/meminfo >> /stats/memory.txt

9、工作日的工作时间内,每两小时执行一次echo "howdy"

[email protected] ~]# crontab -e 
[email protected] ~]# mkdir /stats
* */2 * * 1-5 /bin/echo "howdy"

脚本编程练习

10、创建目录/tmp/testdir-当前日期时间;

#!/bin/bash
#

mkdir -pv /tmp/testdir-`date +%Y%m%d%H%M`

11、在此目录创建100个空文件:file1-file100

#!/bin/bash
#

dirname=/tmp/testdir-`date +%Y%m%d%H%M`
mkdir $dirname
for digits in {1..100};do
        touch $dirname/file$digits
done
#验证:
[[email protected] tmp]# ls testdir-201608281853/
file1    file16  file23  file30  file38  file45  file52  file6   file67  file74  file81  file89  file96
file10   file17  file24  file31  file39  file46  file53  file60  file68  file75  file82  file9   file97
file100  file18  file25  file32  file4   file47  file54  file61  file69  file76  file83  file90  file98
file11   file19  file26  file33  file40  file48  file55  file62  file7   file77  file84  file91  file99
file12   file2   file27  file34  file41  file49  file56  file63  file70  file78  file85  file92
file13   file20  file28  file35  file42  file5   file57  file64  file71  file79  file86  file93
file14   file21  file29  file36  file43  file50  file58  file65  file72  file8   file87  file94
file15   file22  file3   file37  file44  file51  file59  file66  file73  file80  file88  file95

12、显示/etc/passw d文件中位于第偶数行的用户的用户名;

#!/bin/bash
#

grep -o ‘^\<[[:alnum:]]*\>‘ /etc/passwd | sed -n ‘2~2p‘
#验证:
[[email protected] tmp]# bash /bin/passwdline2x.sh 
bin
adm
sync
halt
uucp
games
ftp
dbus
vcsa
rpcuser
haldaemon
saslauth
sshd
tcpdump
mageia
opentack
openstacd
archlinux
testbash
nologin

13、创建10用户user10-user19;密码同用户名;

[[email protected] tmp]# cat /adduser.sh 
#!/bin/bash
if [ ! $UID -eq 0 ]; then
    echo "Only root"
    exit 1
fi
for i in {10..19}; do
    if id user$i &> /dev/null; then
        echo "user$i exists"
    else
        useradd user$i
            if [ $? -eq 0 ]; then
                echo "user$i" | passwd --stdin user$i &> /dev/null
                echo "Add user$i successed."
            fi
    fi
done
#验证:
[[email protected] tmp]# bash /adduser.sh
Add user10 successed.
Add user11 successed.
Add user12 successed.
Add user13 successed.
Add user14 successed.
Add user15 successed.
Add user16 successed.
Add user17 successed.
Add user18 successed.
Add user19 successed.
[[email protected] tmp]# tail -10 /etc/passwd
user10:x:3011:3011::/home/user10:/bin/bash
user11:x:3012:3012::/home/user11:/bin/bash
user12:x:3013:3013::/home/user12:/bin/bash
user13:x:3014:3014::/home/user13:/bin/bash
user14:x:3015:3015::/home/user14:/bin/bash
user15:x:3016:3016::/home/user15:/bin/bash
user16:x:3017:3017::/home/user16:/bin/bash
user17:x:3018:3018::/home/user17:/bin/bash
user18:x:3019:3019::/home/user18:/bin/bash
user19:x:3020:3020::/home/user19:/bin/bash

14、在/tmp/创建10个空文件file10-file19;

#!/bin/bash
#

for i in {10..19};do
        touch /tmp/file$i && echo "file$i make  success"
done
#验证
[[email protected] tmp]# bash /bin/mkfile.sh 
file10 make  success
file11 make  success
file12 make  success
file13 make  success
file14 make  success
file15 make  success
file16 make  success
file17 make  success
file18 make  success
file19 make  success
[[email protected] tmp]# ls /tmp/
etc.test  file12  file15  file18     grub.conf
file10    file13  file16  file19     testdir-201608281853
file11    file14  file17

15、把file10的属主和属组改为user10,依次类推。

#!/bin/bash
#
for i in {10..19};do
        chown user$i:user$i /tmp/file$i && echo "file$i‘s owner and group mddify success!"
done
#验证:
[[email protected] tmp]# bash /bin/changemode.sh
file10‘s owner and group mddify success!
file11‘s owner and group mddify success!
file12‘s owner and group mddify success!
file13‘s owner and group mddify success!
file14‘s owner and group mddify success!
file15‘s owner and group mddify success!
file16‘s owner and group mddify success!
file17‘s owner and group mddify success!
file18‘s owner and group mddify success!
file19‘s owner and group mddify success!
[[email protected] tmp]# ls -l /tmp/file1*
-rw-r--r--. 1 user10 user10 0 Aug 28 19:31 /tmp/file10
-rw-r--r--. 1 user11 user11 0 Aug 28 19:31 /tmp/file11
-rw-r--r--. 1 user12 user12 0 Aug 28 19:31 /tmp/file12
-rw-r--r--. 1 user13 user13 0 Aug 28 19:31 /tmp/file13
-rw-r--r--. 1 user14 user14 0 Aug 28 19:31 /tmp/file14
-rw-r--r--. 1 user15 user15 0 Aug 28 19:31 /tmp/file15
-rw-r--r--. 1 user16 user16 0 Aug 28 19:31 /tmp/file16
-rw-r--r--. 1 user17 user17 0 Aug 28 19:31 /tmp/file17
-rw-r--r--. 1 user18 user18 0 Aug 28 19:31 /tmp/file18
-rw-r--r--. 1 user19 user19 0 Aug 28 19:31 /tmp/file19
时间: 2024-08-27 16:55:24

第六周作业的相关文章

机电传动控制第六周作业

关于<机电传动控制>和其他课程的联系的感悟: 1.电机原理部分与之前学的<电路原理>和<大学物理>课程有较大关系,主要体现在定子电路转子电路和控制电路的分析上,电路分析的基尔霍夫定律和电磁学的电子转换麦克斯韦方程对理解和分析电机原理电路有相当大的帮助. 2.电机控制部分与<模拟电路技术>中学到的三相电的特性和星形三角形连接有一定联系. 3.PLC部分与<数控技术>和<数字电路技术>两门课程有很多联系.数电中学到的逻辑变换与逻辑电路能帮

机电传动控制第六周学习笔记——《机电传动控制》和其他课程的联系

机电传动控制就目前学习的情况来看电学方面的东西比较多,但是与其他非电类的课程也有很多联系. 1.电机原理的部分主要是和基础物理学里面的内容有很大关系,比如电磁感应,楞次定律等等,从基础的物理原理讲起: 2.进入控制部分以后我们见到了很多电机,建模的时候有数学建模的思想,利用自定义的参数的变化得到电机随时间的运行状况仿真,并通过探讨这些参数的敏感性牺牲不敏感参数找到整体的最优解: 3.编程的思想和C语言很类似.逻辑性和面向过程编程都很重要: 4.控制时使用的继电器-接触器控制电路与电路的分析很类似

机电传动控制第八周作业

一.交通灯控制 梯形图如上,经过与同学讨论修改. 二.传送带控制

机电传动控制第五周作业

应用兴趣点:日常生活中,洗衣机的电机,如何控制噪声,还有工作电机的类型,调速和电机相关的工作状态,想深入了解工作电机.  冰箱中需要几个电机控制其正常工作,关于制冷电机的工作特性并想深入了解.  汽车中的自动调节座位功能和自动调节车窗需要的电机要多少,还有需不需要同时工作,及工作状态的变化.  水泵中用的电机也较感兴趣,它的控制原理,还有效率怎么控制,想知道有没有什么方式来提高它的工作性能如效率.  还有如光盘驱动,打印机所需的电机怎么控制高精度的加工,一些工作特性,想深入了解精度提升的方式和创

《机电传动控制》第二周作业

1.  对电机发展史的感悟 电机的发明起始于19世纪上叶,那时人们对其中的物理原理还不是很清楚,他们甚至认为发电机和电动机是两种不同完全的东西,但却对电机的应用有着深刻的理解,后来随着一代一代科学家的努力,电机的结构和功效得到了极大的突破,人们也从直流电的时代跨越到了交流电的时代.说起直流电和交流电,就不得不提及爱迪生和特斯拉,或许我们大多数人都知道爱迪生,对特斯拉却知之甚少,其实论起发明创造他们两个不分伯仲,而且特斯拉比爱迪生有更长远的科学眼光. 他们的故事要从1884年说起,这一年,特斯拉第

机电传动控制第四周仿真作业

机电传动控制第四周仿真作业 题目要求: 结合本周学习的交流电机原理及启动.调速.制动特性,用Modelica设计和仿真一个用三相交流异步电机带动起重机起升机构运行.具体要求如下: 1)实现如下机械运动周期: 控制电机带重物上升,从静止加速到800r/min 保持800r/min匀速运动0.5s, 减速到静止,保持静止状态0.5s, 带重物下降,从静止达到600r/min 保持600r/min匀速运动0.6s, 减速到静止. (为了便于仿真,匀速和静止持续时间较短) 2) 升降机构和重物折算到到电

机电传动控制课程第一周学习笔记

机电传动课程第一周学习笔记 本周的学习内容主要是第一章绪论和第二章机电传动系统的动力学基础,结合课程学习和预习复习回顾内容如下: 1.绪论:学习了机电传动控制目的与任务.发展历程和我们该如何学习这门课程. 2.机电传动系统的动力学基础: a.运动方程式:对于单一拖动系统或者多拖动系统,在分析时一般都折算到一根轴(电动机轴)上,折算的基本原则是,折算前的多轴系统同折算后的单轴系统在能量关系上或功率关系上保持不变.而对于单 走拖动系统的运动方程式如下. b.判断TM/TL的符号:主要概括为三条:规定

机电传动控制直流调速作业

一.仿真测试: 本次作业对直流调速控制器进行设计,预期采用PID控制,控制器设计如下: 其仿真结果如下: 二.对控制器和结果做以下解释: 1.控制器期初限定的10V输出限定对控制结果影响较大,使积分环节对振动的稳定作用变差: 2.微分环节引入反而使电流曲线更为尖锐,过渡曲线不平滑,因此放弃微分环节: 3.结果显示响应较快,但不够平滑,速度曲线变化不大,超调量很小.

《机电传动控制》第一周笔记

知识要点: 1.1 术语与概念 1.1.1 控制与调节 引入了输入量u,输出量v,被调量x,基准量w,调节差e等概念,并用工作原理图表示它们之间的函数关系,即相应传递环节的传递特性.其中控制与调节的区别在于控制属于开环作用路径,调节则属于闭环作用路径. 1.1.2 调节信号回路 调节或控制所使用的信号,分为模拟信号,数字信号和二进制信号. 模拟信号:连续的取值范围,时间是连续/不连续的,数值变化过程是连续/不连续的. 数字信号:有限数量的离散取值范围,时间是连续/不连续的,数值变化过程始终是不连

机电传动控制第八周——PLC仿真练手

一.交通灯控制 控制的要求是“打开SW1开关后,交通灯控制器开始工作”和“SW2为控制开关”,整个过程中只有一个给行人用的按钮,SW1(X024)和SW2(X025)都不是按钮,所以启动的时候采用了X024的上升沿和X025的上升下降沿控制. 最上面的一部分是绿灯(Y002)的控制,有X025常闭触点串接的支路是白天模式,X025常开串接的支路对应夜间模式,一开始的时候白天于夜间的部分我是分开写的,但是后来发现Y002等等线圈在同一时刻只能有一个确定的状态,不能在白天模式的灯是亮的而夜间模式的没