10/21.22 练习题
来源:互联网 发布:淘宝怀轩旗舰店真假 编辑:程序博客网 时间:2024/05/17 06:07
复习部分:
1、查看80天以前的日期,重定向到文件/mnt/datafile,并查看80天以后的日期,追加到文件/mnt/datafile。
2、配置vim的配置文件,使其拥有以下功能:显示行号、鼠标可以操纵光标位置。
vim /etc/virmc //修改vim的配置文件
3、新建用户redhat,用户说明为“redhat User”,并设置密码为redhat,该用户首次登陆需修改密码。
[root@foudation7 ~]# useradd redhat //创建用户
[root@foudation7 ~]# password redhat //设置密码
bash: password: command not found...
[root@foudation7 ~]# passwd redhat
Changing password for user redhat.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@foudation7 ~]# usermod -c "redhat User" redhat //设置用户说明“redhat User”
[root@foudation7 ~]# chage -d 0 redhat //修改使得首次登陆需要修改秘密
[kiosk@foudation7 ~]$ su - redhatsystemctl restart network
Password:
You are required to change your password immediately (root enforced) //提示修改密码
Changing password for redhat.
(current) UNIX password:
4、给redhat用户授权,可无密码创建用户westos,指定uid=1008,gid=1008,但不能删除westos用户。
[root@foudation7 ~]$ hostname //查询我本台主机的名字
[root@foudation7 ~]# visudo //编写配置文件
redhat foudation7.example.com=(root) NOPASSWD:/usr/sbin/useradd//在配置文件中写入这个内容允许redhat以root用户身份执行useradd命令并且不需要密码
[root@foudation7 ~]# groupadd 1008 //创建组
[root@foudation7 ~]# su - redhat //切换到redhat用户用户
[redhat@foudation7 ~]# sudo useradd westos -u 1008 -g 1008// 创建用户westos,指定uid=1008,gid=1008
5、找出cpu使用量排在前五的pid,并重定向到文件/mnt/pidfile中。
[root@foudation7 ~]# ps ax -o %cpu,pid --sort -%cpu| head -6 |grep PID -v
1.1 2914
0.7 2382
0.6 3550
0.3 3599
0.2 3102
[root@foudation7 ~]# ps ax -o pid --sort -%cpu| head -6 >>/mnt/pidfile
6、打包压缩/mnt下的文件为tar.gz格式,并无密码发送到真机kiosk用户的桌面,不忽略链接文件。
1.tar cvf /mnt/mnt.tar /mnt/ //将/mnt/的东西打包压缩放到/mnt/下 名字为mnt.tar
2.[kiosk@foudation7 ~]$ ssh-keygen //为kiosk用户生成key认证方式
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kiosk/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kiosk/.ssh/id_rsa.
Your public key has been saved in /home/kiosk/.ssh/id_rsa.pub.
The key fingerprint is:
2d:18:ca:59:0c:da:4f:3a:18:48:87:4c:a8:5c:18:3c kiosk@foudation7.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|=++.. |
|oE.+ o |
|+ = . = |
|.. + B o . |
| . * o S . |
| . . |
| |
| |
| |
+-----------------+
[kiosk@foudation7 ~]$ cd /home/kiosk/.ssh/
[kiosk@foudation7 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
[kiosk@foudation7 .ssh]$ scp id_rsa root@172.25.254.24:/root/.ssh/ //把钥匙发给desktop
[kiosk@foudation7 .ssh]$ ssh-copy-id -i id_rsa.pub kiosk@172.25.254.7 //添加锁
在desktop里面 rsync -l /mnt/mnt.tar kiosk@172.25.254.7:/home/kiosk/Desktop //无密码发送到真机kiosk用户的桌面,不忽略链接文件
此次作业:
1、在server主机系统中创建set-ip-tool命令要求如下
*)会自动显示ifconfig命令的输出
*)系统ip被设定为:172.25.254.X
*)系统网关被设定为:172.25.254.250
*)系统dns被设定为:172.25.254.250
cd /bin/ //切换到bin目录下
vim set-ip-tool //编写一个set-ip-tool
实现效果如上
2、在虚拟机上安装Ubuntu操作系统,Redhat操作系统;
Redhat系统
(1)打开虚拟机管理器
(2)选择本地镜像
(3)选择本地镜像位置
(4)设置内存大小
(5)名称
(6)开始安装
(7)设置语言,选择最小化安装,手动配置分区
ubuntu系统
(1)打开虚拟机管理器
(2)选择镜像
3、搭建第三方yum仓库,可用yum安装google(自行上网搜软件包),wps-office软件。
[root@foundation90 software]# ls
google-chrome-stable_current_x86_64.rpm wps-office-9.1.0.4961-1.a18p1.x86_64.rpm
[root@foundation90 software]# createrepo -v /software/ ##扫描第三方库
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 1 pkgs
Spawning worker 2 with 0 pkgs
Spawning worker 3 with 0 pkgs
Worker 0: reading google-chrome-stable_current_x86_64.rpm
Worker 1: reading wps-office-9.1.0.4961-1.a18p1.x86_64.rpm
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Starting other db creation: Wed Oct 25 10:30:25 2017
Ending other db creation: Wed Oct 25 10:30:25 2017
Starting filelists db creation: Wed Oct 25 10:30:25 2017
Ending filelists db creation: Wed Oct 25 10:30:25 2017
Starting primary db creation: Wed Oct 25 10:30:25 2017
Ending primary db creation: Wed Oct 25 10:30:26 2017
Sqlite DBs complete
[root@foundation90 software]# ls
google-chrome-stable_current_x86_64.rpm repodata wps-office-9.1.0.4961-1.a18p1.x86_64.rpm ##repodata 成功
[root@foundation90 software]# vim /etc/yum.repos.d/software.repo ##编写第三方repo文件
[root@foundation90 software]# cat /etc/yum.repos.d/software.repo
[westos]
name=westos
baseurl=file:///software
gpgcheck=0
[root@foundation90 software]# yum clean all ##清理yum缓存
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel-dvd smplayer westos
Cleaning up everything
[root@foundation90 software]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-dvd | 4.1 kB 00:00:00
smplayer | 2.9 kB 00:00:00
westos | 2.9 kB 00:00:00
(1/4): westos/primary_db | 5.0 kB 00:00:00
(2/4): rhel-dvd/group_gz | 136 kB 00:00:00
(3/4): smplayer/primary_db | 23 kB 00:00:00
(4/4): rhel-dvd/primary_db | 3.6 MB 00:00:00
repo id repo name status
rhel-dvd westos 4,620
smplayer smplayer 30
westos westos 2
repolist: 4,652 ##可以看到westos库,代表扫描到软件包
[root@foundation90 software]# yum search google
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
================================================================ N/S matched: google =================================================================
google-chrome-stable.x86_64 : Google Chrome
[root@foundation90 software]# yum search wps
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
================================================================== N/S matched: wps ==================================================================
wps-office.x86_64 : WPS Office Suite
Name and summary matches only, use "search all" for everything.
[root@foundation90 software]# yum install wps-office.x86_64 ##安装wps软件包
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package wps-office.x86_64 0:9.1.0.4961-1.a18p1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
wps-office x86_64 9.1.0.4961-1.a18p1 westos 64 M
Transaction Summary
======================================================================================================================================================
Install 1 Package
Total download size: 64 M
Installed size: 274 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wps-office-9.1.0.4961-1.a18p1.x86_64 1/1
Verifying : wps-office-9.1.0.4961-1.a18p1.x86_64 1/1
Installed:
wps-office.x86_64 0:9.1.0.4961-1.a18p1
Complete!
- 10/21.22 练习题
- 复习10:If练习题
- C++之练习题10
- shell 练习题 1-10
- shell 练习题 1-10
- 搜索练习题J-10
- python练习题 1-10
- Java练习题10
- 运维 10/14.15 练习题
- 2017-10-15练习题
- java练习题10
- C语言练习题(10)
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- GMIS 2017 大会杨琼演讲:人工智能+医疗——噱头,还是未来?
- 线程的优先级
- 【NOI2015 Day2】荷马史诗 huffman tree结构运用
- GMIS 2017大会俞凯演讲:迈向智能认知型对话交互
- GMIS 2017大会圆桌论坛:探索人工智能的应用场景及商业化
- 10/21.22 练习题
- 1024!程序员节快乐!
- Ubuntu下apt-get安装及卸载jdk
- GMIS 2017大会圆桌论坛:机器智能时代的全球化进程
- [BZOJ1050][HAOI2006]旅行comf(图论)
- GMIS 2017 Jean-Sebastien Cournoyer 演讲:加拿大,领先的人工智能枢纽的兴起
- 正则表达式
- GMIS 2017 大会刘维演讲:跨越国界,智能机器时代的全球化
- GMIS 2017大会Saman Farid演讲:人工智能时代创业者面对的挑战和机会