最全的Linux教程,Linux从入门到精通
======================
-
linux从入门到精通(第2版)
-
Linux系统移植
-
Linux驱动开发入门与实战
-
LINUX 系统移植 第2版
-
Linux开源网络全栈详解 从DPDK到OpenFlow
第一份《Linux从入门到精通》466页
====================
内容简介
====
本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。
本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。
需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
3.再添加一个定时任务
[09:55 root@m01 ~]# ansible all -m cron -a ‘name=“guoav-date” minute=“*/30” job=“/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1”’
4.把此定时任务删除:
[09:55 root@m01 ~]# ansible all -m cron -a ‘name=“guoav-date” state=absent’
查看一下
[09:56 root@m01 ~]# ansible all -a ‘crontab -l’
5.再添加一个定时任务
[09:57 root@m01 ~]# ansible all -m cron -a ‘name=“guoav-date” minute=“*/30” job=“/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1”’
6.给定时任务添加注释:
[10:00 root@m01 ~]# ansible all -m cron -a ‘name=“guoav-date” minute=“*/30” job=“/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1” disabled=yes’
查看一下
[10:00 root@m01 ~]# ansible all -a ‘crontab -l’
172.16.1.31 | CHANGED | rc=0 >>
#Ansible: guoav-date
#*/30 * * * * /sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1
7.取消注释:
[10:02 root@m01 ~]# ansible all -m cron -a ‘name=“guoav-date” minute=“*/30” job=“/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1” disabled=no’
查看一下
[10:02 root@m01 ~]# ansible all -a ‘crontab -l’
172.16.1.7 | CHANGED | rc=0 >>
#Ansible: guoav-date
*/30 * * * * /sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1
远程启动/关闭定时任务服务
---
## 二、mount 挂载模块
>
> ![](https://upload-images.jianshu.io/upload_images/16952149-b20647128165945e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
> ![](https://upload-images.jianshu.io/upload_images/16952149-62c0c3b6418e37be.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
>
>
>
1.首先保证nfs01客户端的nfs服务开启
[10:12 root@nfs01 ~]# systemctl is-active rpcbind
active
[10:13 root@nfs01 ~]# systemctl is-active nfs
active
2.将/nfs共享目录挂载到web01服务端上
[10:09 root@web01 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/nfs 172.16.1.0/24
/upload 172.16.1.0/24
[10:09 root@web01 ~]# mount -t nfs 172.16.1.31:/nfs/ /mnt/
[10:09 root@web01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.7G 18G 9% /
devtmpfs 476M 0 476M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.7M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 54% /boot
tmpfs 98M 0 98M 0% /run/user/0
172.16.1.31:/nfs 19G 1.7G 18G 9% /mnt
测试完把/mnt卸载掉:
umount /mnt
3.用ansible将/nfs挂载到web01上的/upload
>
> 1.查看挂载信息
> 2.挂载 state=mounted
> 3.查看
>
>
>
[10:27 root@m01 ~]# ansible 172.16.1.7 -a ‘showmount -e 172.16.1.31’
172.16.1.7 | CHANGED | rc=0 >>
Export list for 172.16.1.31:
/nfs 172.16.1.0/24
/upload 172.16.1.0/24
[10:26 root@m01 ~]# ansible 172.16.1.7 -m mount -a ‘fstype=nfs src=172.16.1.31:/nfs path=/upload state=mounted’
172.16.1.7 | CHANGED => {
“ansible_facts”: {
“discovered_interpreter_python”: “/usr/bin/python”
},
“changed”: true,
“dump”: “0”,
“fstab”: “/etc/fstab”,
“fstype”: “nfs”,
“name”: “/upload”,
“opts”: “defaults”,
“passno”: “0”,
“src”: “172.16.1.31:/nfs”
}
[10:26 root@m01 ~]# ansible 172.16.1.7 -a ‘df -h’
172.16.1.7 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
…
172.16.1.31:/nfs 19G 1.7G 18G 9% /upload
4.不挂载,只添加到fstab文件
>
> state=present
>
>
>
[10:46 root@m01 ~]# ansible 172.16.1.7 -m mount -a ‘fstype=nfs src=172.16.1.31:/date path=/tmp state=present’
5.卸载,会删除/etc/fstab
>
> state=absent
>
>
>
[11:04 root@m01 ~]# ansible 172.16.1.7 -m mount -a ’ src=172.16.1.31:/nfs path=/upload state=absent’
## 三、查看命令的返回值(命令执行是否成功)
>
> echo $?
> #查看命令的返回值 (命令执行是否成功)
> #返回0 正确 非0 错误
>
>
>
[11:21 root@m01 ~]# ls
10.0.0.61 anaconda-ks.cfg dead.letter hosts.txt put
[11:21 root@m01 ~]# echo $?
0 \命令执行成功
[11:21 root@m01 ~]# touch -p aaa.txt
touch: invalid option – ‘p’
Try ‘touch --help’ for more information.
[11:21 root@m01 ~]# echo $?
1 \命令执行失败
---
---
## ※四、palybook剧本 ※
>
> 不会先看图:
>
>
>
![image.png](https://upload-images.jianshu.io/upload_images/16952149-41db5d3366d663cf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
### playbook的优势:
![image.png](https://upload-images.jianshu.io/upload_images/16952149-a06f90a708d09ccf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
### 1.playbook剧本初体验:
| 1.书写剧本 |
| --- |
| 2.检查剧本 |
| 3.执行剧本 |
>
> ##### 1.创建一个递归目录 名称注释为guoav
>
>
>
[1:43 root@m01 /etc/ansible]# vim touch.yml
▽
- hosts: all
tasks:- name: make guoav
command: mkdir -p /tmp/a/b/c/d/e/f/g/
- name: make guoav
>
> ##### 2.命令示范:
>
>
>
>
> ##### 3.playbook检查或执行的显示过程我们可以自己设置:
>
>
>
可以安装cowsay(奶牛说) yum install -y cowsay
>
> 也可以改为直观的显示过程:如下取消注释
> vim /etc/ansible/ansible.cfg ![](https://upload-images.jianshu.io/upload_images/16952149-f511c7d2b0a003ae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
>
>
>
#### 检查剧本:
>
> ##### ansible-playbook -C touch.yml
>
>
>
[11:49 root@m01 /etc/ansible]# ansible-playbook -C touch.yml
PLAY [all] ***********************************************************************
TASK [Gathering Facts] ***********************************************************
ok: [172.16.1.31]
ok: [172.16.1.7]
ok: [172.16.1.41]
TASK [make guoav] ****************************************************************
skipping: [172.16.1.41]
skipping: [172.16.1.31]
skipping: [172.16.1.7]
PLAY RECAP ***********************************************************************
172.16.1.31 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
172.16.1.41 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
172.16.1.7 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
#### 3.执行剧本
>
> ###### ansible-playbook touch.yml
>
>
>
[11:45 root@m01 /etc/ansible]# ansible-playbook touch.yml
PLAY [all] ******************************************************************************************
TASK [Gathering Facts] ******************************************************************************
ok: [172.16.1.31]
ok: [172.16.1.7]
ok: [172.16.1.41]
TASK [make guoav] ***********************************************************************************
[WARNING]: Consider using the file module with state=directory rather than running ‘mkdir’. If you
need to use command because file is insufficient you can add ‘warn: false’ to this command task or
set ‘command_warnings=False’ in ansible.cfg to get rid of this message.
changed: [172.16.1.7]
changed: [172.16.1.31]
changed: [172.16.1.41]
PLAY RECAP ******************************************************************************************
172.16.1.31 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.16.1.41 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.16.1.7 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
![](https://img-blog.csdnimg.cn/img_convert/9a8cb5f8c0ec69e6499adead0da6e95b.png)
最全的Linux教程,Linux从入门到精通
======================
1. **linux从入门到精通(第2版)**
2. **Linux系统移植**
3. **Linux驱动开发入门与实战**
4. **LINUX 系统移植 第2版**
5. **Linux开源网络全栈详解 从DPDK到OpenFlow**
![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/59742364bb1338737fe2d315a9e2ec54.png)
第一份《Linux从入门到精通》466页
====================
内容简介
====
本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。
![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/9d4aefb6a92edea27b825e59aa1f2c54.png)
**本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。**
> 需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化的资料的朋友,可以点击这里获取!](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**