
《Linux就该这么学》是一本注重于实用性的Linux系统技术自学书籍,自基础篇公布后网站每天日常阅读量已经超过10000多人,25万多名忠实粉丝读者,是目前国内人气增速最快的IT书籍。您可以在本网站内免费在线阅读书籍的全部章节及最新内容,今后的进阶篇也将会一如既往免费、完整的提供给亲爱的读者们在线
能力说明:
掌握计算机基础知识,初步了解Linux系统特性、安装步骤以及基本命令和操作;具备计算机基础网络知识与数据通信基础知识。
暂时未有相关云产品技术能力~
阿里云技能认证
详细说明tail命令将每个文件的最后10行打印到标准输出。对于多个文件,在每个文件前面加上一个给出文件名的头。如果没有文件,或者文件为-,则读取标准输入。 如何使用tail命令 使用tail命令查看yum.log日志文件,显示最后10行内容,tail默认显示问价你的最后10行内容: [root@localhost ~]# tail /var/log/yum.log May 26 15:22:08 Installed: pytalloc-2.1.16-1.el7.x86_64 May 26 15:22:08 Updated: libwbclient-4.10.4-11.el7_8.x86_64 May 26 15:22:08 Installed: samba-libs-4.10.4-11.el7_8.x86_64 May 26 15:22:08 Updated: samba-common-libs-4.10.4-11.el7_8.x86_64 May 26 15:22:08 Updated: samba-client-libs-4.10.4-11.el7_8.x86_64 May 26 15:22:08 Updated: libsmbclient-4.10.4-11.el7_8.x86_64 May 26 15:22:08 Installed: libarchive-3.1.2-14.el7_7.x86_64 May 26 15:22:09 Installed: samba-client-4.10.4-11.el7_8.x86_64 May 26 17:22:44 Installed: lm_sensors-libs-3.4.0-8.20160601gitf9185e5.el7.x86_64 May 26 17:22:44 Installed: sysstat-10.1.5-19.el7.x86_64 Linux中tail命令实例Linux中tail命令实例 如何显示指定的行数 使用-n命令显示指定的行数,也可以省略字母n,只使用-和数字(数字和-之间没有空格)。 例如:查看自己创建的用户,查看/etc/passwd文件最后两行内容: [root@localhost ~]# tail -2 /etc/passwd bob:x:1000:1001::/home/bob:/bin/bash user01:x:1001:1002::/home/user01:/bin/bash Linux中tail命令实例Linux中tail命令实例 如何实时监控文件的更改 如果需要监视文件内容的更改,使用-f选项。这个选项对于监视日志文件非常有用。例如,要显示/var/log/nginx/error.log文件的最后10行,并监视文件的更新: [root@localhost ~]# tail -f /var/log/messages Linux中tail命令实例Linux中tail命令实例 想要退出,请按Ctrl+C退出。 查看多个文件 如果提供了多个文件作为tail命令的输入,它将显示每个文件的最后十行。下面例子,使用tail命令显示/etc/passwd和/etc/shadow文件的最后两行内容: [root@localhost ~]# tail -n 2 /etc/passwd /etc/shadow ==> /etc/passwd <== bob:x:1000:1001::/home/bob:/bin/bash user01:x:1001:1002::/home/user01:/bin/bash ==> /etc/shadow <== bob:!!:18333:0:99999:7::: user01:$6$qPoy4v75$jzkBdrR.1L5G1sIs34GXRWa43fej.CLgaWKO9WRGkYcrUSVmVBGfcmOjn1Kc8FgcwVv2abac7t/m3crt2Vu8G.:18335:0:99999:7::: Linux中tail命令实例Linux中tail命令实例 tail命令和其他命令一起使用 例如,要实时监视apache访问日志文件并显示包含IP地址192.168.43.157的行,可以使用: [root@localhost ~]# tail -f /var/log/httpd/access_log |grep 192.168.43.157 192.168.43.157 - - [28/May/2020:14:56:31 +0800] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0" 192.168.43.157 - - [28/May/2020:14:56:41 +0800] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0" 192.168.43.157 - - [28/May/2020:14:56:41 +0800] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0" 192.168.43.157 - - [28/May/2020:14:56:41 +0800] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0" Linux中tail命令实例Linux中tail命令实例 总结 tail命令将每个文件的最后10行打印到标准输出。对于多个文件,在每个文件前面加上一个给出文件名的头。
在大小写之间转换文本可能非常繁琐,幸运的是Linux提供了一些命令,这些命令可以使工作变得非常简单。 环境 Centos7 使用tr 如果有一个字符串要确保全部是大写的,只需通过tr命令替换: [root@localhost ~]# echo "Hello World" | tr [:lower:] [:upper:] HELLO WORLD 下面是在脚本中使用此命令的示例,需要确保添加到文件中的所有文本都是大写,以保持一致性: !/bin/bash read -p "Enter department name: " dept echo $dept | tr [:lower:] [:upper:] >> depts 将顺序切换为[:upper:] [:lower:]会会将所有大写字符转换成小写: #!/bin/bash read -p "Enter department name: " dept echo $dept | tr [:upper:] [:lower:] >> depts 也可以使用”a-z” “A-Z”来替换大小写。 !/bin/bash read -p "Enter department name: " dept echo $dept | tr a-z A-Z>> depts 下面几个函数是tr内置的: [:alnum:] 所有字母和数字 [:alpha:] 所有字母 [:blank:] 所有空白 [:cntrl:] 所有控制字符 [:digit:] 所有数字 [:graph:] 所有可打印字符,不包括空格 [:lower:] 所有小写字符 [:print:] 所有可打印字符,包括空格 [:punct:] 所有的标点符号 [:upper:] 所有大写字符 使用awk 在awk中可以使用toupper()和tolower()函数,来转换大小写。 下面实例内容在文本里面写入,将输入的小写内容转换为大写: #!/bin/bash read -p "Enter department name: " dept echo $dept | awk ‘{print toupper($0)}’ >> depts 下面实例内容在文本里面写入,将输入的大写内容转换为小写: #!/bin/bash read -p "Enter department name: " dept echo $dept | awk ‘{print tolower($0)}’ >> depts 使用sed 在sed中可以使用\U&和\L&函数,来转换大小写。 使用sed,将小写转换成大写: #!/bin/bash read -p "Enter department name: " dept echo $dept | sed 's/[a-z]/\U&/g' >> depts 使用sed,将大写转换成小写: !/bin/bash read -p "Enter department name: " dept echo $dept | sed 's/[A-Z]/\L&/g' >> depts 总结 在linux中有很多方式可以替换大小写字母,你可以选择一个能记住的命令使用。
Lynis是Unix/Linux等操作系统的一款安全审计工具,它可以发现基于Linux系统中的恶意软件和安全漏洞。Lynis是免费开源的服务器审计工具,一旦审计完成,我们可以审查结果、警告和建议,然后我们可以根据它实现我们的安全策略。它将显示一个报告,该报告可以被分成几个部分。 通常我们在Linux服务器上运行很多东西,比如网络服务、数据库服务、电子邮件服务、FTP服务等等。通过在所有Linux机器上进行自动的安全审计和渗透测试,Lynis可以简化管理员的工作。 环境 Centos8 lynis-3.0.0 安装Lynix Lynis是一款轻量级的软件,它不会破坏系统,也不会影响Linux系统上的任何应用程序或服务。首先,我们将为Lynis的安装创建一个目录,进入该目录,wget下载最新的Lynis源代码: [root@localhost ~]# mkdir /usr/local/lynis [root@localhost ~]# cd /usr/local/lynis/ [root@localhost lynis]# wget https://downloads.cisofy.com/lynis/lynis-3.0.0.tar.gz Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 解压压缩包,进入解压出来的目录 [root@localhost lynis]# tar xvf lynis-3.0.0.tar.gz [root@localhost lynis]# cd lynis 运行lynis显示帮助信息。具有管理员权限的用户可以运行该脚本,所有日志和输出将保存在/var/log/lynis.log文件中: [root@localhost lynis]# ./lynis Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 开始审计并查找漏洞 执行本地安全扫描,所以使用‘audit system’参数来扫描整个系统。运行下面的命令来启动对整个系统的审计: [root@localhost lynis]# ./lynis audit system 或者 [root@localhost lynis]# ./lynis audit system --wait --wait选项:等待用户按回车键显示下一节的报告。 有时我们不想扫描或审计整个系统的应用程序或服务,所以我们可以按类别审计自定义应用程序。我们可以先列出所有的组,然后选择需要审计或扫描的组。 [root@localhost lynis]# ./lynis show groups Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 现在我们将对"kernel"和"firewalls"进行简单的审计,我们将使用下面的命令。 [root@localhost lynis]# ./lynis --tests-from-group "kernel firewalls" Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 Lynis – 用于Linux服务器的自动安全审计工具Lynis – 用于Linux服务器的自动安全审计工具 要查看更多的lynis命令选项,请参考它的手册页: [root@localhost lynis]# ./lynis --man 总结 Lynis是Unix/Linux等操作系统的一款安全审计工具,它可以发现基于Linux系统中的恶意软件和安全漏洞。
Tee命令是一个命令行工具,它从标准输入读取数据,同时将结果打印到文件中和标准输出到屏幕中。Tee 命令语法tee 选项 文件名实例一:基本方式tee命令的主要功能是显示命令的输出并将其保存到一个文件中。在下面的示例中,我们检查系统中的块设备并将结果发送到tee命令,tee命令将输出显示到终端,同时将其保存在devices.txt的文件中: [root@localhost ~]# lsblk | tee devices.txtTee命令的几个使用实例Tee命令的几个使用实例可以使用cat命令检查devices.txt文件的内容,如下所示: [root@localhost ~]# cat devices.txt Tee命令的几个使用实例Tee命令的几个使用实例 实例二:命令输出写入多个文件此外,可以将命令的输出写入多个文件,用空格分隔。如下所示: [root@localhost ~]# hostnamectl | tee file1.txt file2.txtTee命令的几个使用实例Tee命令的几个使用实例我们调用了hostnamectl命令来打印系统的主机名以及其他详细信息,并将标准输出保存为两个文件file1.txt和file2.txt 使用cat命令查看file1.txt和file2.txt:Tee命令的几个使用实例Tee命令的几个使用实例 实例三:静默输出到文件如果你想隐藏或禁止tee命令在屏幕上打印输出,那么将输出重定向到/dev/null,如下所示: [root@localhost ~]# df -Th | tee file4.txt > /dev/nullTee命令的几个使用实例Tee命令的几个使用实例 实例四:在文件中追加输出默认情况下,tee命令覆盖文件的内容。若要追加输出并防止擦除当前内容,请使用-a或--append选项。 [root@localhost ~]# lsblk | tee file1.txt[root@localhost ~]# date | tee -a file1.txt [root@localhost ~]# cat file1.txt Tee命令的几个使用实例Tee命令的几个使用实例上面命令中,第一条命令时将内容输出到file1.txt,第二条命令tee命令加上了-a选项,就可以追加内容到file1.txt里面了,第三条命令用cat查看file1.txt,发现上面两条命令输出的内容都保存下来了。 实例五:tee命令和sudo一起使用假设只可以用一个sudo用户,希望写入root用户拥有权限的文件。任何提升操作都需要在命令之前调用sudo用户。要实现这一点,只需在tee命令前面加上sudo,如下所示: [bob@localhost ~]$ echo "10.200.50.20 db-01" | sudo tee -a /etc/hosts/Tee命令的几个使用实例Tee命令的几个使用实例 实例六:将一个命令的输出重定向到另一个命令使用tee命令,我们可以将一个命令的输出重定向到另一个命令。这里,第一个命令的输出将作为第二个命令的输入。示例如下: [root@localhost ~]# grep 'root' /etc/passwd | tee /tmp/passwd.tmp | wc -l2[root@localhost ~]# cat /tmp/passwd.tmp root:x:0:0:root:/root:/bin/bashoperator:x:11:0:operator:/root:/sbin/nologin[root@localhost ~]# Tee命令的几个使用实例Tee命令的几个使用实例 实例七:在vim编辑器中使用tee假设你是一个非root用户,你正在修改root用户拥有的文件,忘记使用sudo权限打开文件,现在你想保存更改,示例如下: [bob@localhost ~]$ vim /etc/hostsTee命令的几个使用实例Tee命令的几个使用实例现在要将更改保存到vim编辑器中的/etc/hosts文件,请运行: :w !sudo tee %Tee命令的几个使用实例Tee命令的几个使用实例上面提示输入用户的密码,输入完成之后即可保存成功。 总结Tee命令是一个命令行工具,它从标准输入读取数据,同时将结果打印到文件中和标准输出到屏幕中。
本篇文章介绍如何在CentOS8 Linux操作系统中安装Xfce桌面环境和LightDM(Light Display Manager)。在Centos8中使用epel-release软件源安装Xfce4桌面时,发现安装之后的桌面是Gnome3的,许多xfce的工具打不开。所以研究了几天,通过Fedora28 Server版本的系统中,下载安装包拷贝到Centos8中,可以安装成功,在此记录一下安装过程。Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面 环境CentOS Linux release 8.2.2004 (Core) 、CentOS Linux release 8.0.1905 (Core) 安装xfce4这里使用的xfce4相关的安装包都是从Fedora28系统中下载的,装在Centos8中或许有些不稳定,目前发现装上之后Firewalld有问题,如果不妨碍使用,可以禁用Firewalld。 生产环境就不要这样玩了,本实验纯属测试一下而已。 Xfce4相关的安装包我已经放在网盘里了:https://share.weiyun.com/VqEEZio1, 下载到本地,然后上传到Centos8中。 安装lrzsz,将下载好的 压缩包上传到系统中。 [root@localhost ~]# dnf -y install lrzsz tar[root@localhost ~]# rz 解压文件,并进入文件夹,开始安装 [root@localhost ~]# tar xvf Xfce_fd28.tar.gz [root@localhost ~]# cd Xfce[root@localhost Xfce]# dnf install -y * --skip-broken --nobest Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面 Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面 设置开机启动到图形界面 开机启动lightdm显示管理器 [root@localhost ~]# systemctl enable lightdm 默认启动图形界面 [root@localhost ~]# systemctl set-default graphical.target Removed /etc/systemd/system/default.target.Created symlink /etc/systemd/system/default.target ¡ú /usr/lib/systemd/system/graphical.target.关闭防火墙[root@localhost ~]# systemctl disable firewalldRemoved /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.设置中文显示安装中文: [root@localhost ~]# yum -y install wqy* glibc-langpack-zh修改/etc/locale.conf: [root@localhost ~]# sed -i 's/en_US/zh_CN/' /etc/locale.conf [root@localhost ~]# cat /etc/locale.confLANG="zh_CN.UTF-8"重启一下系统,进入桌面看一下吧:Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面登录界面 Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面使用默认配置 Centos8如何安装Xfce桌面Centos8如何安装Xfce桌面到此已经安装完成了!总结本篇文章介绍如何在CentOS8 Linux操作系统中安装Xfce桌面环境和LightDM(Light Display Manager)。
Arch Linux是一个通用的滚动发行版Linux,一旦系统或者软件有新版本发布,你就可以升级它们。深受DIY爱好者和Linux核心用户的欢迎。默认安装只覆盖最小的基本系统,并希望用户自行配置系统。这就是为什么安装Arch Linux本身就是一个挑战,但同时,它也是中级Linux用户的一个学习机会。环境VMware Workstation 15.0 Arch Linux 2020.05 如何下载ArchLinux查看最新版本的系统:http://mirrors.163.com/archlinux/iso/latest/ 下载地址:http://mirrors.163.com/archlinux/iso/latest/archlinux-2020.05.01-x86_64.iso 虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 创建Arch Linux虚拟机虚拟机的版本可以选择“其他…”虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 安装操作系统引导界面,选择第一项虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统启动之后,可以看到,进入了Live环境。虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 检查一下是否连接到因特网检查一下网卡是否获取到IP地址了: root@archiso ~ # ip ad 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:83:ed:00 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.43.154/24 brd 192.168.43.255 scope global dynamic noprefixroute ens33 valid_lft 1706sec preferred_lft 1481sec inet6 fe80::456b:5cf2:4baa:efd8/64 scope link valid_lft forever preferred_lft forever 然后ping一下外部网络试试,能否上网: root@archiso ~ # ping www.baidu.comPING www.a.shifen.com (180.101.49.12) 56(84) bytes of data.64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=128 time=20.3 ms64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=128 time=20.5 ms^C--- www.a.shifen.com ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 20.252/20.391/20.531/0.139 ms如果可以上网,就进行下一步吧! 创建分区在这里我们分两个区,分别为: swap :512MB/ :剩余所有空间sda磁盘总容量为20GB。 root@archiso ~ # fdisk -l虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统创建分区:虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 格式化分区,并挂载分区/dev/sda1分区,创建swap分区,并且启用。 root@archiso ~ # mkswap /dev/sda1Setting up swapspace version 1, size = 488 MiB (511700992 bytes)no label, UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3root@archiso ~ # swapon /dev/sda1虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统格式化sda2分区为xfs文件系统,并且挂载分区到/mnt目录: root@archiso ~ # mkfs.xfs /dev/sda2root@archiso ~ # mount /dev/sda2 /mnt虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 修改镜像源进入/etc/pacman.d目录,修改mirrorlist文件,默认情况下,mirrorlist文件里面包含了许多源地址,这样会导致下载程序包速度很慢,我们只需要启用中国的源地址就可以: root@archiso ~ # cd /etc/pacman.d root@archiso /etc/pacman.d # lltotal 25drwxr-xr-x 4 root root 320 May 6 2020 gnupg-rw-r--r-- 1 root root 495 May 6 2020 mirrorlistroot@archiso /etc/pacman.d # mv mirrorlist mirrorlist.backroot@archiso /etc/pacman.d # cat mirrorlist.back | grep -A1 China | grep -v '-' > mirrorlist虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 安装必须软件包root@archiso ~ # pacstrap /mnt base linux linux-firmware dhcpcd vim openssh xfsprogs man net-tools生成fstab文件使用genfstab命令生成配置文件。-U命令用来设置UUID。 root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab root@archiso ~ # cat !$cat /mnt/etc/fstab Static information about the filesystems. See fstab(5) for details. /dev/sda2 UUID=ed6bd242-34fe-43b6-bb0a-08af6cdb28e8 / xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 1 /dev/sda1 UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3 none swap defaults 0 0root@archiso ~ #可以看到swap分区和/分区都已经写入fstab配置文件了。 更改根目录root@archiso ~ # arch-chroot /mnt [root@archiso /]#更改时区更改时区为亚洲、上海。并同步时间到硬件时间。 [root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime[root@archiso /]# hwclock -w设置本地化文本编码编辑/etc/locale.gen添加如下内容: [root@archiso /]# echo “en_US.UTF-8 UTF-8” >> /etc/locale.gen[root@archiso /]# echo LANG=en_US.UTF-8 > /etc/locale.conf设置root密码[root@Archone /]# passwd rootNew password: Retype new password: passwd: password updated successfully[root@Archone /]#设置开机启动项[root@Archone /]# systemctl enable dhcpcd[root@Archone /]# systemctl enable sshd安装并配置grub2引导安装grub2 [root@Archone /]# pacman -S grub –noconfirm[root@Archone /]# grub-install /dev/sdaInstalling for i386-pc platform.Installation finished. No error reported.导出grub配置文件到/boot/grub/grub.cfg [root@Archone /]# grub-mkconfig -o /boot/grub/grub.cfg配置完成重启系统 [root@Archone /]# exitroot@archiso ~ # reboot可以看到,重启之后已经进入系统了。虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 修改ssh配置文件,允许root用户ssh登录发现使用root用户不能ssh远程登录系统,是因为配置文件里面没有允许root用户登录: [root@arch-one ~]# sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config[root@arch-one ~]# systemctl restart sshd这样就可以ssh远程登录服务器了。 安装Gnome桌面环境 安装提示信息,默认都回车即可。 [root@arch-one ~]# pacman -S xorg xorg-server gnome[root@arch-one ~]# systemctl enable gdm NetworkManagerCreated symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/gdm.service.Created symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service.Created symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service.Created symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service -> /usr/lib/systemd/system/NetworkManager-wait-online.service.重启操作系统 [root@arch-one ~]# reboot虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 虚拟机中如何安装Arch Linux操作系统虚拟机中如何安装Arch Linux操作系统 总结你可能已经意识到安装Arch Linux并不像安装Ubuntu那么容易。然而,只要有一点耐心,你就一定可以完成它。
Nmon是一款计算机性能系统监控工具,因为它免费,体积小,安装简单,耗费资源低,广泛应用于AIX和Linux系统Centos7部署nmon监控工具Centos7部署nmon监控工具 上传软件包[root@localhost tools]# wget http://sourceforge.net/projects/nmon/files/nmon16d_x86.tar.gz解压[root@localhost tools]# tar xf nmon16d_x86.tar.gz[root@localhost tools]# lsnmon_power_64le_ubuntu16 nmon_x86_64_linux nmon_x86_debian7 nmon_x86_macpuppy nmon_x86_rhel6nmon_power_64_linux nmon_x86_64_mint16 nmon_x86_debian8 nmon_x86_mint16 nmon_x86_sles12nmon16d_x86.tar.gz nmon_power_64_rhel6 nmon_x86_64_mint17 nmon_x86_fedora17 nmon_x86_mint17 nmon_x86_sles13nmon_power_32_linux nmon_power_64_rhel7 nmon_x86_64_opensuse13 nmon_x86_fedora18 nmon_x86_mint7 nmon_x86_tahrpuppynmon_power_32_rhel6 nmon_power_64_sles11 nmon_x86_64_rhel6 nmon_x86_fedora19 nmon_x86_mint8 nmon_x86_ubuntu10nmon_power_32_sles11 nmon_x86_64_centos6 nmon_x86_64_rhel7 nmon_x86_fedora20 nmon_x86_opensuse12 nmon_x86_ubuntu13nmon_power_64_kvm2 nmon_x86_64_centos7 nmon_x86_64_sles13 nmon_x86_fedora21 nmon_x86_opensuse13 nmon_x86_ubuntu15nmon_power_64le_fedora22 nmon_x86_64_debian6 nmon_x86_64_ubuntu13 nmon_x86_fedora22 nmon_x86_peppermint4 nmon_x86_ubuntu8nmon_power_64le_linux nmon_x86_64_debian8 nmon_x86_64_ubuntu15 nmon_x86_knoppix5 nmon_x86_precisepuppy nmon_x86_ubuntu9nmon_power_64le_rhel7 nmon_x86_64_fedora17 nmon_x86_centos6 nmon_x86_knoppix6 nmon_x86_puppy_GNU_2.0.0 nmon_x86_zorin6nmon_power_64le_ubuntu14 nmon_x86_64_fedora20 nmon_x86_debian5 nmon_x86_knoppix7 nmon_x86_puppy_GNU_2.6.15nmon_power_64le_ubuntu15 nmon_x86_64_fedora21 nmon_x86_debian6 nmon_x86_linux nmon_x86_puppy_GNU_2.6.24执行启动对应版本[root@localhost tools]# ./nmon_x86_64_centos7Centos7部署nmon监控工具Centos7部署nmon监控工具 测试按c查看cpu信息Centos7部署nmon监控工具Centos7部署nmon监控工具 按m 查看内存信息Centos7部署nmon监控工具Centos7部署nmon监控工具部署完成!
本文档以实战的形式介绍破解 MariaDB5.5 数据库的 root 登录密码忘记 root 登录密码[root@localhost ~]# mysql -uroot -p123 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)查找并运行 mysqld_safe 程序绕开 MariaDB5.5 数据库密码验证[root@localhost ~]# find / -name mysqld_safe/usr/bin/mysqld_safe[root@localhost ~]# /usr/bin/mysqld_safe --skip-grant-tables &直接使用 mysql 命令登录 MariaDB5.5 数据库并修改 root 登录密码[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or g.Your MariaDB connection id is 1Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]> show databases; Database information_schema mysql performance_schema 3 rows in set (0.00 sec) MariaDB [(none)]> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A Database changedMariaDB [mysql]> UPDATE user SET password=password("New-password") WHERE user='root';Query OK, 3 rows affected (0.00 sec)Rows matched: 3 Changed: 3 Warnings: 0 MariaDB [mysql]> flush privileges;Query OK, 0 rows affected (0.00 sec) MariaDB [mysql]> exitBye使用新密码 New-password 登录 MariaDB5.5 数据库[root@localhost ~]# ps auUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 3986 0.0 0.1 115380 2084 tty1 Ss+ 19:53 0:02 -bashroot 22483 0.0 0.1 115384 2076 pts/0 Ss 21:54 0:00 -bashroot 22910 0.0 0.0 113252 1592 pts/0 S 21:59 0:00 /bin/sh /usr/bin/mysqld_safe --skimysql 23066 0.3 4.6 839268 86192 pts/0 Sl 21:59 0:00 /usr/libexec/mysqld --basedir=/usrroot 23091 0.0 0.0 151056 1824 pts/0 R+ 22:00 0:00 ps au[root@localhost ~]# kill -9 22910[root@localhost ~]# mysql -uroot -pNew-passwordWelcome to the MariaDB monitor. Commands end with ; or g.Your MariaDB connection id is 2Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]> MariaDB [(none)]> show databases; Database information_schema mysql performance_schema 3 rows in set (0.00 sec) MariaDB [(none)]> exitBye[1]+ Killed /usr/bin/mysqld_safe --skip-grant-tables使用其他密码不能登录 MariaDB5.5 数据库[root@localhost ~]# mysql -uroot -pNew-passworddERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)[root@localhost ~]# rpm -qa mariadbmariadb-5.5.52-1.el7.x86_64总结以上就是破解 MariaDB5.5 数据库的 root 登录密码的实战方法,希望能帮助到大家。
本文档介绍检查Docker版本,重装Docker,给有需要有朋友提供参考。检查 Docker 版本[root@Docker ]# docker versionClient: Docker Engine - Community Version: 19.03.8 API version: 1.40 Go version: go1.12.17 Git commit: afacb8b Built: Wed Mar 11 01:27:04 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.8 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: afacb8b Built: Wed Mar 11 01:25:42 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683查看所有仓库中所有docker版本,并选择特定的版本安装[root@Docker ]# yum list docker-ce --showduplicates | sort -r updates: mirrors.aliyun.comLoading mirror speeds from cached hostfile Loaded plugins: fastestmirror extras: mirrors.ustc.edu.cn epel: hkg.mirror.rackspace.comdocker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stabledocker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stabledocker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable base: mirrors.aliyun.comAvailable Packages 重装 Docker安装 docker-ce-18.06.0.ce[root@Docker ]# yum remove docker docker-common docker-selinux docker-engine -y[root@Docker ]# yum install -y docker-ce-18.06.0.ce可能会遇到的报错 file /usr/share/zsh/vendor-completions/_docker from install of docker-ce-18.06.0.ce-3.el7.x86_64 conflicts with file from package docker-ce-cli-1:19.03.8-3.el7.x86_64 Error Summary解决方法卸载 docker-ce-cli-1:19.03.8-3.el7.x86_64 -y [root@Docker ]# yum erase docker-ce-cli-1:19.03.8-3.el7.x86_64 -y再次安装 docker-ce-18.06.0.ce [root@Docker ]# yum install -y docker-ce-18.06.0.ce[root@Docker ]# systemctl start docker[root@Docker ]# systemctl enable dockerCreated symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.[root@Docker ]# systemctl status docker● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/docker.service.d └─kolla.conf Active: active (running) since Mon 2020-03-30 14:25:00 EDT; 24s ago Docs: https://docs.docker.com Main PID: 21775 (dockerd) CGroup: /system.slice/docker.service ├─21775 /usr/bin/dockerd └─21782 docker-containerd --config /var/run/docker/containe... Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack dockerd[21775 ]: time="2020-0...Mar 30 14:25:00 openstack systemd[1 ]: Started Docker A...Hint: Some lines were ellipsized, use -l to show in full.查看 Docker 版本信息 [root@Docker ~]# docker --versionDocker version 18.06.0-ce, build 0ffa825[root@Docker ~]# docker version Client: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:08:18 2018 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.06.0-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:10:42 2018 OS/Arch: linux/amd64 Experimental: false总结至此,docker-ce-18.06.0.ce 安装成功!想看 Docker 后续操作的朋友,请持续关注我的文章,希望我的文章能给大家带来帮助。
本文档详细介绍破解 MySQL5.7 数据库的 root 登录密码忘记 root 登录密码[root@MySQL1 ~]# mysql -uroot -p1231234mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)在 /etc/my.cnf 配置文件中添加 skip-grant-tables 绕开 MySQL5.7 数据库密码验证[root@MySQL1 ~]# echo skip-grant-tables >> /etc/my.cnf[root@MySQL1 ~]# /etc/init.d/mysqld restartShutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! 直接使用 mysql 命令登录 MySQL5.7 数据库并修改 root 登录密码[root@MySQL1 ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.7.19-log Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its Other names may be trademarks of their respectiveowners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statementmysql> flush privileges;Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';Query OK, 0 rows affected (0.00 sec) mysql> quitBye 注意:如果在执行该步骤的时候出现 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 错误。则执行下 flush privileges; 命令,再执行该命令即可。 使用新密码 password 登录 MySQL5.7 数据库[root@MySQL1 ~]# mysql -uroot -ppasswordmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.7.19-log Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its Other names may be trademarks of their respectiveowners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> exitBye使用其他密码不能登录 MySQL5.7 数据库[root@MySQL1 ~]# mysql -uroot -ppassworddmysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)优化删掉 /etc/my.cnf 里的 skip-grant-tables[root@MySQL1 ~]# sed -i -e '/skip-grant-tables/d' /etc/my.cnf重启数据库[root@MySQL1 ~]# /etc/init.d/mysqld restart总结以上就是破解 MySQL5.7 数据库的 root 登录密码的方法,希望能给大家带来帮助。
对于许多与系统相关的任务和进程,使用正确的时区是必不可少的。例如,cron守护进程使用系统的时区执行cron作业,日志文件中的时间戳基于同一系统的时区。环境Centos8 检查现在的时区timedatectl是一个命令行实用程序,允许您查看和更改系统的时间和日期。 [root@localhost ~]# timedatectl Local time: Tue 2020-03-31 16:35:23 CST Universal time: Tue 2020-03-31 08:35:23 UTC RTC time: Tue 2020-03-31 08:35:23 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no Centos8如何更改时区Centos8如何更改时区 更改时区在更改时区之前,您需要找出要使用的时区名称。要列出所有可用时区,请使用下面的命令: [root@localhost ~]# timedatectl list-timezones…Asia/SamarkandAsia/SeoulAsia/ShanghaiAsia/SingaporeAsia/Srednekolymsk…然后使用set-timezone选项更改时区,比如更改为Europe/Berlin: [root@localhost ~]# timedatectl set-timezone Europe/BerlinCentos8如何更改时区Centos8如何更改时区 使用创建链接的方式更改时区如果运行的是旧版本的Centos,比如Centos6之前的版本,并且系统上不存在timedatectl命令,则可以通过将/etc/localtime符号链接到/usr/share/zoneinfo目录中的时区文件来更改时区。 查看一下/usr/share/zoninfo下面的时区文件, [root@localhost ~]# ls /usr/share/zoneinfo/[root@localhost ~]# ls /usr/share/zoneinfo/Asia/Centos8如何更改时区Centos8如何更改时区 Centos8如何更改时区Centos8如何更改时区现在替换时区文件。 [root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime[root@localhost ~]# dateTue Mar 31 16:53:59 CST 2020可以看到已经切换到了CST中国标准时间 总结在本文中,使用了两种方式修改时区。一种是使用timedatectl,另一种方式使用创建链接的方式。
Unison是一个跨平台的文件同步工具,它在同步计算机或存储设备之间的数据时非常有用。环境Centos7(1): 192.168.43.165Centos7(2): 192.168.43.166安装Unison在两个系统中都要安装epel源,然后都要安装unison: [root@192_168_43_165 ~]# yum -y install epel-release[root@192_168_43_165 ~]# yum makecache[root@192_168_43_165 ~]# yum -y install unison两台操作系统配置ssh免密登录[root@192_168_43_165 ~]# ssh-keygen 使用Unison 同步文件使用Unison 同步文件 [root@192_168_43_165 ~]# ssh-copy-id root@192.168.43.166[root@192_168_43_165 ~]# cd ~/.ssh[root@192_168_43_165 .ssh]# cat id_rsa.pub > authorized_keys[root@192_168_43_165 .ssh]# scp id_rsa root@192.168.43.166:/root/.ssh如何使用UnisonUnison用于将目录中的一组文件同步到结构相似的另一个位置,该位置可以是本地主机或远程主机。 本地文件同步在root家目录下面创建两个文件夹,一个是"Files",一个是"Backup"。Files里面创建文件,同步到Backup里面。 [root@192_168_43_165 ~]# mkdir Files Backup[root@192_168_43_165 ~]# cd Files/[root@192_168_43_165 Files]# touch file{1..10}.txt使用Unison 同步文件使用Unison 同步文件现在运行unison命令,同步文件到Backup文件夹里面。 [root@192_168_43_165 ~]# unison -batch /root/Files /root/Backup使用Unison 同步文件使用Unison 同步文件查看一下Backup文件夹,发现文件同步过来了。使用Unison 同步文件使用Unison 同步文件现在修改一下Backup文件夹里面的某个文件,然后再添加已给文件,最后执行一下刚才的命令,看看是否会同步到Files文件夹中: [root@192_168_43_165 Backup]# echo "testtesttest" > file2.txt [root@192_168_43_165 Backup]# echo 'hello world!' > index.html使用Unison 同步文件使用Unison 同步文件执行unison命令: [root@192_168_43_165 ~]# unison -batch /root/Files /root/Backup使用Unison 同步文件使用Unison 同步文件可以看到Backup文件夹里面的内容同步到Files里面了使用Unison 同步文件使用Unison 同步文件 远程文件同步如果需要进行远程文件同步,必须在本地和远程服务器上安装Unison。 下面现在两台服务器的root目录下面创建两个文件夹,为同步文件使用的。 在第一台服务器创建文件夹。 [root@192_168_43_165 ~]# mkdir Files 在第二台服务器创建文件夹。 [root@192_168_43_166 ~]# mkdir Files下面使用-testServer选项测试本地和远程服务器之间的连通性。 [root@192_168_43_165 ~]# unison -testServer /root/Files ssh://root@192.168.43.166//root/FilesContacting server...Connected [//192_168_43_165//root/Files -> //192_168_43_166//root/Files]使用Unison 同步文件使用Unison 同步文件连通性没问题之后,我们就可以执行命令同步文件了: [root@192_168_43_165 ~]# unison -batch /root/Files ssh://root@192.168.43.166//root/Files使用Unison 同步文件使用Unison 同步文件 使用Unison 同步文件使用Unison 同步文件查看第二台服务器上面的/root/Files文件夹,文件是否同步过来了:使用Unison 同步文件使用Unison 同步文件 总结Unison非常易于使用,不需要额外的精力。它可以在GUI以及命令行实用程序中使用任何一种方式进行自定义同步。如果需要使用图形界面,可以在桌面环境执行unison-gtk-2.40打开图形界面进行配置。
本文档以实战的形式介绍 RHEL7 禁止和开启 ping 的方法一、内核参数设置1、允许ping设置临时 echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all永久 echo net.ipv4.icmp_echo_ignore_all=0 >> /etc/sysctl.confsysctl -p # 执行这条命令使更改后的 /etc/sysctl.conf 配置文件生效注意:如果 /etc/sysctl.conf 配置文件里已经有 net.ipv4.icmp_echo_ignore_all 字段了,那么直接用 vim 进去更改对应的值即可。 2、禁止ping设置临时 echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all永久 echo net.ipv4.icmp_echo_ignore_all=1 >> /etc/sysctl.confsysctl -p # 执行这条命令使更改后的 /etc/sysctl.conf 配置文件生效注意:如果 /etc/sysctl.conf 配置文件里已经有 net.ipv4.icmp_echo_ignore_all 字段了,那么直接用 vim 进去更改对应的值即可。 二、防火墙设置注:使用以下方法的前提是内核配置是默认值,也就是内核没有禁ping 1、允许PING设置 iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT 2、禁止PING设置 iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP --icmp-type 8 echo request 表示回显请求(ping请求) 0/0 表示所有 IP 总结以上方法选择其中一种即可,希望能给大家带来帮助! 本文原创地址:https://www.linuxprobe.com/linux-forbid-ping.html编辑:public,审核员:逄增宝
在 Linux 中使用 mv 命令可以重命名或者移动文件及目录,但是它不支持一次重命名多个文件。本文介绍mmv的使用方式,使用通配符模式移动/复制/追加/链接多个文件环境Centos7.7 安装mmv在默认情况下,Centos7的网络源中没有mmv的安装包,我们需要先安装epel源,然后再安装mmv工具。 下载阿里云的epel源文件。 [root@localhost ~]# wget http://mirrors.aliyun.com/repo/epel-7.repo --directory-prefix=/etc/yum.repos.d 清楚yum缓存,并重新生成缓存 [root@localhost ~]# yum clean all && yum makecache 安装mmv [root@localhost ~]# yum -y install mmv使用mmv重命名文件实例实例一想删除重复的扩展名,例如扩展名是.rar.rar.rar,只保留一个.rar,可以使用如下命令:使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 [root@localhost test]# mmv '...' '#1.#2'使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称可以看到扩展名已经变成一个.rar了。是不是很方便。 实例二如果想要修改文件名和扩展名,但是不修改文件中的序号,可以这样做:使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 [root@localhost test]# mmv 'file*.rar' 'text#1.zip'使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 实例三将当前目录里面所有.jpeg格式的文件转换成.jpg格式:使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 [root@localhost test]# mmv '*.jpeg' '#1.jpg'使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 实例四将当前目录中的.html.cn,.html.en,.html.de修改为 cn.html,en.html,de.html使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 [root@localhost test]# mmv '*.html.??' '#1.#2#3.html'使用mmv命令批量修改文件名称使用mmv命令批量修改文件名称 解释Mmv后面第一个单引号里的参数叫做From,第二个单引号里面的参数叫做To。From中可以使用的通配符有*、?、[]、;。To中可以使用的通配符是#1,#2,#3…等。#号加数字形式,对应着From中的每一个通配符。 例如: [root@localhost test]# mmv '*.html.??' '#1.#2#3.html'这个例子中,From模式是'.html.??',To模式是 '#1.#2#3.html'。From模式中有三个通配符,,?,?。To模式中也对应着From模式#1,#2,#3。 总结想了解更多信息,可以查看手册# man mmv。
pigz(parallel implementation of gzip)是一个并行执行的压缩工具,解压缩比gzip快,同时CPU消耗是gzip的好几倍,在对短时间内CPU消耗较高不受影响的场景下,可以使用pigz。环境Centos7 RAM:2GB , CPU: 4vcpus 安装 安装epel扩展源 [root@localhost ~]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo[root@localhost ~]# yum makecache 安装pigz [root@localhost ~]# yum -y install pigz如何压缩文件下面几个是常用参数: -p n: 压缩时使用的核心数量,默认使用所有核心-k: 压缩后保留源文件-l: 列出压缩输入的内容。-6: 默认的压缩级别-9: 压缩率最高,但是速度慢-1: 压缩率最低,速度最快例如:压缩FreeNAS-11.2-U7.iso文件,如果需要保留源文件,可以添加-k参数: [root@localhost ~]# pigz -k FreeNAS-11.2-U7.iso Linux中使用pigz工具更快的压缩和解压文件Linux中使用pigz工具更快的压缩和解压文件可以使用-l选项查看压缩后文件的压缩率: [root@localhost ~]# pigz -l FreeNAS-11.2-U7.iso.gz compressed original reduced name 576426218 602378240 4.3% FreeNAS-11.2-U7.isoLinux中使用pigz工具更快的压缩和解压文件Linux中使用pigz工具更快的压缩和解压文件 如何压缩目录Pigz没有压缩文件夹的选项,只可以压缩单个文件。pigz可以和tar命令一起使用,来压缩文件夹。 [root@localhost ~]# tar -cvf - /var/log | pigz -k > logs.tar.gzLinux中使用pigz工具更快的压缩和解压文件Linux中使用pigz工具更快的压缩和解压文件查看一下压缩信息: [root@localhost ~]# pigz -l logs.tar.gz compressed original reduced name 698038 9093120 92.3% logs.tar [root@localhost ~]# Linux中使用pigz工具更快的压缩和解压文件Linux中使用pigz工具更快的压缩和解压文件 如何解压文件解压单个文件,解压方式: [root@localhost test]# unpigz -d FreeNAS-11.2-U7.iso.gz 如果需要保留源压缩文件,请添加-k参数 [root@localhost test]# pigz -k -d FreeNAS-11.2-U7.iso.gz 解压一个目录,解压方式: [root@localhost test]# tar -xf logs.tar.gz Linux中使用pigz工具更快的压缩和解压文件Linux中使用pigz工具更快的压缩和解压文件 总结pigz是一个并行执行的压缩工具,解压缩比gzip快,同时CPU消耗是gzip的好几倍,在对短时间内CPU消耗较高不受影响的场景下,可以使用pigz。
Terminus是一款基于web技术的终端,支持windows、Linux、MacOS系统。可以为终端定制主题和各种配色方案。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 环境Deepin 15.11 安装 TerminusTerminus的github仓库:https://github.com/Eugeny/terminus/releasesDeepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端官网提供了下载地址(https://www.termius.com/),它的下载速度比github快很多Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端但是github中的安装包类型比官网提供的多。有源码包、RHELCentos、UbuntuDebianDeepin、Windows、MacOS等安装包。在这里我们从github下载.deb的安装包: bob@bob-PC:~$ sudo wget https://github.com/Eugeny/terminus/releases/download/v1.0.112/terminus-1.0.112-linux.debbob@bob-PC:~$ sudo dpkg -i terminus-1.0.112-linux.deb Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 启动terminus启动terminus的方式,可以从Deepin的启动器里面找到"Terminus",点击启动。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端打开之后启动了terminusDeepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端点击“New Terminal”,可以新建回话。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 自定义terminusApplication选项卡Application选项里面可以修改终端的主题、窗口的位置等参数。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 hotkeyshotkeys选项可以修改某些功能的快捷键Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 pluginsplugins选项可以下载插件,例如terminus的主题等插件。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 Color SchemeColor Scheme选项可以设置中的文本的配色方案。Deepin Linux如何安装Terminus终端Deepin Linux如何安装Terminus终端 总结Terminus是一个新的终端工具,它可以轻松地定制默认环境的可视化方面。
linux系统安装完毕后,首先要做的就是系统调优,这样会提高系统的使用效率,接下来为大家介绍一下linux系统调优方法。linux系统调优linux系统调优 关闭selinux功能selinux是美国国家安全局对于强制访问控制的实现,这个功能很强大,同时又很麻烦,大多是运维人员都选择将其关闭,利用其它途径增加安全性。 此命令是永久关闭selinux,执行后重启系统生效。 [root@chao selinux]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config开机自启服务linux系统和windows系统类似,开机也会自启一些服务,没用的服务即会占用资源又有安全隐患,需要把必须运行的服务开机自启,其他的关闭。 需要开机自启的服务:sshd,远程连接需要使用此服务rsyslog,日志有关的软件networ,网络相关的软件crond,定时任务相关软件sysstat数据分析的软件查看目前开机自启的服务[root@chao selinux]# systemctl list-unit-files|grep enabledabrt-ccpp.service enabled abrt-oops.service enabled abrt-vmcore.service enabled abrt-xorg.service enabled abrtd.service enabled atd.service enabled auditd.service enabled autovt@.service enabled chronyd.service enabled crond.service enabled dbus-org.fedoraproject.FirewallD1.service enabled dbus-org.freedesktop.ModemManager1.service enabled dbus-org.freedesktop.NetworkManager.service enabled dbus-org.freedesktop.nm-dispatcher.service enabled dmraid-activation.service enabled firewalld.service enabled getty@.service enabled irqbalance.service enabled iscsi.service enabled kdump.service enabled ksm.service enabled ksmtuned.service enabled libstoragemgmt.service enabled libvirtd.service enabled 例如想关闭一个[root@chao selinux]# systemctl disable postfix.service Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.设置ssh服务编辑/etc/ssh/sshd_config文件 更改默认端口为Port 22222 保存退出,重启服务!linux系统调优linux系统调优 linux中文设置查看系统是否是 zh_CN.UTF-8 如果不是手动添加一行到此文件。 [root@chao etc]# cat locale.conf LANG="zh_CN.UTF-8"设置账户超时时间[root@chao ~]# echo 'export TMOUT=300' >>/etc/profile[root@chao ~]# source /etc/profile[root@chao ~]# env |grep -i tmout[root@chao ~]# vim /etc/profile[root@chao ~]# source /etc/profile[root@chao ~]# 等待输入超时:自动登出Connection closing...Socket close. Connection closed by foreign host. Disconnected from remote host(172.16.1.16) at 11:01:36. Type `help' to learn how to use Xshell prompt.设置命令行历史记录数将原来的5条改成10条 [root@chao ~]# sed -i 's/^HISTSIZE=5/HISTSIZE=10/' /etc/profile[root@chao ~]# source /etc/profile隐藏系统版本[root@chao ~]# echo redflag 5.9 >/etc/issue[root@chao ~]# cat /etc/issueredflag 5.9锁定重要文件[root@chao ~]# chattr -i /etc/passwd /etc/shoadow /etc/group /etc/gshadow /etc/inittab以上就是常用的优化步骤!
本篇文章介绍如何在CentOS8 Linux操作系统中安装GNOME3桌面环境和GDM(GNOME Display Manager)现实环境管理器。环境CentOS8 Minimal 安装GNOME3首先列出网络源中可以使用的Groups: [root@localhost ~]# yum grouplistCentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面下一步我们需要“Available Environment Groups”下面的“Server with GUI”,这个“Server with GUI”环境包使用的桌面环境就是GNOME3。下面进行安装,下载大约1GB的安装包: [root@localhost ~]# yum groupinstall "Server with GUI"CentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面安装完成! 设置GDM开机启动查看gdm.service是否启动,发现gdm服务没有启动。 [root@localhost ~]# systemctl status gdm● gdm.service - GNOME Display Manager Loaded: loaded (/usr/lib/systemd/system/gdm.service; enabled; vendor preset: enabled) Active: inactive (dead)下面设置gdm开机启动,并立即启动该服务: [root@localhost ~]# systemctl enable gdm --nowCentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面 设置系统启动级别为graphical默认情况,CentOS8默认启动级别为multi-user.target。 [root@localhost ~]# systemctl get-defaultmulti-user.targetCentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面下面设置CentOS8的启动级别为graphical.target [root@localhost ~]# systemctl set-default graphical.target Removed /etc/systemd/system/default.target.Created symlink /etc/systemd/system/default.target ¡ú /usr/lib/systemd/system/graphical.target. [root@localhost ~]# systemctl get-default graphical.targetCentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面 进入GNOME3桌面设置完上面的配置之后,重启操作系统。进入欢迎界面:CentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面CentOS8安装GNOME3桌面并设置开机启动图形界面 总结本篇文章介绍如何在CentOS8 Linux操作系统中安装GNOME3桌面环境和GDM(GNOME Display Manager)现实环境管理器。
Chromium浏览器是Chrome浏览器的开源版本,本文介绍如何使用snap工具安装最新版本的Chromium浏览器。环境Centos8 安装snapd工具使用snap安装chromium,可以安装最新版本的,下面是安装命令: [bob@localhost ~]$ sudo dnf install -y snapd 使snapd开机启动,并马上启动服务。 [bob@localhost ~]$ sudo systemctl enable snapd --now安装chromium接下来就是用snap安装chromium-83.0.4103.61吧。 [bob@localhost ~]$ sudo snap install chromiumCentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器打开chromium,查看一下版本。CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器 如何安装Chromium 测试版?使用snap工具可以安装测试版本的Chromium-84.0.4147.21浏览器。我们先把之前安装的卸载掉: [bob@localhost ~]$ sudo snap remove chromiumchromium removedCentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器接下来安装Beta版本的Chromium: [bob@localhost ~]$ sudo snap install chromium --betaCentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器打开浏览器看一下吧:CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器可以在命令行输入命令打开chromium浏览器: [bob@localhost ~]$ chromium &CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器 使用Centos8的epel源安装Chromium如果使用Centos8的epel源来安装Chromium浏览器,浏览器的版本比较低,更新的并不是很积极。可以使用下面命令列出chromium的安装包版本: [bob@localhost ~]$ sudo yum -y install https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm[bob@localhost ~]$ sudo sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*[bob@localhost ~]$ sudo sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*[bob@localhost ~]$ yum list chromiumCentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器使用yum安装chromium: [bob@localhost ~]$ sudo yum -y install chromium打开chromium浏览器,查看版本:CentOS8安装最新版本Chromium浏览器CentOS8安装最新版本Chromium浏览器可以看到,snap安装的版本和yum epel源安装的版本会有差别: snap安装的稳定版本:chromium-83.0.4103.61snap安装的测试版本:chromium-84.0.4147.21epel源安装的版本:chromium 81.0.4044.138总结Chromium浏览器是Chrome浏览器的开源版本。是谷歌主导的开源网络浏览器项目,国内外很多浏览器都是在它的代码基础上二次开发的,例如360浏览器、QQ浏览器、还有最近windows 10 2004版本的Microsoft Edge浏览器也是chromium二次开发的。 本文原创地址:https://www.linuxprobe.com/centos8-install-chromium.html编辑:逄增宝,审核员:逄增宝
Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。linux环境部署redislinux环境部署redis 解压缩,进入redis目录 make && make install 编译安装linux环境部署redislinux环境部署redis linux环境部署redislinux环境部署redis 查看运行状态linux环境部署redislinux环境部署redis修改配置文件/etc/redis/6379.conf设置密码linux环境部署redislinux环境部署redis然后修改前面提到过的redis.properties 使用以下命令查看到有数据说明redis起作用了linux环境部署redislinux环境部署redis
linux运维工程师在面试的时候经常会被问到各种问题,接下来小编根据自己的经验将面试题整理下来供大家参考。linux面试题整理linux面试题整理 取出文件aaa.txt的第4到7行[root@localhost ~]# cat aaa.txt 1.aaa2.bbbbbbb3.ccccccccccccc4.dddddddddddddddddddddd5.eeeeeeeeeeeeeeeeee6.ffffffffffffffffffffffffffffffffff7.gggggggggggggggggggggg8.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh9.iiiiiiiiiiiiiiiiiiii10.jjjjjjjjjjjjjjjjjjjjjjjjjj11.kkk12.llllllllll[root@localhost ~]# sed -n '4,7p' aaa.txt4.dddddddddddddddddddddd5.eeeeeeeeeeeeeeeeee6.ffffffffffffffffffffffffffffffffff7.gggggggggggggggggggggg找出当前目录下txt结尾的文件 [root@localhost ~]# ls1.txt 2.txt 3.pdf aaa.txt anaconda-ks.cfg[root@localhost ~]# find ./ -name "*.txt"./aaa.txt./1.txt./2.txt查找/usr目录下超过1M的文件[root@localhost ~]# find /usr -type f -size +10240k/usr/lib/locale/locale-archive/usr/lib64/libicudata.so.50.1.2写一个定时任务5点到8点执行 5-8 * /usr/bin/backupmysql主从复制原理 主库db的更新事件(update、insert、delete)被写到binlog。主库创建一个binlog dump thread,把binlog的内容发送到从库。从库启动并发起连接,连接到主库。从库启动之后,创建一个I/O线程,读取主库传过来的binlog内容并写入到relay log。从库启动之后,创建一个SQL线程,从relay log里面读取内容,从Exec_Master_Log_Pos位置开始执行读取到的更新事件,将更新内容写入到slave的db。 vim有几种工作模式命令模式。行末模式,编辑模式 简述dns解析流程?访问www.baidu.com的解析流程优先查找本地dns缓存,查找本地/etc/hosts文件,是否有强制解析,如果没有去/etc/resolv.conf指定的dns服务器中查找记录(需联网,在dns服务器中找到解析记录后,在本地dns中添加缓存,完成一次dns解析 讲解一下DNS查询的两种模式递归查询递归查询是一种DNS 服务器的查询模式,在该模式下DNS 服务器接收到客户机请求,必须使用一个准确的查询结果回复客户机。如果DNS 服务器本地没有存储查询DNS 信息,那么该服务器会询问其他服务器,并将返回的查询结果提交给客户机。 迭代查询DNS 服务器另外一种查询方式为迭代查询,DNS 服务器会向客户机提供其他能够解析查询请求的DNS 服务器地址,当客户机发送查询请求时,DNS 服务器并不直接回复查询结果,而是告诉客户机另一台DNS 服务器地址,客户机再向这台DNS 服务器提交请求,依次循环直到返回查询的结果为止。 描述一下正向代理和反向代理正向代理比如我们国内访问国外网站,直接访问访问不到,我们可以通过一个正向代理服务器,请求发到代理服,代理服务器能够访问国外网站,这样由代理去国外网站取到返回数据,再返回给我们,这样我们就能访问了。 反向代理反向代理实际运行方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时客户只是访问代理服务器却不知道后面有多少服务器。 总结以上就是我面试的整理,希望对大家有所帮助。
在本文中我们将使用一个名为speedtest-cli的命令行工具来测试网速。它是用Python语言编写的工具,系统通过向speedtest.net网站上传和下载数据来测试带宽。环境Centos7 安装speedtest-cli工具在安装speedtest-cli之前,我们需要安装先安装python3-pip包管理器,然后通过pip安装speedtest-cli工具。 [root@localhost ~]# yum -y install python3-pip使用Speedtest CLI测试你的网速使用Speedtest CLI测试你的网速安装成功之后,我们可以用pip3命令安装speedtest-cli: [root@localhost ~]# pip3 install speedtest-cli使用Speedtest CLI测试你的网速使用Speedtest CLI测试你的网速 通过speedtest cli检测网络[root@localhost ~]# speedtest-cli Retrieving speedtest.net configuration...Testing from China Telecom (...)...Retrieving speedtest.net server list...Selecting best server based on ping...Hosted by China Telecom JiangSu 5G (Lianyungang) [196.15 km]: 31.424 msTesting download speed................................................................................Download: 47.64 Mbit/sTesting upload speed......................................................................................................Upload: 94.56 Mbit/s使用Speedtest CLI测试你的网速使用Speedtest CLI测试你的网速 总结在本文中我们将使用一个名为speedtest-cli的命令行工具来测试网速。它是用Python语言编写的工具,系统通过向speedtest.net网站上传和下载数据来测试带宽。 本文原创地址:https://www.linuxprobe.com/use-speedtest-cli.html编辑:逄增宝,审核员:逄增宝
OwnCloud 一款文件主机服务软件,就是我们平时使用的云存储,不过这是在自己主机的服务器上建立属于自己的私有云,OwnCloud 使用AGPLv3协议发布。本项目是基于PHP和SQLite,MySQL,Oracle或PostgreSQL数据库,所以它可以运行在所有的平台上 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 下载owncloud安装包 [root@chao tools]# wget https://download.owncloud.org/community/owncloud-10.0.2.zip --2020-06-01 15:09:12-- https://download.owncloud.org/community/owncloud-10.0.2.zip 正在解析主机 download.owncloud.org (download.owncloud.org)... 116.203.164.24, 2a01:4f8:1c0c:8147:: 正在连接 download.owncloud.org (download.owncloud.org)|116.203.164.24|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 301 Moved Permanently 位置:https://attic.owncloud.org/community/owncloud-10.0.2.zip [跟随至新的 URL] --2020-06-01 15:09:18-- https://attic.owncloud.org/community/owncloud-10.0.2.zip 正在解析主机 attic.owncloud.org (attic.owncloud.org)... 195.201.36.192, 2a01:4f8:c2c:5c1d::1 正在连接 attic.owncloud.org (attic.owncloud.org)|195.201.36.192|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:42123371 (40M) [application/zip] 正在保存至: “owncloud-10.0.2.zip” 100%[=========================================================================================================>] 42,123,371 232KB/s 用时 3m 14s 2020-06-01 15:12:34 (212 KB/s) - 已保存 “owncloud-10.0.2.zip” [42123371/42123371]) [root@chao tools]# ls owncloud-10.0.2.zip 安装依赖包组件 [root@chao tools]# yum install -y httpd php php-mysql mariadb-server mariadb sqlite php-dom php-mbstring php-gd php-pdo wget vim 将owncloud包与apache结合将owncloud解压到apache目录 [root@chao tools]# unzip owncloud-10.0.2.zip -d /var/www/html/ 授权 [root@chao tools]# chown -R apache.apache /var/www/html/owncloud/ 设置数据库启动数据库和apache [root@chao tools]# systemctl start mariadb [root@chao tools]# systemctl start httpd 关闭防火墙和selinux [root@chao tools]# setenforce 0 [root@chao tools]# systemctl stop firewalld 创建用户并授权 [root@chao tools]# mysql Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 2 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]> create database owncloud; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> create user 'owncloud'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on owncloud.* to 'owncloud'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> quit Bye 登录 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 填写相关数据库信息 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 部署完成 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 测试 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘RHEL7部署私有云网盘 上传成功!
在 RHEL 7.3 上面搭建好了 Apache Web 服务,现在想把 RHEL 8.1 系统镜像上传到 Apache Web 根目录,但由于 RHEL 8.1 系统镜像的大小为 7.31 GB,已经超过 4 GB ,通过 rz 无法上传。解决方法是把 RHEL 8.1 系统镜像挂载到 RHEL 7.3 系统上再制作一个新系统镜像,然后把新系统镜像移动到 Apache Web 根目录里面的系统镜像目录即可,也可以先到 Apache Web 根目录里的系统镜像目录再制作新系统镜像,这样就可以省去移动新系统镜像的步骤了。Linux 制作系统镜像Linux 制作系统镜像 环境Red Hat Enterprise Linux Server release 7.3VMware Workstation Pro 14 添加镜像Linux 制作系统镜像Linux 制作系统镜像 [root@Jaking ~]# ifconfigens32: flags=4163 mtu 1500 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:fe84:eae5 prefixlen 64 scopeid 0x20 ether 00:0c:29:84:ea:e5 txqueuelen 1000 (Ethernet) RX packets 636 bytes 53068 (51.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 508 bytes 85327 (83.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:25:a2:80 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@Jaking ~]# df -h Filesystem Size Used Avail Use% Mounted on/dev/mapper/rhel-root 48G 4.9G 41G 11% /devtmpfs 478M 0 478M 0% /devtmpfs 489M 0 489M 0% /dev/shmtmpfs 489M 6.7M 482M 2% /runtmpfs 489M 0 489M 0% /sys/fs/cgroup/dev/sr0 3.6G 3.6G 0 100% /media/cdrom/dev/sdd 40G 27G 14G 67% /download/dev/sda2 1014M 145M 870M 15% /boot/dev/mapper/rhel-data 10G 33M 10G 1% /datatmpfs 98M 0 98M 0% /run/user/0[root@Jaking ~]# ls /dev/sr*/dev/sr0 /dev/sr1 /dev/sr1为新添加的镜像 制作新系统镜像切换到 Apache Web 根目录里的系统镜像目录 [root@Jaking ~]# cd /download/系统镜像/[root@Jaking 系统镜像]# lsCentOS-7.6-x86_64-DVD-1810.iso rhel-server-7.3-x86_64-dvd.iso Windows 7 x64.isoLaoMaoTao.iso ubuntu-18.04.1-desktop-amd64.iso Windows Sever 2008.isorhel-server-6.5-x86_64-dvd.iso Windows 2003 SP2.iso[root@Jaking 系统镜像]# dd if=/dev/sr1 of=RHEL-8.1.iso15335424+0 records in15335424+0 records out7851737088 bytes (7.9 GB) copied, 174.329 s, 45.0 MB/s通过Web界面查看新系统镜像http://192.168.10.10/系统镜像/ Linux 制作系统镜像Linux 制作系统镜像 下载镜像Linux 制作系统镜像Linux 制作系统镜像 用 watch ifstat 实时查看网卡流量Linux 制作系统镜像Linux 制作系统镜像 总结至此,镜像已经制作成功,下载后就能直接使用。
忘记root密码的时候,往往会进入单用户模式重置root密码。任何人能通过未设防grub重置root密码是很危险的事,本文以centos8为例介绍设置GRUB账户给GRUB加密,避免能直接进入单用户模式Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码 Cento8在我实际测试用这个方法在centos8是有效的。 在root权限编辑"grub.d"目录下的"00_header"文件,命令模式输入大写G,跳转到文件尾部。 vim /etc/grub.d/00_headerCentos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码 在尾部追加下面的语句,两处admin位置代表账户,qwe123位置代表密码,可以自行设置其他。 cat <set superusers='admin'password admin qwe123E0FCentos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码文件编辑保存,更新一下grub文件 grub2-mkconfig -o /boot/grub2/grub.cfgCentos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码然后重启,在开机grub选择页面按e进入编辑引导,如果有需要登录且输入对应的账户密码进入编辑,即为设置成功。Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码 Centos7.2/Centos8首先设置密码 grub2-set-password记住密码,输入两次确认密码:Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码密码密文存放在:/boot/grub2/user.cfg文件中Centos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码这样生成的默认账户是root,有需要可以把root修改成其他的: vim /etc/grub.d/01_usersCentos8加密GRUB防破解root密码Centos8加密GRUB防破解root密码 最后一步更新grub。 grub2-mkconfig -o /boot/grub2/grub.cfg然后重启在grub选择项那里按e测试grub账户密码。
本文档介绍 SSH 的原理与应用,这是企业级非常实用的技术,希望能给大家带来帮助。一、SSH简介SSH是Secure Shell的缩写,也叫做安全外壳协议。SSH的主要目的是实现安全远程登录。 二 、SSH工作原理SSH的安全性比较好,其对数据进行加密的方式主要有两种:对称加密(密钥加密)和非对称加密(公钥加密)。 对称加密指加密解密使用的是同一套秘钥。Client端把密钥加密后发送给Server端,Server用同一套密钥解密。对称加密的加密强度比较高,很难破解。但是,Client数量庞大,很难保证密钥不泄漏。如果有一个Client端的密钥泄漏,那么整个系统的安全性就存在严重的漏洞。为了解决对称加密的漏洞,于是就产生了非对称加密。非对称加密有两个密钥:“公钥”和“私钥”。公钥加密后的密文,只能通过对应的私钥进行解密。想从公钥推理出私钥几乎不可能,所以非对称加密的安全性比较高。 SSH的加密原理中,使用了RSA非对称加密算法。整个过程是这样的:(1)远程主机收到用户的登录请求,把自己的公钥发给用户。(2)用户使用这个公钥,将登录密码加密后,发送回来。(3)远程主机用自己的私钥,解密登录密码,如果密码正确,就同意用户登录。 三、中间人攻击SSH之所以能够保证安全,原因在于它采用了公钥加密,这个过程本身是安全的,但是实际用的时候存在一个风险:如果有人截获了登录请求,然后冒充远程主机,将伪造的公钥发给用户,那么用户很难辨别真伪。因为不像https协议,SSH协议的公钥是没有证书中心(CA)公证的,是自己签发的。 如果攻击者插在用户与远程主机之间(比如在公共的wifi区域),用伪造的公钥,获取用户的登录密码。再用这个密码登录远程主机,那么SSH的安全机制就不存在了。这种风险就是著名的"中间人攻击"(Man-in-the-middle attack)。那么SSH协议是怎样应对的呢? 四、口令登录如果是第一次登录远程机,会出现以下提示: $ ssh user@hostThe authenticity of host 'host (12.18.429.21)' can't be established.RSA key fingerprint is 98:2e:d7:e0:de:9f:ac:67:28:c2:42:2d:37:16:58:4d.Are you sure you want to continue connecting (yes/no)?因为公钥长度较长(采用RSA算法,长达1024位),很难比对,所以对其进行MD5计算,将它变成一个128位的指纹。如98:2e:d7:e0:de:9f:ac:67:28:c2:42:2d:37:16:58:4d,这样比对就容易多了。 经过比对后,如果用户接受这个远程主机的公钥,系统会出现一句提示语: Warning: Permanently added 'host,12.18.429.21' (RSA) to the list of known hosts.表示host主机已得到认可,然后再输入登录密码就可以登录了。 当远程主机的公钥被接受以后,它就会被保存在文件~/.ssh/known_hosts之中。下次再连接这台主机,系统就会认出它的公钥已经保存在本地了,从而跳过警告部分,直接提示输入密码。每个SSH用户都有自己的known_hosts文件,此外系统也有一个这样的文件,一般是/etc/ssh/ssh_known_hosts,保存一些对所有用户都可信赖的远程主机的公钥。 五、公钥登录使用密码登录,每次都必须输入密码,非常麻烦。好在SSH还提供了公钥登录,可以省去输入密码的步骤。所谓"公钥登录",原理很简单,就是用户将自己的公钥储存在远程主机上。登录的时候,远程主机会向用户发送一段随机字符串,用户用自己的私钥加密后,再发回来。远程主机用事先储存的公钥进行解密,如果成功,就证明用户是可信的,直接允许登录shell,不再要求密码。 这种方法要求用户必须提供自己的公钥。如果没有现成的,可以直接用ssh-keygen生成一个: $ ssh-keygen 运行上面的命令以后,系统会出现一系列提示,可以一路回车。其中有一个问题是,要不要对私钥设置口令(passphrase),如果担心私钥的安全,这里可以设置一个。运行结束以后,在~/.ssh/目录下,会新生成两个文件:id_rsa.pub和id_rsa。前者是公钥,后者是私钥。 这时再输入下面的命令,将公钥传送到远程主机host上面: $ ssh-copy-id user@host远程主机将用户的公钥,保存在登录后的用户主目录的~/.ssh/authorized_keys文件中。这样,以后就登录远程主机不需要输入密码了。 如果还是不行,就用vim打开远程主机的/etc/ssh/sshd_config这个文件,将以下几行的注释去掉。 RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys然后,重启远程主机的ssh服务。 Redhat6系统service ssh restartRedhat7系统systemctl restart sshdubuntu系统service ssh restartdebian系统/etc/init.d/ssh restart实战生成秘钥[root@Jaking ~]# ifconfigens33: flags=4163 mtu 1500 inet 192.168.10.88 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::1026:b2d7:b2bc:82be prefixlen 64 scopeid 0x20 ether 00:0c:29:57:18:93 txqueuelen 1000 (Ethernet) RX packets 993461 bytes 114570794 (109.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 66404 bytes 45385043 (43.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 [root@Jaking ~]# ssh-keygen #这里要一直按回车Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:89:86:42:59:1f:27:f1:f4:26:e8:10:bb:ae:37:e2:69 root@Jaking.localdomainThe key's randomart image is:+--[ RSA 2048]----+| o +.o || o + B . || o o o o o || . = . + || . o + S || o . || . || Eoo | [root@Jaking ~]# cat /root/.ssh/id_rsa-----BEGIN RSA PRIVATE KEY-----MIIEogIBAAKCAQEAuc8KoCp+dmHY99gOAt9ywPXv1YZyzdOKuDSaYZOMEp9c78sUJDZl08LEQCSgiNKaUYZxd5XGMHkk2n9dDWKmH5NJ1KBP+Olp433A4W+BBFF71wRD2OU8ulAwNNSsWB5Q2EXcCqHDtu9zN7fZvujPMVvVqprPqw+gXpskjRI2lG34iftflRJoChXSrEOJQEMwYJcps45xoy/7yOhPidpoU3BE1ojemMecL5bQTnd56eR1zjIEpCtwNWaKm8VJfqHge/A75R60QKfv0SjsNQaddo7gqYBkj+2zbxiJY5K1WE5K4UyU7wLzjBNZW0h/EaE73wHEKoFni8ydZ8cbjJJZhwIDAQABAoIBAARGg1QUJjzLG5b4XborMhTGk/Ix2cpqp7J9Y2ADaSG0kQrjfV8n8UfiH2nqbdc4IVzm3w2FYL4Uy4hLjfSU5IWtefFujuiHVmxppFqLmkhjJ5pW+siu3arb1YAhtKWCbRHM6bdE6Z/3+oq5rET8TmgwWMZIMacaAPKsVzb3yFG5/AU4HS4V4XgmfoqEnjwrYUnySOcZKkYvoEPelJchN44SjrKd2MndtXRgm0GbSCbwrMj3Blmx8qutnaqzMZVIgicxu2tim6mTCWru5SaydYQbDA3CX909qkvx4IVTYy2+6K1jfLy+ikhv3kJnivD0TAlEmJe4cR3G7zpVkKdz1yECgYEA5Y971v7zz+GBeAhF9H2y7iUY9V3mSdWbwS2sCDXVpzwrjCYE9QGahbE6k5NyrUmK1GxhtWJbHUjDQMS8fvDIARJ23W3T/Y3sa6XBjN6Hq5DRyicy+0tJdxynEpqzFdkYt77bpcEKXhoAakpDrfrR182Wd4rk80UHdp1XlZcLIMsCgYEAzzWNYt2UJQ4aWRxTA0+H3NRZuzrSs8vl+i7Iw02ZsDxB39/0vCSsL0OczwdR6XK2tMvG61Czve/8A9g/ERgFbWIGKqs777T9jgVS/JslRle4/JGCGeKZcw0msKOKqCHTYYOERAVZ2jPqaZZ8Gamc+TE6F5qupXhU8EB0csXpPrUCgYA5NeoqKb3/p/bJQF6W0SDfwvUWaYF0Ez1PBp/iJ/CITjGYKv1/RhgJi6LKlqu0zihASoaLWujUQocOxDkp9b4SrlRbWPzFKzKpnVTAU9FCC8SM+fn1sMytV8G3nEBXiJRlbrZ098gqrZY+5yU43dKgUsdWIZJvolt6zzm9uTf3wwKBgGQo77oNf3HV+lh+v4XHKNZO8zz0tyrf8b/YY4U8eoDc777G4+caFv0VwrO0Rx0ALV8BbZsLvIagfYJiQkICCYWRL4fqk6NQKow++JlQaVkySCIWN/xJM4GQptYVh420JBhr2UCEEaXPGI2Hh19kRJOT/w+v3qHvo6cqkN912URNAoGAGzMTIjaYBHVzdQAZT0Tb01xRXhV9BxH9WM8KPN2WH1pqxkMQ0DG0hnk9hnC7Lv8W0kRUkDb56D+wxAyLe4GO4Zy51IGnAWGWivHmVxh6Q9ToggOiqsAGTGA/HTGTElG7tOsXNIGu/eImgPeSKbAZ+Zi9HYNWx4SY/7OYnuwfXAM=-----END RSA PRIVATE KEY-----[root@Jaking ~]# cd /root/.ssh[root@Jaking .ssh]# lsid_rsa id_rsa.pub known_hosts[root@Jaking .ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5zwqgKn52Ydj32A4C33LA9e/VhnLN04q4NJphk4wSn1zvyxQkNmXTwsRAJKCI0ppRhnF3lcYweSTaf10NYqYfk0nUoE/46WnjfcDhb4EEUXvXBEPY5Ty6UDA01KxYHlDYRdwKocO273M3t9m+6M8xW9Wqms+rD6BemySNEjaUbfiJ+1+VEmgKFdKsQ4lAQzBglymzjnGjL/vI6E+J2mhTcETWiN6Yx5wvltBOd3np5HXOMgSkK3A1ZoqbxUl+oeB78DvlHrRAp+/RKOw1Bp12juCpgGSP7bNvGIljkrVYTkrhTJTvAvOME1lbSH8RoTvfAcQqgWeLzJ1nxxuMklmH root@Jaking.localdomain[root@Jaking .ssh]# [root@Jaking .ssh]# [root@Jaking .ssh]# [root@Jaking .ssh]# ssh-copy-id root@192.168.10.10/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysroot@192.168.10.10's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.10.10'"and check to make sure that only the key(s) you wanted were added.验证免密登录[root@Jaking .ssh]# ssh root@192.168.10.10Last login: Wed Nov 20 15:18:11 2019 from 192.168.10.88[root@Jaking ~]# ifconfigens32: flags=4163 mtu 1500 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:fe84:eae5 prefixlen 64 scopeid 0x20 ether 00:0c:29:84:ea:e5 txqueuelen 1000 (Ethernet) RX packets 16300 bytes 1107939 (1.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13043 bytes 17924190 (17.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 六、SSH端口转发SSH端口转发有三种:动态端口转发、本地端口转发、远程端口转发。这三种方式说起来有点难理解,通过例子会好理解一点。假设有三台主机,host1、host2、host3。 动态端口转发是找一个代理端口,然后通过代理端口去连相应的端口。动态端口转发的好处在于通过代理端口可以去找很多需要连接的端口,提高了工作效率。比如host1本来是连不上host2的,而host3却可以连上host2。host1可以找到host3作代理,然后通过host3去连接host2的相应端口 本地端口转发也是找到第三方,通过第三方再连接想要连接的端口,但这种方式的端口转发是固定的,是点对点的。比如假定host1是本地主机,host2是远程主机。由于种种原因,这两台主机之间无法连通。但是,另外还有一台host3,可以同时连上host1和host2这两台主机。通过host3,将host1连上host2。host1找到host3,host1和host3之间就像有一条数据传输的道路,通常被称为“SSH隧道”,通过这条隧道host1就可以连上host2。 远程端口转发和本地端口转发就是反过来了。假如host1在外网,host2在内网,正常情况下,host1不能访问host2。通过远程端口转发,host2可以反过来访问host1。host2和host1之间形成了一条道路,host1就可以通过这条道路去访问host2。 七、SSH基本用法SSH主要用于远程登录:假定你要以用户名user,登录远程主机host,只要一条简单命令就可以了。 $ ssh user@host如果本地用户名与远程用户名一致,登录时可以省略用户名。 $ ssh hostSSH的默认端口是22,也就是说,你的登录请求会送进远程主机的22端口。使用p参数,可以修改这个端口。 $ ssh -p 2018 user@host上面这条命令表示,ssh直接连接远程主机的2018端口。 总结以上就是 SSH 的原理与应用,希望大家能好好理解,给实际工作带来帮助。
eDEX-UI是一个全屏、跨平台的终端仿真器和系统监视器,它的外观和感觉就像一个科幻电脑界面。从《创战记》的电影特效(尤其是会议室的场景)中获得了巨大的灵感,最初,eDEX-UI项目的设计初衷是“减少«艺术»,增加«可分配软件»的dx - ui”。虽然保持了未来主义的外观和感觉,它努力保持一定程度的功能,并在现实生活场景中可用,更大的目标是把科幻小说的UXs带入主流。 使用环境Windows 10 eDEX-UI 可以安装在linux、Windows、MacOS操作系统上面。 安装下载地址:https://github.com/GitSquared/edex-ui/releases酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI 如果在linux32位或者64位上安装,可以选择 eDEX-UI.Linux.i386.AppImage或者 eDEX-UI.Linux.x86_64.AppImage,下载完,输入chmod +x eDEX-UI.Linux添加执行权限,然后./ eDEX-UI.Linux执行,就可以运行eDEX-UI终端模拟器了。 在windows中安装,需要下载 eDEX-UI.Windows.Installer.exe这个安装包。下载完成之后,双击运行,自动进入终端模拟器了。 下面是启动后的效果:酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI 酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI可以更改主题:鼠标点击settings.json,然后修改themes酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI修改完成之后,需要点击”Save to Disk”,然后点击”Reload UI”酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI 更改themes后的效果图Themes: Tron-disrupted酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UIThemes: Matrix酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UIThemes: Red酷炫的终端模拟器eDEX-UI酷炫的终端模拟器eDEX-UI 总结eDEX-UI是一个全屏、跨平台的终端仿真器和系统监视器,它的外观和感觉就像一个科幻电脑界面。
将 manpages-zh-1.5.1.tar.gz 源码包下载到本地http://pkgs.fedoraproject.org/repo/pkgs/man-pages-zh-CN/manpages-zh-1.5.1.tar.gz/13275fd039de8788b15151c896150bc4/ 安装 lrzsz 工具[root@centos7 ~]# cd /usr/local/src[root@centos7 src]# yum install -y lrzsz已加载插件:fastestmirrorLoading mirror speeds from cached hostfile base: mirrors.163.com extras: mirrors.aliyun.com updates: mirrors.aliyun.com正在解决依赖关系 --> 正在检查事务---> 软件包 lrzsz.x86_64.0.0.12.20-36.el7 将被 安装--> 解决依赖关系完成 依赖关系解决 ======================================================================== Package 架构 版本 源 大小 正在安装: lrzsz x86_64 0.12.20-36.el7 base 78 k 事务概要 安装 1 软件包 总下载量:78 k安装大小:181 kDownloading packages:lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在安装 : lrzsz-0.12.20-36.el7.x86_64 1/1 验证中 : lrzsz-0.12.20-36.el7.x86_64 1/1 已安装: lrzsz.x86_64 0:0.12.20-36.el7 完毕![root@centos7 src]# lsmanpages-zh-1.5.1.tar.gz[root@centos7 src]# sz manpages-zh-1.5.1.tar.gz rz zmodem trl+C ȡ 100% 1 KB 1 KB/s 00:00:01 0 Errorsgz...上传源码包[root@centos7 src]# rm -rf *[root@centos7 src]# ls[root@centos7 src]# rzrz waiting to receive. zmodem trl+C ȡ 100% 1919 KB 1919 KB/s 00:00:01 0 Errorsgz... [root@centos7 src]# lsmanpages-zh-1.5.1.tar.gz[root@centos7 src]# file manpages-zh-1.5.1.tar.gz manpages-zh-1.5.1.tar.gz: gzip compressed data, from Unix, last modified: Thu Apr 3 23:29:16 2008, max compression[root@centos7 src]# tar xf manpages-zh-1.5.1.tar.gz [root@centos7 src]# lsmanpages-zh-1.5.1 manpages-zh-1.5.1.tar.gz [root@centos7 src]# cd manpages-zh-1.5.1[root@centos7 manpages-zh-1.5.1]# lsaclocal.m4 configure DOCS Makefile.am NEWS utilsAUTHORS configure.in INSTALL Makefile.in READMEChangeLog COPYING install-sh missing src关闭 zhtw[root@centos7 manpages-zh-1.5.1]# ./configure --disable-zhtwchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /usr/bin/mkdir -pchecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking whether to enable maintainer-specific portions of Makefiles... noconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating DOCS/Makefileconfig.status: creating src/Makefileconfig.status: creating src/man1/Makefileconfig.status: creating src/man1/zh_CN/Makefileconfig.status: creating src/man1/zh_TW/Makefileconfig.status: creating src/man2/Makefileconfig.status: creating src/man2/zh_CN/Makefileconfig.status: creating src/man2/zh_TW/Makefileconfig.status: creating src/man3/Makefileconfig.status: creating src/man3/zh_CN/Makefileconfig.status: creating src/man3/zh_TW/Makefileconfig.status: creating src/man4/Makefileconfig.status: creating src/man4/zh_CN/Makefileconfig.status: creating src/man4/zh_TW/Makefileconfig.status: creating src/man5/Makefileconfig.status: creating src/man5/zh_CN/Makefileconfig.status: creating src/man5/zh_TW/Makefileconfig.status: creating src/man6/Makefileconfig.status: creating src/man6/zh_CN/Makefileconfig.status: creating src/man6/zh_TW/Makefileconfig.status: creating src/man7/Makefileconfig.status: creating src/man7/zh_CN/Makefileconfig.status: creating src/man7/zh_TW/Makefileconfig.status: creating src/man8/Makefileconfig.status: creating src/man8/zh_CN/Makefileconfig.status: creating src/man8/zh_TW/Makefileconfig.status: creating src/mann/Makefileconfig.status: creating src/mann/zh_CN/Makefileconfig.status: creating src/mann/zh_TW/Makefileconfig.status: creating utils/Makefile manpages-zh configure summary UTF-8 : truezh_CN : truezh_TW : false编译安装[root@centos7 manpages-zh-1.5.1]# make && make install设置环境变量[root@centos7 manpages-zh-1.5.1]# vim /etc/profile.d/cman.sh #新文件 输入以下内容 alias cman='man -M /usr/local/share/man/zh_CN'执行别名文件让该文件生效[root@centos7 manpages-zh-1.5.1]# source /etc/profile.d/cman.sh执行 man ls 或者 cman ls 查看配置结果是否成功[root@centos7 manpages-zh-1.5.1]# cman lsLS(1) General Commands Manual LS(1) NAME ls, dir, vdir - 列目录内容 提要 ls [选项] [文件名...] POSIX 标准选项: [-CFRacdilqrtu1] GNU 选项 (短格式): [-1abcdfgiklmnopqrstuxABCDFGLNQRSUX] [-w cols] [-T cols] [-I pattern] [--full-time] [--format={long,verbose,commas,across,vertical,single-column}] [--sort={none,time,size,extension}] [--time={atime,access,use,ctime,status}] [--color[={none,auto,always}]] [--help] [--version] [--] 描述( DESCRIPTION )总结以上就是配置 CentOS 7 man 命令帮助显示简体中文的方法,最后用 cman 来测试,大家可以去尝试用 man 来测试一下,希望能给大家带来帮助。
QRCP在不离开终端的情况下扫描二维码,通过wifi将文件从计算机传输到移动设备、接受移动设备上传的文件。如何工作的?qrcp将web服务器绑定到网络接口地址上的随机端口,并为其创建处理程序。默认处理程序提供内容,并在传输完成时退出程序。当用于接收文件时,qrcp提供上传页面并处理传输。通过二维码传输文件到linux通过二维码传输文件到linux 下载地址https://github.com/claudiodangelis/qrcp/releases通过二维码传输文件到linux通过二维码传输文件到linux 安装Deb安装包(Deepin , Ubuntu , Debian…)下载最新的.deb安装包,然后运行下面的命令: $ sudo dpkg -i qrcp_0.5.3_linux_x86_64.debRPM安装包(CentOS , Fedora , RHEL…) rpm -ivh qrcp_0.5.3_linux_x86_64.rpm windows安装包下载qrcp_0.5.3_Windows_x86_64.tar.gz ,并解压进入文件夹。使用方式是在cmd/PowerShell命令提示符界面运行。通过二维码传输文件到linux通过二维码传输文件到linux在空白地方按住shift键,然后鼠标右键,选择“在此处打开PowerShell窗口” 发送文件 .qrcp.exe send .README.md通过二维码传输文件到linux通过二维码传输文件到linux接受文件 --output后面加上创建好的目录,用来接受文件。 .qrcp.exe receive --output=.\通过二维码传输文件到linux通过二维码传输文件到linux 发送文件发送一个或者多个文件 [root@localhost ~]# qrcp send file1.txt[root@localhost ~]# qrcp send file1.txt file2.txt 发送一个文件夹 [root@localhost ~]# qrcp send Documents/通过二维码传输文件到linux通过二维码传输文件到linux还可以文件压缩之后传输: [root@localhost ~]# qrcp --zip send file1.txt file2.txt通过二维码传输文件到linux通过二维码传输文件到linux手机端提示下载压缩包通过二维码传输文件到linux通过二维码传输文件到linux 接收文件接收文件时,qrcp会提供一个“上传页面”,可以通过该页面从手机中选择文件。 接收文件,并指定一个保存文件的目录。 [root@localhost ~]# mkdir /files[root@localhost ~]# qrcp receive --output=/files通过二维码传输文件到linux通过二维码传输文件到linux手机端扫描二维码,然后选择文件,上传文件通过二维码传输文件到linux通过二维码传输文件到linux文件上传成功通过二维码传输文件到linux通过二维码传输文件到linuxqrcp服务端显示文件上传完成,就会断开连接通过二维码传输文件到linux通过二维码传输文件到linux 总结使用起来很方便。需要了解更多参数,可以使用qrcp --help查看帮助。 本文原创地址:https://www.linuxprobe.com/qr-transfer-file.html编辑:逄增宝,审核员:逄增宝
Awk是为高级文本处理而设计的通用脚本语言。它主要用作报告和分析工具。本文介绍awk在命令行中操作文本的使用方式。Awk一次对一条记录进行操作,直到到达输入的末尾。记录由一个称为记录分隔符的字符分隔。默认的记录分隔符是换行符,这意味着文本数据中的每一行都是一个记录。 每条记录中的字段由$后跟字段号(以1开头)引用。第一个字段用$1表示,第二个字段用$2表示,依此类推。最后一个字段也可以用特殊变量$NF引用。整个记录可以用$0引用。 Awk模式Awk支持不同类型的模式,包括正则表达式、关系表达式、范围和特殊表达式模式。 在下面的例子中,将创建一个名为“ teams.txt”的文件,文件内容如下: [root@localhost ~]# cat teams.txt Bucks Milwaukee 60 22 0.732 Raptors Toronto 58 24 0.707 76ers Philadelphia 51 31 0.622Celtics Boston 49 33 0.598Pacers Indiana 48 34 0.585正则表达式模式Awk的正则表达式模式用斜线(//)包含起来,例如:要显示包含“0.5”的每条记录,可以运行以下命令: [root@localhost ~]# awk '/0.5/ {print $0}' teams.txt Celtics Boston 49 33 0.598Pacers Indiana 48 34 0.585awk命令使用实例awk命令使用实例要显示包含“0.5”的每条记录的第一个和第二个字段: [root@localhost ~]# awk '/0.5/ {print $1,$2}' teams.txt Celtics BostonPacers Indianaawk命令使用实例awk命令使用实例显示一个或者多个数字开头的记录,并打印第一列: [root@localhost ~]# awk '/^[0-9]/ {print $1}' teams.txt 76ersawk命令使用实例awk命令使用实例 关系表达式模式关系表达式模式通常用于匹配特定字段或变量的内容。常用的关系运算符有: ~:包含!~:不包含 :大于<:小于=:大于等于 <=:小于等于=:等于!=:不等于使用~“包含”比较运算符。例如,显示第二个字段中包含“ia”字符的每条记录: [root@localhost ~]# awk '$2 ~ /ia/ {print $0}' teams.txt 76ers Philadelphia 51 31 0.622Pacers Indiana 48 34 0.585 awk命令使用实例awk命令使用实例若要匹配不包含给定字符的记录,可以使用!~不包含操作符。例如,显示第二个字段中不包含“ia”字符的每条记录: [root@localhost ~]# awk '$2 !~ /ia/ {print $0}' teams.txt Bucks Milwaukee 60 22 0.732 Raptors Toronto 58 24 0.707 Celtics Boston 49 33 0.598 使用!=“不等于”操作符,awk命令使用实例awk命令使用实例使用>=“大于等于”操作符,显示第四个字段大于等于30的记录: [root@localhost ~]# awk '$4 >= 30 {print $0}' teams.txt 76ers Philadelphia 51 31 0.622Celtics Boston 49 33 0.598Pacers Indiana 48 34 0.585awk命令使用实例awk命令使用实例 范围模式范围模式由逗号分隔的两组字符组成,从与第一个字符串匹配的记录开始,直到与第二个字符串的记录匹配为止的所有记录。 例如,显示从“Raptors”到 “Celtics”在内的记录,: [root@localhost ~]# awk '/Raptors/,/Celtics/ {print $0}' teams.txt Raptors Toronto 58 24 0.707 76ers Philadelphia 51 31 0.622Celtics Boston 49 33 0.598awk命令使用实例awk命令使用实例范围模式也可以使用关系表达式,例如,显示第四个字段等于31到第四个字段等于34 的记录: [root@localhost ~]# awk '$4 == 31 , $4 == 34 {print $0}' teams.txt 76ers Philadelphia 51 31 0.622Celtics Boston 49 33 0.598Pacers Indiana 48 34 0.585awk命令使用实例awk命令使用实例 特殊表达式模式Awk包括以下特殊模式。 BEGIN:在处理记录之前执行此操作。END:用于在处理记录之后执行此操作。BEGIN模式通常用于设置变量,END模式用于处理统计的数据。例如,下面将显示“Start Processing.”,然后显示第三个字段,最后显示”End Processing.”: [root@localhost ~]# awk 'BEGIN {print "Start Processing."};{print $3};END {print "End Processing."}' teams.txt Start Processing.6058514948End Processing.awk命令使用实例awk命令使用实例 内置变量Awk有许多内置变量,允许控制程序的处理方式。下面是一些常见的内置变量: NF:记录中的字段数NR:当前记录的编号FILENAME:当前正在处理的输入文件名称FS:字段分隔符RS:记录分隔符OFS:输出字段分隔符ORS:输出记录分隔符下面是一个显示如何打印文件名和行数的示例: [root@localhost ~]# awk 'END {print "File" , FILENAME , "contains" , NR , "lines."}' teams.txt File teams.txt contains 5 lines.总结Awk是最强大的文本处理工具之一。 本文原创地址:https://www.linuxprobe.com/awk-cmd-example.html编辑:逄增宝,审核员:逄增宝
虚拟网络控制台(VNC)是一个图形桌面共享软件,允许您使用键盘和鼠标远程控制另一台计算机。系统环境服务端:Centos7.7 Minimal客户端:Windows10客户端VNC-Viewer 6.20下载地址:https://www.realvnc.com/en/connect/download/viewer/安装桌面环境本实验中安装的系统没有安装桌面环境,我们需要自己安装,如果已经安装桌面了清跳过这一步。Centos7提供了"Cinnamon Desktop","MATE Desktop","GNOME Desktop","KDE Plasma Workspaces","LXQt Desktop","Xfce"让我们安装。 下面的命令列出可用环境组: [root@localhost ~]# yum grouplistLoaded plugins: fastestmirrorThere is no installed groups file.Maybe run: yum groups mark convert (see man yum)Loading mirror speeds from cached hostfile base: mirrors.tuna.tsinghua.edu.cn epel: mirrors.aliyun.com extras: mirrors.aliyun.com updates: mirrors.aliyun.comAvailable Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Cinnamon Desktop MATE Desktop Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative WorkstationAvailable Groups: Cinnamon Compatibility Libraries Console Internet Tools Development Tools Educational Software Electronic Lab Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell LXQt Desktop Legacy UNIX Compatibility MATE Milkymist Scientific Support Security Tools Smart Card Support System Administration Tools System Management TurboGears application framework XfceDone我们可以选择自己喜欢的桌面环境,在这里选择安装Xfce桌面: [root@localhost ~]# yum -y install epel-release && yum groupinstall Xfce创建一个用户[root@localhost ~]# useradd user1[root@localhost ~]# echo '123456'|passwd --stdin user1[root@localhost ~]# usermod -a -G wheel user1安装VNC Server在Centos仓库默认提供的是TigerVNC安装包,我们就安装这个: [root@localhost ~]# yum -y install tigervnc-server tigervnc-server-module切换到user1用户,运行vncserver命令创建一个初始配置并设置密码: [root@localhost ~]# su - user1[user1@localhost ~]$ vncserver :2 You will require a password to access your desktops. Password:Verify:Would you like to enter a view-only password (y/n)? nA view-only password is not used New 'localhost.localdomain:2 (user1)' desktop is localhost.localdomain:2 Starting applications specified in /home/user1/.vnc/xstartupLog file is /home/user1/.vnc/localhost.localdomain:2.log然后停止vncserver服务,目的就是创建密码和.vnc下面的文件。 [user1@localhost ~]$ vncserver -kill :2配置VNC Server编辑用户家目录下面的.vnc/xstartup文件 [user1@localhost ~]$ vim ~/.vnc/xstartup !/bin/sh xrdb $HOME/.Xresources xsetroot -solid grey xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm & startxfce4 &如果需要修改屏幕分辨率,可以修改~/.vnc/config文件,取消gemoetry前面的注释。 [user1@localhost ~]$ vim .vnc/config Supported server options to pass to vncserver upon invocation can be listed in this file. See the following manpages for more: vncserver(1) Xvnc(1). Several common ones are shown below. Uncomment and modify to your liking. securitytypes=vncauth,tlsvnc desktop=sandbox geometry=1920x1080 localhost alwaysshared 创建 Systemd Unit文件Unit文件方便快速的启动,停止,重启服务 [user1@localhost ~]$ sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service编辑vncserver@:2.service,替换文件里面的为user1用户, Type由默认的forking改为simple [user1@localhost ~]$ vim /etc/systemd/system/vncserver@:2.service [Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=simpleExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/sbin/runuser -l user1 -c "/usr/bin/vncserver %i"PIDFile=/home/user1/.vnc/%H%i.pidExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]WantedBy=multi-user.target启动vncserver服务 重新加载管理器配置 [user1@localhost ~]$ sudo systemctl daemon-reload 启动vncserver [user1@localhost ~]$ sudo systemctl start vncserver@:2客户端远程连接测试在windows10客户端打开VNC Viewer,输入地址和会话端口号:Centos7.7安装vncserver虚拟网络控制台Centos7.7安装vncserver虚拟网络控制台Centos7.7安装vncserver虚拟网络控制台Centos7.7安装vncserver虚拟网络控制台Centos7.7安装vncserver虚拟网络控制台Centos7.7安装vncserver虚拟网络控制台 总结如果需要将VNC服务器配置为多个用户启动显示,请使用vncserver命令创建初始配置并设置密码,然后使用其他端口创建新的服务文件。
SSHFS(SSH Filesystem)是一个基于FUSE的文件系统客户端,用于通过SSH连接远程目录。SSHFS使用的是SFTP协议,它是SSH的一个子系统,在大多数SSH服务器上默认启用简介SSHFS(SSH Filesystem)是一个基于FUSE的文件系统客户端,用于通过SSH连接远程目录。SSHFS使用的是SFTP协议,它是SSH的一个子系统,在大多数SSH服务器上默认启用 与其他网络文件系统(如NFS和Samba)相比,SSHFS的优势在于它不需要在服务器端进行任何额外的配置。要使用SSHFS,您只需要SSH访问远程服务器。 系统环境Cetnos7.7 Windows10 安装Centos安装SSHFS[root@localhost ~]# yum -y install epel-release && yum -y install sshfsWindows10安装SSHFS需要安装最新版本的WinFsp和SSHFS-Win, WinFsp下载地址:https://github.com/billziss-gh/winfsp/releases/SSHFS-Win下载地址:https://github.com/billziss-gh/sshfs-win/releases在Centos中挂载远程文件系统SSHFS使用格式: sshfs [user@]host:[dir] mountpoint [options]如果没有指定远程目录,默认会连接用户的家目录。 例如,远程主机需要访问root的家目录,在这里使用root用户远程访问。挂载点这里使用/mnt文件夹。 [root@localhost ~]# sshfs root@192.168.0.105: /mntroot@192.168.0.105's password:使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录系统将提示您输入用户密码。为了避免每次装载远程目录时键入密码,可以生成SSH密钥并设置无密码登录。 如果需要开机自动挂载,可以在/etc/fstab文件中添加: [root@localhost ~]# echo 'root@192.168.0.105:/Shares /mnt fuse.sshfs defaults 0 0'>> /etc/fstab前提是需要设置无密码登录,不然开机不能挂载。 卸载远程文件系统[root@localhost ~]# fusermount -u /mnt/或者[root@localhost ~]# umount /mnt在Windows10中挂载远程文件系统默认添加的远程目录是用户的家目录。 右键此电脑 - 映射网络驱动器使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录如果需要远程挂载根目录,可以如下操作:使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录使用SSHFS文件系统通过SSH远程挂在目录 总结由于SSHFS使用SSH协议,所以服务器和客户端之间传输的所有数据都必须加密和解密。与NFS相比,这会导致性能略有下降,并且客户端和服务器上的CPU使用率更高。sshfs可以临时用来访问远程文件。
搜狗公司开源了其 C++ 服务器引擎 Sogou C++ Workflow,这一引擎实现了高性能、轻量级落地,还引入任务流概念,实现了计算任务与通信任务的统一和协同调度。搜狗服务器引擎Sogou C++ Workflow开源啦!搜狗服务器引擎Sogou C++ Workflow开源啦! 据介绍,目前该引擎支撑着搜狗几乎所有后端 C++ 在线服务,包括所有搜索服务、云输入法与在线广告等,每日处理数百亿请求。 Sogou C++ Workflow 在设计之初,就秉持着高性能与轻量级两个核心理念。长久以来,业界中优化服务器性能都主要专注于如何跑满 cpu、如何单独地让网络请求极速响应等方面。而此次上线的搜狗 Workflow 则更专注于如何让各种网络资源被具体的调度器管理,使其尽可能地全部调度起来。 搜狗服务器引擎Sogou C++ Workflow开源啦!搜狗服务器引擎Sogou C++ Workflow开源啦! 另一方面,对多通信计算资源融为一体的解决方案,进一步提升了 Workflow 引擎的性能。过去开发者在面临选择高吞吐网络框架时,需要自己面对不同计算资源比例而划分不同大小的线程池。然而每种计算具体资源需求比例是动态变化的,重要性也不一样,后端响应时长也是动态变动。Sogou C++ Workflow 使得 C++ 服务器引擎也能像 Go 语言一样,实现网络资源异步调度,并且进一步打通计算与磁盘等资源。 此项目最大的亮点可能是创新性引入了任务流的概念,Sogou C++ Workflow 将资源高度封装,用户再也接触不到连接池、线程池,包括想要做 aio 时的文件 fd 与各种异步通知机制。这就意味着,在开发阶段开发人员仅仅需要了解业务关系而不用关心内部细节,帮助开发者们实现自己复杂的业务逻辑。 开发人员可以利用 Sogou C++ Workflow 封装好的各种任务来动态或静态组建自己的业务逻辑,如下图所示,不同类型的任务都可以被串行、并行到一起: 根据资料,除了各种创新设计以外,Sogou C++ Workflow 还拥有友好的用户体验。Sogou C++ Workflow 原生实现了对http、redis、mysql 和 kafka 等协议的支持,可以直接作为这些协议的客户端使用。并且在其基础上开发了一套更加易用的 Sogou RPC,实现了与 brpc 和 thrift 互通,并且可以通过 http+json 或 IDL 实现跨语言。 开发团队透露,Sogou RPC 项目也会在不久的将来开源。 Http Server 性能实测:Sogou C++ Workflow VS nginx、brpc 搜狗团队也提供了 Sogou C++ Workflow 和 nginx、brpc 两个主流系统的 http server 性能对比。 测试环境:选取了最基本的测试场景:wrk 或者 wrk2 跨机做 client,单 server,长连接,CPU:40 核 E5-2630 v4 @ 2.20GHz,内存:192GB,网卡:25000Mb/s。nginx 配置了 auto 的进程数(与核数一致),brpc 配置了 40 个 nthreads,workflow 配置了 16 个 poller 线程和 20 个 handler 线程。 测试一:不同并发数对 QPS 的影响(越高越好)搜狗服务器引擎Sogou C++ Workflow开源啦!搜狗服务器引擎Sogou C++ Workflow开源啦! 结论:随着压测并发数的增加,server 的 QPS 会随着增高。可以看到 Workflow 无论是低并发数还是高并发数的情况下,QPS 依然比 nginx 和 brpc 要高,尤其是并发数超过 128 的时候优势更加明显,Workfow 对于小包基本能保证 50w 的 QPS,说明内部对网络资源的高并发调度做了很多优化。 测试二:不同数据大小对 QPS 的影响(越高越好)搜狗服务器引擎Sogou C++ Workflow开源啦!搜狗服务器引擎Sogou C++ Workflow开源啦! 结论:此处的返回包大小是 http 请求的 body 大小,随着返回包增大,QPS 会有所下降,我们希望 QPS 依然尽可能保持平稳不要下降得太快。Workflow 在同并发下的性能依然比其他两个系统要好,说明网络收发和其他调用之间的调度协调得更好。 测试三:固定 QPS 下的延迟分布 CDF 图(越左越好,越直越好)搜狗服务器引擎Sogou C++ Workflow开源啦!搜狗服务器引擎Sogou C++ Workflow开源啦! 结论:本测试由 wrk2 进行固定 QPS 的压测,其中还有 1% 的长尾请求 Outiler,长尾请求不计入结果,因为我们关注的是模拟真实情况下普通请求能否被及时处理。由于 nginx 在其他测试中性能略差一截,因此没有对其进行 CDF 对比。可以看到在不同比例的分布中,Workflow 的延迟更低、且最慢的那些(0.99 到 1.00 之间)延迟增长也相对缓慢,说明 Workflow 对长尾处理更及时。
windows系统和linux系统,是目前网站服务器使用最多的2大服务器系统,当然,还有unix也可以作为服务器系统,只是已经被边缘化,很少见到。那么,在我们购买网站服务器时,是选择windows系统好,还是选择linux系统好呢?这还是要看具体情况而定。网站服务器系统,选windows还是linux?网站服务器系统,选windows还是linux? 一、服务器配置比较低时,最好使用linux系统。对于一个电脑新手,刚开始做网站时,都会选择入门级的服务器,我刚开始做网站时,就是这样的。我购买了一台入门级服务器:CPU是单核的,内存是512M的,硬盘是20G,带宽是1M,这样的配置,在当时的阿里云服务器中最最低端的,但是总比虚拟主机要好使。windows系统是非常吃内存的,系统本身最低都要1G以上的内存,所以,我的这个配置没法安装windows系统。而linux系统对硬件要求非常低,512M的内存已经足够用,现在,我服务器上运行了4个网站,依然流畅自如。网站服务器系统,选windows还是linux?网站服务器系统,选windows还是linux? 二、使用PHP做网站后台时,最好选linux系统。如果我们的网站要使用php语言来开发,最好是选择linux系统作为服务器的系统,因为,php在linux系统下的兼容性非常完美,这得益于linux系统的开源和免费,linux + apahce + mysql + php这样的组合,就深受众多站长的喜爱。就拿用户量巨大的网站程序wordpress来说,它就是php开发的,在linux下可以轻松配置伪静态,虽然也能在windows系统上使用,但是配置伪静态时容易出现问题。当然,如果你选择asp.net语言来开发网站,那最好的选择是windows系统,因为asp.net语言是微软开发的一种网站语言。 网站服务器系统,选windows还是linux?网站服务器系统,选windows还是linux? 三、不熟悉linux的,最好选择windows系统。如果你对linux系统不太熟悉,又急于开始自己的网站,那最好的选择就是windows系统了。因为,我们平时在电脑上就经常操作的就是windows系统,上手容易,搭建网站也就会很快。相对于linux系统的命令行界面,windows系统的图形界面对用户更加友好,比如:我们要安装PHP环境,windwos下我们只需要下载一个wamp这样的集成环境,然后双击安装,就可以很快安装成功;而linux系统安装php环境就比较麻烦,需要输入相关的命令才可以安装,不精通linux系统的命令,是无法操作的。网站服务器系统,选windows还是linux?网站服务器系统,选windows还是linux? 总之,是选择windows系统还是选择linux系统,这要根据我们自己的具体情况而定。不过,我还是强烈建议使用linux系统,这样可以避免很多不必要的问题。
你是某公司的网络管理员,公司办公网需要接入互联网,公司只向 ISP 申请了一条专线,该专线分配了一个公司 IP 地址,配置实现全公司的主机都能访问外网。 技术原理NAT 将网络划分为内部网络和外部网络两部分,局域网主机利用 NAT 访问网络时,是将局域网内部的本地地址转换为全局地址(互联网合法的 IP 地址)后转发数据包;NAT 分为两种类型:NAT(网络地址转换)和 NAPT(网络端口地址转换 IP 地址对应一个全局地址)。NAPT:使用不同的端口来映射多个内网 IP 地址到一个指定的外网 IP 地址,多对一。NAPT 采用端口多路复用方式。内部网络的所有主机均可共享一个合法外部 IP 地址实现对 Internet 的访问,从而可以最大限度地节约 IP 地址资源。同时,又可隐藏网络内部的所有主机,有效避免来自 Internet 的攻击。因此,目前网络中应用最多的就是端口多路复用方式。 ISP(Internet Service Provider),互联网服务提供商,即向广大用户综合提供互联网接入业务、信息业务和增值业务的电信运营商。ISP是经国家主管部门批准的正式运营企业,享受国家法律保护。 实验步骤新建 Packet Tracer 拓扑图 网络端口地址转换 NAPT 配置网络端口地址转换 NAPT 配置 (1)R1 为公司出口路由器,其与 ISP 路由器之间通过 V.35 电缆串口连接,DCE 端连接在 R1 上,配置其时钟频率 64000;(2)配置 PC 机、服务器及路由器接口 IP 地址;(3)在各路由器上配置静态路由协议,让 PC 间能相互 Ping 通;(4)在 R1 上配置 NAPT。(5)在 R1 上定义内外网络接口。(6)验证主机之间的互通性。 实验设备PC 2 台;Server-PT 1 台;Switch_2950-24 1 台 Router-PT 2 台;直通线;交叉线;DCE串口线 PC1 192.168.1.2255.255.255.0192.168.1.1 PC2 192.168.1.3255.255.255.0192.168.1.1 Server 200.1.2.2255.255.255.0200.1.2.1 R1 enconf thost R1int fa 0/0ip address 192.168.1.1 255.255.255.0no shutdownint s 2/0ip address 200.1.1.1 255.255.255.0no shutdownclock rate 64000 R2 enconf thost R2int s 2/0ip address 200.1.1.2 255.255.255.0no shutdownint fa 0/0ip address 200.1.2.1 255.255.255.0no shutdown R1 exitip route 200.1.2.0 255.255.255.0 200.1.1.2 R2 exitip route 192.168.1.0 255.255.255.0 200.1.1.1endshow ip route PC1 CMDping 200.1.2.2 (success) Web 浏览器http://200.1.2.2 (success) R1 int fa 0/0ip nat insideint s 2/0ip nat outsideexitaccess-list 1 permit 192.168.1.0 0.0.0.255ip nat pool jaking 200.1.1.3 200.1.1.3 netmask 255.255.255.0 #设置名称为jaking的地址池,起始和终止IP都是200.1.1.3ip nat inside source list 1 pool jaking overload (无 overload 表示多对多,有 overload 表示多对一)endshow ip nat translations(无结果) PC1 Web 浏览器http://200.1.2.2 (success) R1 show ip nat translations(有 1 个结果) PC2 Web 浏览器http://200.1.2.2 (success) R1 show ip nat translations(有 2 个结果)实战演练R1 Continue with configuration dialog? [yes/no]: n Press RETURN to get started! Router>enRouter#conf tEnter configuration commands, one per line. End with CNTL/Z.Router(config)#host R1R1(config)#int fa 0/0R1(config-if)#ip add 192.168.1.1 255.255.255.0R1(config-if)#no shut %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R1(config-if)#int s 2/0R1(config-if)#ip add 200.1.1.1 255.255.255.0R1(config-if)#no shut %LINK-5-CHANGED: Interface Serial2/0, changed state to downR1(config-if)#clock rate 64000R1(config-if)# R2 Continue with configuration dialog? [yes/no]: n Press RETURN to get started! Router>enRouter#conf tEnter configuration commands, one per line. End with CNTL/Z.Router(config)#host R2R2(config)#int s 2/0R2(config-if)#ip add 200.1.1.2 255.255.255.0R2(config-if)#no shut %LINK-5-CHANGED: Interface Serial2/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up R2(config-if)#int fa 0/0R2(config-if)#ip add 200.1.2.1 255.255.255.0R2(config-if)#no shut %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R2(config-if)# R1 R1(config-if)#exitR1(config)#ip route 200.1.2.0 255.255.255.0 200.1.1.2 R2 R2(config-if)#exitR2(config)#ip route 192.168.1.0 255.255.255.0 200.1.1.1R2(config)#endR2#%SYS-5-CONFIG_I: Configured from console by console R2#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set S 192.168.1.0/24 [1/0] via 200.1.1.1C 200.1.1.0/24 is directly connected, Serial2/0C 200.1.2.0/24 is directly connected, FastEthernet0/0 PC1 CMDping 200.1.2.2 (success) PC>ipconfig IP Address......................: 192.168.1.2Subnet Mask.....................: 255.255.255.0Default Gateway.................: 192.168.1.1 PC>ping 200.1.2.2 Pinging 200.1.2.2 with 32 bytes of data: Request timed out.Reply from 200.1.2.2: bytes=32 time=24ms TTL=126Reply from 200.1.2.2: bytes=32 time=25ms TTL=126Reply from 200.1.2.2: bytes=32 time=20ms TTL=126 Ping statistics for 200.1.2.2: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 20ms, Maximum = 25ms, Average = 23ms PC>ping 200.1.2.2 Pinging 200.1.2.2 with 32 bytes of data: Reply from 200.1.2.2: bytes=32 time=25ms TTL=126Reply from 200.1.2.2: bytes=32 time=20ms TTL=126Reply from 200.1.2.2: bytes=32 time=23ms TTL=126Reply from 200.1.2.2: bytes=32 time=25ms TTL=126 Ping statistics for 200.1.2.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 20ms, Maximum = 25ms, Average = 23ms Web 浏览器http://200.1.2.2 (success)网络端口地址转换 NAPT 配置网络端口地址转换 NAPT 配置 PC2 CMDping 200.1.2.2 (success) PC>ipconfig IP Address......................: 192.168.1.3Subnet Mask.....................: 255.255.255.0Default Gateway.................: 192.168.1.1 PC>ping 200.1.2.2 Pinging 200.1.2.2 with 32 bytes of data: Reply from 200.1.2.2: bytes=32 time=31ms TTL=126Reply from 200.1.2.2: bytes=32 time=17ms TTL=126Reply from 200.1.2.2: bytes=32 time=19ms TTL=126Reply from 200.1.2.2: bytes=32 time=23ms TTL=126 Ping statistics for 200.1.2.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 17ms, Maximum = 31ms, Average = 22ms Web 浏览器http://200.1.2.2 (success)网络端口地址转换 NAPT 配置网络端口地址转换 NAPT 配置 R1 R1(config)#int fa 0/0R1(config-if)#ip nat insideR1(config-if)#int s 2/0R1(config-if)#ip nat outsideR1(config-if)#exitR1(config)#access-list 1 permit 192.168.1.0 0.0.0.255R1(config)#ip nat pool jaking 200.1.1.3 200.1.1.3 netmask 255.255.255.0R1(config)#ip nat inside source list 1 pool jaking overloadR1(config)#endR1#%SYS-5-CONFIG_I: Configured from console by console R1#show ip nat translationsR1# PC1 Web 浏览器http://200.1.2.2 (success) R1show ip nat translations(有 1 个结果) R1#show ip nat translationsPro Inside global Inside local Outside local Outside globaltcp 200.1.1.3:1026 192.168.1.2:1026 200.1.2.2:80 200.1.2.2:80 PC2 Web 浏览器http://200.1.2.2 (success) R1show ip nat translations(有 2 个结果) R1#show ip nat translationsPro Inside global Inside local Outside local Outside globaltcp 200.1.1.3:1026 192.168.1.2:1026 200.1.2.2:80 200.1.2.2:80tcp 200.1.1.3:1024 192.168.1.3:1026 200.1.2.2:80 200.1.2.2:80总结至此,用思科模拟器进行网络端口地址转换 NAPT 配置完毕。
虚拟网络控制台(VNC)是一个图形桌面共享软件,允许您使用键盘和鼠标远程控制另一台计算机。系统环境服务端:Ubuntu 18.04 Server LTS客户端:Windows10客户端VNC-Viewer 6.20下载地址:https://www.realvnc.com/en/connect/download/viewer/安装桌面环境本实验中安装的系统没有安装桌面环境,我们需要自己安装,如果已经安装桌面了清跳过这一步。 我们可Ubuntu提供了许多桌面环境,可以选择自己喜欢的桌面环境,在这里选择安装Xfce4桌面: bpang@ubuntu1804:~$ sudo apt install xfce4*安装VNC Server安装仓库提供的vnc4server: bpang@ubuntu1804:~$ sudo apt install vnc4server运行vncserver命令创建一个初始配置并设置密码: bpang@ubuntu1804:~$ vncserver You will require a password to access your desktops. Password:Verify: New 'ubuntu1804:1 (bpang)' desktop is ubuntu1804:1 Creating default startup script /home/bpang/.vnc/xstartupStarting applications specified in /home/bpang/.vnc/xstartupLog file is /home/bpang/.vnc/ubuntu1804:1.logUbuntu 18.04 LTS安装vncserver虚拟网络控制台Ubuntu 18.04 LTS安装vncserver虚拟网络控制台然后停止vncserver服务: bpang@ubuntu1804:~$ vncserver -kill :1Killing Xvnc4 process ID 10260Ubuntu 18.04 LTS安装vncserver虚拟网络控制台Ubuntu 18.04 LTS安装vncserver虚拟网络控制台 配置VNC Server编辑用户家目录下面的.vnc/xstartup文件 bpang@ubuntu1804:~$ vim .vnc/xstartup !/bin/sh Uncomment the following two lines for normal desktop: unset SESSION_MANAGERexec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesxsetroot -solid greyvncconfig -iconic & x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & x-window-manager & startxfce4 &Ubuntu 18.04 LTS安装vncserver虚拟网络控制台Ubuntu 18.04 LTS安装vncserver虚拟网络控制台 设置vncserver开机启动在/etc/init.d文件夹下面创建vncserver文件,export USER=’bpang’改成自己的用户名 bpang@ubuntu1804:~$ sudo vim /etc/init.d/vncserver !/bin/bash export USER='bpang' eval cd ~$USER case "$1" in start) su $USER -c '/usr/bin/vncserver :1' echo "Starting VNC server for $USER " ;; stop) su $USER -c '/usr/bin/vncserver -kill :1' echo "vncserver stopped" ;; *) echo "Usage: /etc/init.d/vncserver {start|stop}" exit 1 ;; esacexit 0给vncserver添加执行权限 bpang@ubuntu1804:~$ sudo chmod +x /etc/init.d/vncserver开机启动设置 bpang@ubuntu1804:~$ sudo update-rc.d vncserver defaultsbpang@ubuntu1804:~$ sudo service vncserver start客户端远程连接测试在windows10客户端打开VNC Viewer,输入地址和回话端口号:Ubuntu 18.04 LTS安装vncserver虚拟网络控制台Ubuntu 18.04 LTS安装vncserver虚拟网络控制台 Ubuntu 18.04 LTS安装vncserver虚拟网络控制台Ubuntu 18.04 LTS安装vncserver虚拟网络控制台 总结如果需要将VNC服务器配置为多个用户启动显示,请使用vncserver命令创建初始配置并设置密码,然后使用其他端口创建新的服务文件。
timeout是一个命令行实用程序,它运行指定的命令,如果在给定的时间段后仍在运行,则终止该命令。timeout命令是GNU核心实用程序软件包的一部分,该软件包几乎安装在所有Linux发行版中如何使用语法格式: timeout [OPTION] DURATION COMMAND [ARG]...DURATION可以是正整数或浮点数,后跟可选的后缀: s – 秒 (默认)m – 分钟h – 小时d – 天如果不添加任何单位,默认是秒。如果DURATION为0,则关联的超时是禁用的。 实例5秒后终止ping操作: [root@localhost ~]# timeout 5 ping www.baidu.comPING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=55 time=16.3 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=55 time=16.0 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=55 time=16.7 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=4 ttl=55 time=16.0 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=5 ttl=55 time=17.6 msLinux中运行有时间限制的命令(timeout)Linux中运行有时间限制的命令(timeout)5分钟之后终止ping操作: [root@localhost ~]# timeout 5m ping www.baidu.com1天之后终止ping操作: [root@localhost ~]# timeout 1d ping www.baidu.com2.5秒之后终止ping操作: [root@localhost ~]# timeout 2.5s ping www.baidu.comPING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=55 time=14.9 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=55 time=15.6 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=3 ttl=55 time=15.6 msLinux中运行有时间限制的命令(timeout)Linux中运行有时间限制的命令(timeout) 发送指定的信号如果未给出任何信号,则当达到时间限制时,timeout将SIGTERM信号发送到受管命令。可以使用-s(-signal)选项指定要发送的信号。 发送SIGKILL信号给ping命令,5秒钟后终止: [root@localhost ~]# sudo timeout -s SIGKILL 5s ping www.baidu.comPING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=55 time=17.2 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=55 time=16.6 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=55 time=16.7 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=4 ttl=55 time=16.2 ms64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=5 ttl=55 time=16.7 msKilledLinux中运行有时间限制的命令(timeout)Linux中运行有时间限制的命令(timeout)信号可以指定他的名字也可以指定他序号。下面使用的事SIGKILL的序号,5秒钟后终止操作: [root@localhost ~]# sudo timeout -s 9 5s ping www.baidu.comPING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=55 time=15.5 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=55 time=16.3 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=3 ttl=55 time=14.9 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=4 ttl=55 time=16.0 ms64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=5 ttl=55 time=22.0 msKilledLinux中运行有时间限制的命令(timeout)Linux中运行有时间限制的命令(timeout)想要知道全部可用的信号,请使用 kill -l该命令查看全部的信号。 [root@localhost ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR111) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+338) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+843) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+1348) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-1253) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-758) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-263) SIGRTMAX-1 64) SIGRTMAX [root@localhost ~]#Linux中运行有时间限制的命令(timeout)Linux中运行有时间限制的命令(timeout) 停掉卡住的进程SIGTERM,当超过时间限制时发送的默认信号可以被某些进程捕获或忽略。在这种情况下,进程在发送终止信号后继续运行。 要确保被执行的的命令终止,请使用-k(--kill after)选项,后面加一个时间。当达到给定的时间限制后会强制结束。 在下面的示例中,timeout命令运行一分钟,如果命令没有结束,将在10秒后终止命令: [root@localhost ~]# timeout -k 10s 1m sh test.sh运行在前台默认情况下,timeout在后台运行托管命令。如果要在前台运行该命令,请使用--foreground选项: [root@localhost ~]# timeout --foreground 5m ./script.sh总结timeout命令用于运行具有时间限制的命令。通常情况下只需要给定时间限制和命令就足够了。
Secure Shell (SSH)是一种加密协议,可以在不安全的网络上安全地传输数据。X11- forwarding是一个安全的shell特性,它允许通过现有的SSH shell会话转发X11连接,用于在服务器上运行X11程序,而ssh-client通过用户的X11-server显示图形窗口。Secure Shell (SSH)是一种加密协议,可以在不安全的网络上安全地传输数据。X11- forwarding是一个安全的shell特性,它允许通过现有的SSH shell会话转发X11连接,用于在服务器上运行X11程序,而ssh-client通过用户的X11-server显示图形窗口。 为什么使用X11转发虽然SSH (Secure Shell)允许用户在客户机上远程连接服务器,但是这种Shell访问只允许用户和服务器应用程序之间基于文本的交互。 然而,X11是一个允许服务器应用程序显示图形界面的系统(本质上是基于像素的输出,显示自己的窗口)。这是一个长期建立的协议,但它传输数据没有加密。 X11-forwarding允许通过已经建立和加密的SSH连接安全地运行X11程序。 准备工作操作系统版本:Centos7.7 MinimalXming 6.9 Xming下载地址: https://sourceforge.net/projects/xming/Xshell 6.0Putty配置先在windows上面安装xming软件包Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 安装完成之后查看桌面右下角的X图标。记住上面显示的数字。Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 然后设置x11转发,打开xshell软件-文件-默认会话属性Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 点击“隧道”- 勾选“转发X11连接到(X)”,选择“X DISPLAY(D)”,后面输入的内容就是之前桌面右下角显示的数字。 Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 使用xshell连接centos7.7,安装xorg-x11-xauth软件包 Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 [root@client ssh]# yum -y install xorg-x11-xauth装完之后,退出ssh连接,然后重新连接。接着安装图形界面可以使用的软件包测试一下。 [root@client ~]# yum -y install firefox gedit[root@client ~]# gedit &[root@client ~]# firefox &Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 使用putty打开putty软件,找到X11,勾选“启用X11转发”,X display location 输入和桌面右下角显示相同的数字。 Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 返回上面的session选项卡,输入服务器地址,远程连接服务器。 Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发 测试一下吧 Centos7 使用ssh进行x11图形界面转发Centos7 使用ssh进行x11图形界面转发
如果有一个字符串要确保全部是大写的,只需通过tr命令替换: [root@localhost ~]# echo "Hello World" | tr [:lower:] [:upper:]HELLO WORLD下面是在脚本中使用此命令的示例,需要确保添加到文件中的所有文本都是大写,以保持一致性: !/bin/bash read -p "Enter department name: " deptecho $dept | tr [:lower:] [:upper:] >> depts将顺序切换为[:upper:] [:lower:]会会将所有大写字符转换成小写: !/bin/bash read -p "Enter department name: " deptecho $dept | tr [:upper:] [:lower:] >> depts也可以使用”a-z” “A-Z”来替换大小写。 !/bin/bash read -p "Enter department name: " deptecho $dept | tr a-z A-Z>> depts下面几个函数是tr内置的: [:alnum:] 所有字母和数字[:alpha:] 所有字母[:blank:] 所有空白[:cntrl:] 所有控制字符[:digit:] 所有数字[:graph:] 所有可打印字符,不包括空格[:lower:] 所有小写字符[:print:] 所有可打印字符,包括空格[:punct:] 所有的标点符号[:upper:] 所有大写字符使用awk在awk中可以使用toupper()和tolower()函数,来转换大小写。下面实例内容在文本里面写入,将输入的小写内容转换为大写: !/bin/bash read -p "Enter department name: " deptecho $dept | awk ‘{print toupper($0)}’ >> depts下面实例内容在文本里面写入,将输入的大写内容转换为小写: !/bin/bash read -p "Enter department name: " deptecho $dept | awk ‘{print tolower($0)}’ >> depts使用sed在sed中可以使用U&和L&函数,来转换大小写。 使用sed,将小写转换成大写: !/bin/bash read -p "Enter department name: " deptecho $dept | sed 's/[a-z]/U&/g' >> depts使用sed,将大写转换成小写: !/bin/bash read -p "Enter department name: " deptecho $dept | sed 's/[A-Z]/L&/g' >> depts总结在linux中有很多方式可以替换大小写字母,你可以选择一个能记住的命令使用。
XFS文件系统是硅谷图形公司(Silicon Graphics Inc,简称SGI)开发的用于IRIX(一个UNIX操作系统)的文件系统,后将XFS移植到Linux操作系统上。XFS是高级日志文件系统,其特点极具伸缩性,同时也很健壮。2000年5月XFS通过GNU通用公共许可证移植到Linux系统上,通过十多年的不断修改已经成为一款非常成熟的文件系统。在多项针对XFS的性能测试上,XFS都取得了不俗的成绩,高并发环境下甚至已经超过ext4。一、XFS文件系统的备份与恢复XFS文件系统提供了整个分区备份的工具xfsdump供用户使用,用户可以在不借助第三方软件的情况下对XFS文件系统上的数据实施备份。 创建XFS分区及测试文件[root@localhost ~]# ls /dev/sd*/dev/sda /dev/sda1 /dev/sda2 /dev/sdb[root@localhost ~]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command. Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x08a5199d Device Boot Start End Blocks Id System Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pFirst sector (2048-41943039, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1GPartition 1 of type Linux and of size 1 GiB is set Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x08a5199d Device Boot Start End Blocks Id System/dev/sdb1 2048 2099199 1048576 83 Linux Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.[root@localhost ~]# partprobeWarning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.[root@localhost ~]# ls /dev/sd*/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1[root@localhost ~]# mkfs.xfs -f /dev/sdb1meta-data=/dev/sdb1 isize=512 agcount=4, agsize=65536 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=262144, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0[root@localhost ~]# blkid /dev/sdb1 /dev/sdb1: UUID="61a5e59d-92d3-458d-ac09-7d945469cda6" TYPE="xfs" [root@localhost ~]# mkdir /file[root@localhost ~]# echo "/dev/sdb1 /file xfs defaults 0 0" >> /etc/fstab [root@localhost ~]# mount -a[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/rhel-root 17G 1.9G 16G 12% /devtmpfs 901M 0 901M 0% /devtmpfs 912M 0 912M 0% /dev/shmtmpfs 912M 8.7M 903M 1% /runtmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sr0 3.8G 3.8G 0 100% /yum/dev/sda1 1014M 143M 872M 15% /boottmpfs 183M 0 183M 0% /run/user/0/dev/sdb1 1014M 33M 982M 4% /file[root@localhost ~]# cd /file/[root@localhost file]# ls[root@localhost file]# touch file{1..100}[root@localhost file]# lsfile1 file16 file23 file30 file38 file45 file52 file6 file67 file74 file81 file89 file96file10 file17 file24 file31 file39 file46 file53 file60 file68 file75 file82 file9 file97file100 file18 file25 file32 file4 file47 file54 file61 file69 file76 file83 file90 file98file11 file19 file26 file33 file40 file48 file55 file62 file7 file77 file84 file91 file99file12 file2 file27 file34 file41 file49 file56 file63 file70 file78 file85 file92file13 file20 file28 file35 file42 file5 file57 file64 file71 file79 file86 file93file14 file21 file29 file36 file43 file50 file58 file65 file72 file8 file87 file94file15 file22 file3 file37 file44 file51 file59 file66 file73 file80 file88 file95备份XFS分区[root@localhost file]# mkdir /backup [root@localhost file]# yum install -y xfsdump[root@localhost file]# xfsdump -f /backup/file.bak /file 利用xfsdump备份挂载点/file对应的分区 xfsdump: using file dump (drive_simple) strategyxfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control ============================= dump label dialog ============================== 输入dump会话标签 please enter label for this dump session (timeout in 300 sec) -> file.baksession label entered: "file.bak" --------------------------------- end dialog --------------------------------- xfsdump: level 0 dump of localhost.localdomain:/filexfsdump: dump date: Thu Oct 31 22:16:02 2019xfsdump: session id: 02a1445f-5ff3-4518-ab2c-888d9e2a4c44xfsdump: session label: "file.bak"xfsdump: ino map phase 1: constructing initial dump listxfsdump: ino map phase 2: skipping (no pruning necessary)xfsdump: ino map phase 3: skipping (only one dump stream)xfsdump: ino map construction completexfsdump: estimated dump size: 52800 bytes ============================= media label dialog ============================= 输入媒体标签 please enter label for media in drive 0 (timeout in 300 sec) -> filemedia label entered: "file" --------------------------------- end dialog --------------------------------- xfsdump: creating dump session media file 0 (media 0, file 0)xfsdump: dumping ino mapxfsdump: dumping directoriesxfsdump: dumping non-directory filesxfsdump: ending media filexfsdump: media file size 86544 bytesxfsdump: dump size (non-dir files) : 0 bytesxfsdump: dump complete: 27 seconds elapsedxfsdump: Dump Summary:xfsdump: stream 0 /backup/file.bak OK (success)xfsdump: Dump Status: SUCCESS[root@localhost file]# ls /backup/ 已经成功创建备份文件 file.bak恢复过程[root@localhost file]# lsfile1 file16 file23 file30 file38 file45 file52 file6 file67 file74 file81 file89 file96file10 file17 file24 file31 file39 file46 file53 file60 file68 file75 file82 file9 file97file100 file18 file25 file32 file4 file47 file54 file61 file69 file76 file83 file90 file98file11 file19 file26 file33 file40 file48 file55 file62 file7 file77 file84 file91 file99file12 file2 file27 file34 file41 file49 file56 file63 file70 file78 file85 file92file13 file20 file28 file35 file42 file5 file57 file64 file71 file79 file86 file93file14 file21 file29 file36 file43 file50 file58 file65 file72 file8 file87 file94file15 file22 file3 file37 file44 file51 file59 file66 file73 file80 file88 file95[root@localhost file]# rm -rf *[root@localhost file]# ls[root@localhost file]# xfsrestore -f /backup/file.bak /filexfsrestore: using file dump (drive_simple) strategyxfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and controlxfsrestore: searching media for dumpxfsrestore: examining media file 0xfsrestore: dump description: xfsrestore: hostname: localhost.localdomainxfsrestore: mount point: /filexfsrestore: volume: /dev/sdb1xfsrestore: session time: Thu Oct 31 22:16:02 2019xfsrestore: level: 0xfsrestore: session label: "file.bak"xfsrestore: media label: "file"xfsrestore: file system id: 61a5e59d-92d3-458d-ac09-7d945469cda6xfsrestore: session id: 02a1445f-5ff3-4518-ab2c-888d9e2a4c44xfsrestore: media id: 2d1d9f33-dff3-4cfa-a2f6-bf65bd8f242bxfsrestore: using online session inventoryxfsrestore: searching media for directory dumpxfsrestore: reading directoriesxfsrestore: 1 directories and 100 entries processedxfsrestore: directory post-processingxfsrestore: restoring non-directory filesxfsrestore: restore complete: 0 seconds elapsedxfsrestore: Restore Summary:xfsrestore: stream 0 /backup/file.bak OK (success)xfsrestore: Restore Status: SUCCESS[root@localhost file]# ls 已经成功恢复被删除的文件 file1 file16 file23 file30 file38 file45 file52 file6 file67 file74 file81 file89 file96file10 file17 file24 file31 file39 file46 file53 file60 file68 file75 file82 file9 file97file100 file18 file25 file32 file4 file47 file54 file61 file69 file76 file83 file90 file98file11 file19 file26 file33 file40 file48 file55 file62 file7 file77 file84 file91 file99file12 file2 file27 file34 file41 file49 file56 file63 file70 file78 file85 file92file13 file20 file28 file35 file42 file5 file57 file64 file71 file79 file86 file93file14 file21 file29 file36 file43 file50 file58 file65 file72 file8 file87 file94file15 file22 file3 file37 file44 file51 file59 file66 file73 file80 file88 file95二、XFS文件系统的检查和修复创建XFS测试分区[root@localhost file]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command. Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x08a5199d Device Boot Start End Blocks Id System/dev/sdb1 2048 2099199 1048576 83 Linux Command (m for help): nPartition type: p primary (1 primary, 0 extended, 3 free) e extendedSelect (default p): pPartition number (2-4, default 2): First sector (2099200-41943039, default 2099200): Using default value 2099200Last sector, +sectors or +size{K,M,G} (2099200-41943039, default 41943039): +1GPartition 2 of type Linux and of size 1 GiB is set Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x08a5199d Device Boot Start End Blocks Id System/dev/sdb1 2048 2099199 1048576 83 Linux/dev/sdb2 2099200 4196351 1048576 83 Linux Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.[root@localhost file]# partprobeWarning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.[root@localhost file]# ls /dev/sd*/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1 /dev/sdb2[root@localhost file]# mkfs.xfs /dev/sdb2meta-data=/dev/sdb2 isize=512 agcount=4, agsize=65536 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=262144, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0检查XFS文件系统,如果检查过程中发现问题将会列出[root@localhost file]# xfs_repair -n /dev/sdb2Phase 1 - find and verify superblock...Phase 2 - using internal log - zero log... - scan filesystem freespace and inode maps... - found root inode chunk Phase 3 - for each AG... - scan (but don't clear) agi unlinked lists... - process known inodes and perform inode discovery... - agno = 0 - agno = 1 - agno = 2 - agno = 3 - process newly discovered inodes... Phase 4 - check for duplicate blocks... - setting up duplicate extent list... - check for inodes claiming duplicate blocks... - agno = 0 - agno = 1 - agno = 2 - agno = 3 No modify flag set, skipping phase 5Phase 6 - check inode connectivity... - traversing filesystem ... - traversal finished ... - moving disconnected inodes to lost+found ... Phase 7 - verify link counts...No modify flag set, skipping filesystem flush and exiting.自动检查并修复XFS文件系统[root@localhost file]# xfs_repair /dev/sdb2 Phase 1 - find and verify superblock...Phase 2 - using internal log - zero log... - scan filesystem freespace and inode maps... - found root inode chunk Phase 3 - for each AG... - scan and clear agi unlinked lists... - process known inodes and perform inode discovery... - agno = 0 - agno = 1 - agno = 2 - agno = 3 - process newly discovered inodes... Phase 4 - check for duplicate blocks... - setting up duplicate extent list... - check for inodes claiming duplicate blocks... - agno = 0 - agno = 1 - agno = 2 - agno = 3 Phase 5 - rebuild AG headers and trees... - reset superblock... Phase 6 - check inode connectivity... - resetting contents of realtime bitmap and summary inodes - traversing filesystem ... - traversal finished ... - moving disconnected inodes to lost+found ... Phase 7 - verify and correct link counts...done
搭建好 Cobbler 服务端后,使用默认的 kickstarts 引导文件对客户端安装系统,且默认安装的是最小化的系统。我们可以自定义 kickstarts 引导文件进而实现对客户端的自定义安装系统。环境:CentOS Linux release 7.6.1810VMware Workstation Pro 14 定制系统安装的软件包查看默认的 ks 文件 [root@Jaking ~]# cobbler report distros: Name : CentOS-7.6-x86_64Architecture : x86_64TFTP Boot Files : {}Breed : redhatComment : Fetchable Files : {}Initrd : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.imgKernel : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuzKernel Options : {}Kernel Options (Post Install) : {}Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.6-x86_64'}Management Classes : []OS Version : rhel6Owners : ['admin']Red Hat Management Key : <>Red Hat Management Server : <>Template Files : {} profiles: Name : CentOS-7.6-x86_64TFTP Boot Files : {}Comment : DHCP Tag : defaultDistribution : CentOS-7.6-x86_64Enable gPXE? : 0Enable PXE Menu? : 1Fetchable Files : {}Kernel Options : {}Kernel Options (Post Install) : {}Kickstart : /var/lib/cobbler/kickstarts/sample_end.ksKickstart Metadata : {}Management Classes : []Management Parameters : <>Name Servers : []Name Servers Search Path : []Owners : ['admin']Parent Profile : Internal proxy : Red Hat Management Key : <>Red Hat Management Server : <>Repos : []Server Override : <>Template Files : {}Virt Auto Boot : 1Virt Bridge : xenbr0Virt CPUs : 1Virt Disk Driver Type : rawVirt File Size(GB) : 5Virt Path : Virt RAM (MB) : 512Virt Type : kvm注: distros 是发行版本,即光盘镜像信息。 profiles 指的是 ks 应答文件。 systems 是指通 Cobbler 安装好的物理机名称。 [root@Jaking ~]# cd /var/lib/cobbler/kickstarts/[root@Jaking kickstarts]# lsdefault.ks legacy.ks sample_esx4.ks sample.ksesxi4-ks.cfg pxerescue.ks sample_esxi4.ks sample_old.seedesxi5-ks.cfg sample_autoyast.xml sample_esxi5.ks sample.seedinstall_profiles sample_end.ks sample_esxi6.ks sample.seed.28可以看到有很多默认的配置文件。 上传 CentOS7.ks 到 Cobbler 服务器上。CentOS7.ks 这个配置文件里面安装了开发工具相关软件包。 [root@Jaking kickstarts]# rz 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 [root@Jaking kickstarts]# lsCentOS7.ks install_profiles sample_end.ks sample_esxi6.ks sample.seed.28default.ks legacy.ks sample_esx4.ks sample.ksesxi4-ks.cfg pxerescue.ks sample_esxi4.ks sample_old.seedesxi5-ks.cfg sample_autoyast.xml sample_esxi5.ks sample.seed [root@Jaking kickstarts]# cat CentOS7.ks Cobbler for Kickstart Configurator for CentOS 7 by clsn installurl --url=$treetextlang en_US.UTF-8keyboard uszerombrbootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" Network information $SNIPPET('network_config') network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7 timezone --utc Asia/Shanghaiauthconfig --enableshadow --passalgo=sha512rootpw --iscrypted $default_password_cryptedclearpart --all --initlabelpart /boot --fstype xfs --size 1024part swap --size 1024part / --fstype xfs --size 1 --growfirstboot --disableselinux --disabledfirewall --disabledlogging --level=inforeboot %pre$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config') Enable installation monitoring $SNIPPET('pre_anamon')%end %packages@additional-devel@development@platform-develbash-completionchronydos2unixkexec-toolslrzszsysstattreevimwgetgitnet-tools%end %postsystemctl disable postfix.service%end [root@Jaking kickstarts]# cobbler profile list #查看当前启动项,使用的配置文件 CentOS-7.6-x86_64修改 name 是 CentOS-7.6-x86_64 的 kickstart 文件为 CentOS7.ks [root@Jaking kickstarts]# cobbler profile edit --name CentOS-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.ks[root@Jaking kickstarts]# cobbler report | grep KickstartKickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.6-x86_64'}Kickstart : /var/lib/cobbler/kickstarts/CentOS7.ksKickstart Metadata : {}通过给内核传参数,修改网卡名称为 eth0 [root@Jaking kickstarts]# cobbler profile edit --name CentOS-7.6-x86_64 --kopts='net.ifnames=0 biosdevname=0'配置文件内容如下: [root@Jaking kickstarts]# vim CentOS7.ks #查看配置文件中的,默认就可以,不需要修改 Cobbler for Kickstart Configurator for CentOS 7 by clsn Install #安装系统url --url=$tree #url 地址为 Cobbler 内置变量text #文本方式安装,修改为图形界面则为 Graphicallang en_US.UTF-8 #语言keyboard us #键盘zerombr #该参数用于清除引导信息,需要让其生效可以在参数后添加 yes 即可。可选项,一般不用。bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" 指定引导装载程序怎样被安装.对于安装和升级,这个选项都是必需的. Network information $SNIPPET('network_config') #该参数表示使用下方%pre 中的脚本来配置网络,相关脚本存放于/var/lib/cobbler/snippets 如果不需要脚本配置可启用以下配置 network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7timezone --utc Asia/Shanghai #时区authconfig --enableshadow --passalgo=sha512 #加密 shadowrootpw --iscrypted $default_password_crypted #设置 root 密码clearpart --all --initlabel #--all 初除所有分区,后者将磁盘标签初始化为缺省值设置。part /boot --fstype xfs --size 1024 #boot分区大小part swap --size 1024 #swap分区大小part / --fstype xfs --size 1 --grow #根分区大小firstboot --disable #决定是否在系统第一次引导时启动"设置代理”,禁用。selinux --disabled #在系统里设置 SELinux 状态firewall --disabled #在系统狸设置而防火墙状态logging --level=info #这个命令控制安装过程中anaconda的错误日志,它对安装好的系统没有影响。reboot #安装后重启%pre #pre 中定了前面使用的具体脚本名称。$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config') Enable installation monitoring $SNIPPET('pre_anamon')%end%packages #自定义安装内容,这里可以可以自行生成 ks 文件然后把对应的配置复制到这里。当前配置为最小化安装,以及安装系统常用工具。@additional-devel@development@platform-develbash-completionchronydos2unixkexec-toolslrzszsysstattreevimwgetgitnet-tools%end%post #安装后执行操作,可以执行脚本也可以直接执行命令。systemctl disable postfix.service%end定制 Cobbler 引导菜单(名称、超时时间、默认启动菜单) [root@Jaking kickstarts]# vim /etc/cobbler/pxe/pxedefault.templateDEFAULT menuPROMPT 0MENU TITLE Jaking #菜单名称TIMEOUT 100 #超时时间TOTALTIMEOUT 6000ONTIMEOUT $pxe_timeout_profile LABEL local MENU LABEL (local) MENU DEFAULT LOCALBOOT -1 $pxe_menu_items #该变量是我自定义的引导菜单,复制到 LABEL local 配置项上方,否则默认启动还是 local。 MENU end同步 Cobbler 配置 [root@Jaking kickstarts]# systemctl restart cobblerd[root@Jaking kickstarts]# cobbler synctask started: 2020-01-04_050537_synctask started (id=Sync, time=Sat Jan 4 05:05:37 2020)running pre-sync triggerscleaning treesremoving: /var/www/cobbler/images/CentOS-7.6-x86_64removing: /var/lib/tftpboot/pxelinux.cfg/defaultremoving: /var/lib/tftpboot/grub/imagesremoving: /var/lib/tftpboot/grub/grub-x86.efiremoving: /var/lib/tftpboot/grub/grub-x86_64.efiremoving: /var/lib/tftpboot/grub/efidefaultremoving: /var/lib/tftpboot/images/CentOS-7.6-x86_64removing: /var/lib/tftpboot/s390x/profile_listcopying bootloaderstrying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efitrying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.eficopying distros to tftpbootcopying files for distro: CentOS-7.6-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7.6-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7.6-x86_64/initrd.imgcopying imagesgenerating PXE configuration filesgenerating PXE menu structurecopying files for distro: CentOS-7.6-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7.6-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7.6-x86_64/initrd.imgWriting template files for CentOS-7.6-x86_64rendering DHCP filesgenerating /etc/dhcp/dhcpd.confrendering TFTPD filesgenerating /etc/xinetd.d/tftpprocessing boot_files for distro: CentOS-7.6-x86_64cleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning: dhcpd -t -qreceived on stdout: received on stderr: running: service dhcpd restartreceived on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.manage_gendersrunning python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/* TASK COMPLETE 新建虚拟机进行测试。 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 注意:内存要足够大,网络模式要和 Cobbler 服务端的网络模式一致。 创建过程省略,直接来到开机启动界面: 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 可以看到,需要安装 1262 个包,不再是原来的最小化安装了。 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 安装成功后,默认启动命令行模式输入 root 123456 登录系统: 实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 设置默认启动模式为图形化模式 graphical.target [root@localhost ~]# systemctl get-defaultmulti-user.target[root@localhost ~]# systemctl set-default graphical.targetRemoved symlink /etc/systemd/system/default.target.Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.[root@localhost ~]# systemctl get-default graphical.target[root@localhost ~]# reboot实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统 不能正常启动图形化模式 解决方法安装图形化软件 [root@localhost ~]# yum install -y xorg gnome glx*切换到图形化模式 [root@localhost ~]# init 5实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统实战-使用 Cobbler 自定义安装系统
主备模式的链路聚合将其中一个接口置于备份状态,并且仅当活动接口断开链接时才会使其处于活动状态。现在让我们在CentOS 7中配置网卡绑定,运行ip link命令查看可以使用的网卡 [root@localhost ~]# ip link1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:81:d3:be brd ff:ff:ff:ff:ff:ff 使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合在这里使用enp0s3和enp0s8两个网卡配置 主备模式的链路聚合。 创建Team接口[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' Connection 'team0' (4df78635-b9fc-4539-ab02-27db11c656fe) successfully added.使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合运行nmcli con show查看team0的配置 [root@localhost ~]# nmcli con showNAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合 添加Slave接口在这里使用enp0s3和enp0s8两个网卡作为team0的slave接口: [root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname enp0s3 master team0 Connection 'team0-port1' (15183c4a-2053-4b53-ad58-de5a07ae3ae9) successfully added.[root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname enp0s8 master team0Connection 'team0-port2' (a34e20b0-3422-46e5-a947-bb2eaa6c0622) successfully added.使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合查看端口配置信息: [root@localhost ~]# nmcli connection show NAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8 team0-port1 15183c4a-2053-4b53-ad58-de5a07ae3ae9 ethernet -- team0-port2 a34e20b0-3422-46e5-a947-bb2eaa6c0622 ethernet -- 使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合 分配IP地址给team0分配一个静态的IP地址并启动team0配置: [root@localhost ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.0.200/24 ipv4.gateway 192.168.0.1 ipv4.dns 202.102.128.68[root@localhost ~]# nmcli connection up team0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)查看连接配置信息,发现team0-port1没有绑定在enp0s3这个网卡接口上 [root@localhost ~]# nmcli connection 使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合这是以内ifcfg-team0-port1配置文件和ifcfg-enp0s3两个配置文件都设置为开机启动了使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合所以我们需要关闭enp0s3的开机启动,在这里我们把enp0s3和Wired connection 1这两个配置都关掉开机启动 [root@localhost ~]# nmcli connection modify enp0s3 autoconnect no[root@localhost ~]# nmcli connection modify Wired connection 1 autoconnect no使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合然后重启一下网络服务,查看链接配置: [root@localhost ~]# systemctl restart network[root@localhost ~]# nmcli connection[root@localhost ~]# ip ad可以看到team0-port1和team0-port2都绑定在对应的网卡上面了,team0的ip地址显示的是手动设置的192.168.0.200使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合 验证查看team0的状态: [root@localhost ~]# teamdctl team0 statesetup: runner: activebackupports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s8使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合现在活动的端口是enp0s8,我们断开这个端口,看一下主备模式配置是否工作: [root@localhost ~]# nmcli device disconnect enp0s8 Device 'enp0s8' successfully disconnected.[root@localhost ~]# teamdctl team0 statesetup: runner: activebackupports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s3看到活动接口切换到enp0s3上面了。使用nmcli配置主备模式链路聚合使用nmcli配置主备模式链路聚合 总结主备模式的链路聚合将其中一个接口置于备份状态,并且仅当活动接口断开链接时才会使其处于活动状态。
安装 CentOS 主机之前,需要安装好 Cobbler 服务端。本文档使用的是 VMware Workstation Pro 14 来安装 CentOS 主机,网络模式需要和 Cobbler 服务端的网络模式相同。环境:CentOS Linux release 7.6.1810VMware Workstation Pro 14 安装一台主机当前为虚拟机操作,虚拟机默认为 PXE 引导,如果是生产环境请进入 BIOS 修改 PXE 引导。 新建虚拟机实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 注:硬盘给 100G,给大一些。如果给 20G 后期在重安装系统时,可能会提示空间太小。 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 自定义配置实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 注: Cobbler 服务端的网络就是桥接,所以这里修改新建的主机与 Cobbler 服务端在同一网络环境。 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 开机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 选择 CentOS-7.6-x86_64 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 如果遇到 write error: No space left on device 报错,则需要把虚拟机的内存调大一点: 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 关机,把内存调大: 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 再开机: 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 选择 CentOS-7.6-x86_64 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 注:虚拟机默认就是 PXE 启动,所以不需要手动配置启动首选项为 PXE。 这里说明一下,该机制为 Cobbler 的防止误安装,20 秒无响应就会从本地硬盘启动。后续自动化安装我们可以让它不提示。 加载引导文件 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 已经在安装中了, 默认是最小化安装,大概 316个包: 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 安装完成:用户名 root 密码 123456 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 ping 192.168.1.7 可以 ping 通。 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 ping www.163.com 可以 ping 通。 实战-使用 Cobbler 安装一台 CentOS 主机实战-使用 Cobbler 安装一台 CentOS 主机 本文原创地址:https://www.linuxprobe.com/cobbler-install-centos.html编辑:传棋,审核员:逄增宝
Xrdp是Microsoft远程桌面协议(RDP)的一个开源实现,它允许以图形方式控制远程系统。使用RDP,您可以登录到远程计算机并创建一个真正的桌面会话,就像您登录到本地计算机一样。系统环境服务端:Centos7.7 Minimal客户端:Windows10安装桌面环境本实验中安装的系统没有安装桌面环境,我们需要自己安装,如果已经安装桌面了清跳过这一步。Centos7提供了"Cinnamon Desktop","MATE Desktop","GNOME Desktop","KDE Plasma Workspaces","LXQt Desktop","Xfce"让我们安装。 下面的命令列出可用环境组: [root@localhost ~]# yum grouplistLoaded plugins: fastestmirrorThere is no installed groups file.Maybe run: yum groups mark convert (see man yum)Loading mirror speeds from cached hostfile base: mirrors.tuna.tsinghua.edu.cn epel: mirrors.aliyun.com extras: mirrors.aliyun.com updates: mirrors.aliyun.comAvailable Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Cinnamon Desktop MATE Desktop Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative WorkstationAvailable Groups: Cinnamon Compatibility Libraries Console Internet Tools Development Tools Educational Software Electronic Lab Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell LXQt Desktop Legacy UNIX Compatibility MATE Milkymist Scientific Support Security Tools Smart Card Support System Administration Tools System Management TurboGears application framework XfceDone我们可以选择自己喜欢的桌面环境,在这里选择安装Xfce桌面: [root@localhost ~]# yum -y install epel-release && yum groupinstall Xfce安装Xrdp[root@localhost ~]# yum -y install xrdp安装完成之后,设置开机启动并启动xrdp [root@localhost ~]# systemctl start xrdp && systemctl enable xrdp创建~/.Xclients,设置默认启动xfce4桌面 [root@localhost ~]# echo "xfce4-session" > ~/.Xclients[root@localhost ~]# chmod +x .Xclients在客户端远程连接Centos7安装Xrdp远程桌面服务Centos7安装Xrdp远程桌面服务 Centos7安装Xrdp远程桌面服务Centos7安装Xrdp远程桌面服务 Centos7安装Xrdp远程桌面服务Centos7安装Xrdp远程桌面服务 总结安装Xrdp服务器允许您通过图形界面从本地管理CentOS 7服务器。 本文原创地址:https://www.linuxprobe.com/centos7-xrdp-remote-desktop.html编辑:逄增宝,审核员:逄增宝
init是Linux系统操作中不可缺少的程序之一。init进程,它是一个由内核启动的用户级进程。内核会在过去曾使用过init的几个地方查找它,它的正确位置(对Linux系统来说)是/sbin/init。如果内核找不到init,它就会试着运行/bin/sh,如果运行失败,系统的启动也会失败。 Linux系统7个运行级别0:关机,停机模式1:单用户模式2:多用户模式3:完整的多用户文本模式4:系统未使用,保留一般不用5:图形化模式6:重启模式运行级就是操作系统当前正在运行的功能级别。这个级别从0到6,具有不同的功能。 级别具体说明:0: 系统停机(关机)模式,系统默认运行级别不能设置为0,否则不能正常启动,一开机就自动关机。1:单用户模式,root权限,用于系统维护,禁止远程登陆,就像Windows下的安全模式登录。2:多用户模式,没有NFS网络支持。3:完整的多用户文本模式,有NFS,登陆后进入控制台命令行模式。4:系统未使用,保留一般不用,在一些特殊情况下可以用它来做一些事情。例如在笔记本电脑的电池用尽时,可以切换到这个模式来做一些设置。5:图形化模式,登陆后进入图形GUI模式或GNOME、KDE图形化界面,如X Window系统。6:重启模式,默认运行级别不能设为6,否则不能正常启动,就会一直开机重启开机重启。 启动原理简介:1、在目录/etc/rc.d/init.d下有许多服务器脚本程序,一般称为服务(service)。[root@Jaking ~]# ls -l /etc/rc.d/init.dtotal 40-rw-r--r--. 1 root root 15131 Sep 12 2016 functions-rwxr-xr-x. 1 root root 2989 Sep 12 2016 netconsole-rwxr-xr-x. 1 root root 6643 Sep 12 2016 network-rwxr-xr-x. 1 root root 2190 May 31 02:09 nginx-rw-r--r--. 1 root root 1160 Sep 13 2016 README-rwxr-xr-x. 1 root root 2437 Jun 26 2015 rhnsd2、在/etc/rc.d下有7个名为rcN.d的目录,对应系统的7个运行级别即(0-6)。[root@Jaking ~]# ls -l /etc/rc.dtotal 36drwxr-xr-x. 2 root root 4096 May 31 02:09 init.ddrwxr-xr-x. 2 root root 4096 May 30 11:46 rc0.ddrwxr-xr-x. 2 root root 4096 May 30 11:46 rc1.ddrwxr-xr-x. 2 root root 4096 May 31 05:00 rc2.ddrwxr-xr-x. 2 root root 4096 May 31 05:00 rc3.ddrwxr-xr-x. 2 root root 4096 May 31 05:00 rc4.ddrwxr-xr-x. 2 root root 4096 May 31 05:00 rc5.ddrwxr-xr-x. 2 root root 4096 May 30 11:46 rc6.d-rw-r--r--. 1 root root 473 Sep 13 2016 rc.local注意:最小化安装的操作系统默认是没有图形化软件的安装图形化软件方法如下 yum install -y xorg gnome glx* RHEL7更改默认启动级别[root@Jaking ~]# systemctl get-default graphical.target 设置默认启动为多用户字符界面:[root@Jaking ~]# systemctl set-default multi-user.target rm '/etc/systemd/system/default.target'ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target' 查看默认启动的运行模式:[root@Jaking ~]# systemctl get-default multi-user.target 字符模式 设置默认启动为多用户图形界面: [root@Jaking ~]# systemctl set-default graphical.target rm '/etc/systemd/system/default.target'ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target' 查看默认启动的运行模式:[root@Jaking ~]# systemctl get-default graphical.target 图形模式 从字符界面切换到图形界面:方法1:执行 startx方法2:执行 systemctl isolate graphical.target方法3:执行 init 5总结以上就是 RHEL7 运行级别及切换操作,这些基本操作非常实用。
大多数Linux发行版使用GRUB 2作为引导加载程序。GRUB 2 (GNU Grand Unified Boot loader)是GNU项目中的一个引导加载程序包。GRUB2提供两种类型的密码保护: 修改菜单条目时需要密码,但启动菜单条目时不需要密码; 修改菜单条目和启动一个、多个或所有菜单条目都需要密码。 设置修改菜单条目时的密码使用grub2-setpassword设置密码可以防止修改GRUB菜单条目,但是不能防止未经许可的启动。如果需要启动条目的时候也需要密码,需要修改grub配置文件。 在RHEL 7.2和Centos 7(及更高版本)上,GRUB 2使用grub2-setpassword命令提供密码保护。 [root@localhost grub.d]# grub2-setpasswordEnter password:Confirm password:当在grub菜单里面按下e 或c,编辑的时候,提示需要用户名和密码才能修改。如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码 如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码这个过程创建了一个/boot/grub2/user.cfg配置文件,其中包含已经加密的密码。这个密码的用户是root,在/boot/grub2/grub.cfg文件中已经定义了。通过此更改,在引导期间修改引导条目需要指定root用户名和密码。 设置修改菜单条目和启动菜单条目时的密码编辑/boot/grub2/grub.cfg配置文件,搜索10_linux关键字,然后修改下面 的条目,去掉--unrestricted参数,这样开机就需要输入用户名和密码了。 [root@localhost ~]# vim /boot/grub2/grub.cfg如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码修改前 如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码去掉—unrestricted参数之后的配置 修改完成之后,保存退出,重启操作系统,启动系统的时候会提示输入账号密码。如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码如何把root用户修改成其他的用户?Grub.cfg配置文件中默认设置的是root用户,我们可以更改成其他的用户。 编辑/boot/grub2/grub.cfg配置文件,搜索01_users关键字,把root修改为其他的用户,这里修改成了”test”用户名。如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码 如何在 Centos7.7 设置GRUB菜单的密码如何在 Centos7.7 设置GRUB菜单的密码 如何删除密码?想要删除密码,直接删除/boot/grub2/user.cfg文件就可以。 [root@localhost ~]# rm -rf /boot/grub2/user.cfg总结可以使用grub的密码保护启动条目和修改条目菜单。grub2-setpassword工具是在RHEL7.2/Centos7.2中添加的,现在是设置GRUB 2密码的标准方法。
RHEL 8 搭建 Nginx Web 服务前请把 yum 源配好。环境 Red Hat Enterprise Linux release 8.0VMware Workstation Pro 14 搭建步骤[root@localhost ~]# systemctl stop httpd #把 httpd 停掉,防止它影响 Nginx[root@localhost ~]# yum install -y nginx[root@localhost ~]# systemctl start nginx[root@localhost ~]# iptables -F[root@localhost ~]# systemctl stop firewalld[root@localhost ~]# systemctl disable firewalld[root@localhost ~]# setenforce 0[root@localhost ~]# ifconfigens33: flags=4163 mtu 1500 inet 192.168.10.118 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::e09a:769b:83f0:8efa prefixlen 64 scopeid 0x20 ether 00:50:56:34:0d:74 txqueuelen 1000 (Ethernet) RX packets 2908 bytes 1777392 (1.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1800 bytes 244006 (238.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:9c:ef:c6 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 在浏览器输入 192.168.10.118 查看 Nginx Web 服务器的状态 RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 查看 nginx 软件包的文件列表[root@localhost ~]# rpm -ql nginx/etc/logrotate.d/nginx/etc/nginx/fastcgi.conf/etc/nginx/fastcgi.conf.default/etc/nginx/fastcgi_params/etc/nginx/fastcgi_params.default/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/mime.types/etc/nginx/mime.types.default/etc/nginx/nginx.conf/etc/nginx/nginx.conf.default...省略部分内容...自定义首页内容RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 [root@localhost ~]# echo "HLLO RHEL8" > /usr/share/nginx/html/index.html[root@localhost ~]# systemctl restart nginx在浏览器输入 192.168.10.118 查看 设置文件共享服务[root@localhost ~]# mv /usr/share/nginx/html/* /var/lib/nginx/tmp/[root@localhost ~]# touch /usr/share/nginx/html/file{1..10}[root@localhost ~]# ls /usr/share/nginx/html/file1 file10 file2 file3 file4 file5 file6 file7 file8 file9[root@localhost ~]# systemctl restart nginxRHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 遇到 403 Forbidden 报错,原因是配置文件没配好,解决方法如下: [root@localhost html]# grep -v "#" /etc/nginx/nginx.conf user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name localhost; root /usr/share/nginx/html; include /etc/nginx/default.d/*.conf; location / { index index.html index.htm; autoindex on; autoindex_exact_size on; autoindex_localtime on; charset utf-8; } } }参考以上配置进行修改 [root@localhost ~]# vim /etc/nginx/nginx.conf[root@localhost ~]# systemctl restart nginx在浏览器输入 192.168.10.118 查看文件共享状态 RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 设置端口映射RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务查看宿主机IP RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 在浏览器输入 192.168.0.7:118 测试文件共享服务状态 RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 在 RHEL8 上用 yum 安装的 Nginx Web 服务对中文的支持比较好RHEL 8 搭建 Nginx Web 服务RHEL 8 搭建 Nginx Web 服务 [root@localhost ~]# touch /usr/share/nginx/html/你好红帽8.txt[root@localhost ~]# systemctl restart nginx
Semanage是用于配置SELinux策略某些元素而无需修改或重新编译策略源的工具。 这包括将Linux用户名映射到SELinux用户身份以及对象(如网络端口,接口和主机)的安全上下文映射。简介Semanage是用于配置SELinux策略某些元素而无需修改或重新编译策略源的工具。 这包括将Linux用户名映射到SELinux用户身份以及对象(如网络端口,接口和主机)的安全上下文映射。 实验环境Centos7.7操作系统 Selinux已经开启开启方式: [root@localhost ~]# sed -i '/^SELINUX/s/disabled/enforcing/g' /etc/selinux/config 然后重启一下操作系统 [root@localhost ~]# reboot 重启完成之后检查一下是否是enforcing模式 [root@localhost ~]# getenforce Enforcing常用参数port: 管理定义的网络端口类型fcontext: 管理定义的文件上下文-l: 列出所有记录-a: 添加记录-m: 修改记录-d: 删除记录-t: 添加的类型-p: 指定添加的端口是tcp或udp协议的,port子命令下使用-e: 目标路径参考原路径的上下文类型,fcontext子命令下使用列出所有定义的端口使用semanage port命令列出所有端口 [root@localhost ~]# semanage port -lSELinux Port Type Proto Port Number afs3_callback_port_t tcp 7001afs3_callback_port_t udp 7001afs_bos_port_t udp 7007afs_fs_port_t tcp 2040afs_fs_port_t udp 7000, 7005afs_ka_port_t udp 7004afs_pt_port_t tcp 7002afs_pt_port_t udp 7002afs_vl_port_t udp 7003agentx_port_t tcp 705agentx_port_t udp 705amanda_port_t tcp 10080-10083amanda_port_t udp 10080-10082……如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略列出指定的端口类型的端口 [root@localhost ~]# semanage port -l|grep -w http_port_thttp_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略通过查询端口号来列出端口类型 [root@localhost ~]# semanage port -l|grep -w 53dns_port_t tcp 53dns_port_t udp 53[root@localhost ~]# semanage port -l|grep -w 20ftp_data_port_t tcp 20[root@localhost ~]# semanage port -l|grep -w 21ftp_port_t tcp 21, 989, 990如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略 创建、添加、修改端口通过下面的命令为http添加新端口 [root@localhost ~]# [root@localhost ~]# semanage port -a -t http_port_t -p tcp 8888[root@localhost ~]# 查看新添加的端口 [root@localhost ~]# semanage port -l|grep -w 8888http_port_t tcp 8888, 80, 81, 443, 488, 8008, 8009, 8443, 9000 也可以使用-C参数查看自定义的端口号 [root@localhost ~]# semanage port -lCSELinux Port Type Proto Port Number http_port_t tcp 8888如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略添加一个范围的端口 [root@localhost ~]# semanage port -a -t http_port_t -p tcp 11180-11188[root@localhost ~]# [root@localhost ~]# semanage port -lCSELinux Port Type Proto Port Number http_port_t tcp 8888, 11180-11188如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略 删除端口[root@localhost ~]# semanage port -d -t http_port_t -p tcp 8888[root@localhost ~]# [root@localhost ~]# semanage port -d -t http_port_t -p tcp 11180-11188[root@localhost ~]# 查看一下,已经没有自定义的端口了 [root@localhost ~]# semanage port -lC如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略 修改安全上下文为samba共享目录添加安全上下文 没添加安全上下文之前是default_t [root@localhost ~]# ll -dZ /share/drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /share/[root@localhost ~]# semanage fcontext -a -t samba_share_t '/share(/.*)?' 恢复文件默认的安全上下文 [root@localhost ~]# restorecon -Rv /sharerestorecon reset /share context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:samba_share_t:s0 查看一下文件夹已经变成samba_share_t了 [root@localhost ~]# ll -dZ /sharedrwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 /share如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略为nfs共享目录添加读写 [root@localhost ~]# ll -dZ /nfsshare/drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /nfsshare/[root@localhost ~]# [root@localhost ~]# semanage fcontext -a -t public_content_rw_t '/nfsshare(/.*)?' [root@localhost ~]# restorecon -Rv /nfsshare[root@localhost ~]# ll -dZ /nfsshare/drwxr-xr-x. root root unconfined_u:object_r:public_content_rw_t:s0 /nfsshare/如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略 总结本文讲述了添加、修改和删除端口,修改安全上下文。如果你的系统有安装桌面,可以安装图形化管理软件 policycoreutils-gui来进行管理。 [root@localhost ~]# yum -y install policycoreutils-gui system-config-selinux执行该命令打开图形化管理界面 [root@localhost ~]# system-config-selinux如何使用semanage管理SELinux安全策略如何使用semanage管理SELinux安全策略
Ryslog是一个强大而安全的日志处理系统。Rsylog通过多个物理或虚拟服务器在网络上接收日志,并监视不同服务的健康状况。使用Rsyslog,您可以从集中位置监视其他服务器、网络设备和远程应用程序的日志。简介日志对于分析和排除Linux中的任何问题非常有用。默认情况下,所有日志文件都位于Linux的/var/log目录中。日志文件有几种类型,包括cron、内核、用户、安全性,这些文件中的大多数都由Rsyslog服务控制。 Ryslog是一个强大而安全的日志处理系统。Rsylog通过多个物理或虚拟服务器在网络上接收日志,并监视不同服务的健康状况。使用Rsyslog,您可以从集中位置监视其他服务器、网络设备和远程应用程序的日志。 准备两个运行Ubuntu 18.04 LTS版本的虚拟机下载地址:http://mirror.freethought-internet.co.uk/ubuntu-releases/18.04.3/ubuntu-18.04.3-live-server-amd64.iso在Rsylog服务端配置静态IP地址192.168.0.101,在Rsylog客户端配置192.1680.102。在两个服务器上都设置root密码。安装Rsyslog默认情况下,Rsyslog安装在Ubuntu 18.04服务器上。如果没有安装,您可以通过运行以下命令来安装它: linuxprobe@ubuntu-18-04-lts:~$ apt-get install rsyslog -y在安装Rsyslog之后,您可以使用以下命令检查Rsyslog的版本: linuxprobe@ubuntu-18-04-lts:~$ rsyslogd -vrsyslogd 8.32.0, compiled with: PLATFORM: x86_64-pc-linux-gnu PLATFORM (lsb_release -d): FEATURE_REGEXP: Yes GSSAPI Kerberos 5 support: Yes FEATURE_DEBUG (debug build, slow code): No 32bit Atomic operations supported: Yes 64bit Atomic operations supported: Yes memory allocator: system default Runtime Instrumentation (slow code): No uuid support: Yes systemd support: Yes Number of Bits in RainerScript integers: 64 See http://www.rsyslog.com for more information.还可以用这个命令检查Rsyslog的状态: linuxprobe@ubuntu-18-04-lts:~$ systemctl status rsyslog? rsyslog.service - System Logging Service Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled) Active: active (running) since Thur 2020-01-16 11:20:32 CST; 1min 31s ago Docs: man:rsyslogd(8) Main PID: 724 (rsyslogd) Tasks: 4 (limit: 1114) CGroup: /system.slice/rsyslog.service ??724 /usr/sbin/rsyslogd -n Jan 16 04:28:53 ubuntu-18-04-lts systemd[1]: Starting System Logging Service...Jan 16 04:28:54 ubuntu-18-04-lts rsyslogd[724]: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd. [v8.32.0]Jan 16 04:28:54 ubuntu-18-04-lts rsyslogd[724]: rsyslogd's groupid changed to 106Jan 16 04:28:54 ubuntu-18-04-lts rsyslogd[724]: rsyslogd's userid changed to 102Jan 16 04:28:54 ubuntu-18-04-lts rsyslogd[724]: [origin software="rsyslogd" swVersion="8.32.0" x-pid="724" x-info="http://www.rsyslog.com"] startJan 16 04:28:55 ubuntu-18-04-lts systemd[1]: Started System Logging Service.配置Rsyslog服务端linuxprobe@ubuntu-18-04-lts:~$ vim /etc/rsyslog.conf取消这几行前面的注释,同事使用UDP和TCP协议的514端口 $ModLoad imudp$UDPServerRun 514$ModLoad imtcp$InputTCPServerRun 514指定子网、IP或域名来限制访问,如下所示: $AllowedSender TCP, 127.0.0.1, 192.168.0.0/24, *.example.com$AllowedSender UDP, 127.0.0.1, 192.168.0.0/24, *.example.com创建一个模板来告诉Rsyslog如何存储传入的syslog消息。在GLOBAL DIRECTIVES部分之前添加以下几行: $template remote-incoming-logs,"/var/log/%HOSTNAME%/%PROGRAMNAME%.log" . ?remote-incoming-logs用以下命令检查Rsyslog配置信息是否有语法错误: linuxprobe@ubuntu-18-04-lts:~$ rsyslogd -f /etc/rsyslog.conf -N1rsyslogd: version 8.32.0, config validation run (level 1), master config /etc/rsyslog.confrsyslogd: End of config validation run. Bye.重新启动Rsyslog: linuxprobe@ubuntu-18-04-lts:~$ systemctl restart rsyslog验证Rsyslog正在使用以下命令监听TCP/UDP: linuxprobe@ubuntu-18-04-lts:~$ netstat -4altunp | grep 514tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 1332/rsyslogd udp 0 0 0.0.0.0:514 0.0.0.0:* 1332/rsyslogd 配置Rsyslog客户端配置Rsyslog客户端来向远程服务端发送系统日志消息。登录客户端,打开/etc/rsyslog.conf添加如下信息: linuxprobe@ubuntu-18-04-lts:~$ vim /etc/rsyslog.conf Enable sending of logs over UDP add the following line: . @192.168.0.101:514 Enable sending of logs over TCP add the following line: . @@192.168.0.101:514 Set disk queue when rsyslog server will be down: $ActionQueueFileName queue$ActionQueueMaxDiskSpace 1g$ActionQueueSaveOnShutdown on$ActionQueueType LinkedList$ActionResumeRetryCount -1重新启动Rsyslog: linuxprobe@ubuntu-18-04-lts:~$ systemtcl restart rsyslog查看日志此时,Rsyslog客户端被配置为将它们的日志发送到Rsyslog服务端。现在,登录到Rsyslog服务器并检查/var/log目录。看到客户端机器的主机名,包括几个日志文件: linuxprobe@ubuntu-18-04-lts:~$ ls /var/log/rsyslog-client/CRON.log kernel.log rsyslogd-2039.log rsyslogd.log sudo.log wpa_supplicant.log总结在上面的文章中,我们学习了如何在Ubuntu 18.04服务器上安装和配置RysLogServer。我们还学习了如何配置rsyslog客户端 向rsyslog服务端发送日志。 本文原创地址:https://www.linuxprobe.com/ubuntu-18-rsyslog.html编辑:逄增宝,审核员:逄增宝
在RHEL8中把软件源分成了两部分,一个是BaseOS,另一个是AppStream。在Red Hat Enterprise Linux 8.0中,统一的ISO自动加载BaseOS和AppStream安装源存储库。已经存在于光盘链接中,只不过要分别去配置.repo文件。BaseOS 存储库 - BaseOS 存储库以传统 RPM 包的形式提供底层核心 OS 内容。AppStream 存储库 - Application Stream 存储库提供用户可能希望在给定用户空间中运行的所有应用程序。环境 Red Hat Enterprise Linux release 8.0VMware Workstation Pro 14 配置RHEL8本地yum源及DNF简介配置RHEL8本地yum源及DNF简介 配置RHEL8本地yum源及DNF简介配置RHEL8本地yum源及DNF简介 在Red Hat Enterprise Linux 8上,基于DNF技术(YUM v4)的YUM工具的新版本确保了软件的安装。YUM v4与之前在RHEL 7上使用的YUM v3相比具有以下优点:提高性能支持模块化内容设计良好的用于与工具集成的稳定API 配置RHEL8本地yum源及DNF简介配置RHEL8本地yum源及DNF简介 在使用命令行、编辑或创建配置文件时,YUM v4与YUM v3兼容。对于安装软件,可以像在RHEL 7上一样使用yum命令及其特定选项。 配置方法和RHEL7配置本地yum源一样[root@localhost ~]# mkdir /yum[root@localhost ~]# mount /dev/cdrom /yummount: /yum: WARNING: device write-protected, mounted read-only.[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted ondevtmpfs 889M 0 889M 0% /devtmpfs 904M 0 904M 0% /dev/shmtmpfs 904M 18M 886M 2% /runtmpfs 904M 0 904M 0% /sys/fs/cgroup/dev/mapper/rhel-root 17G 3.9G 14G 23% //dev/sda1 1014M 170M 845M 17% /boottmpfs 181M 20K 181M 1% /run/user/42tmpfs 181M 3.5M 178M 2% /run/user/0/dev/sr0 6.7G 6.7G 0 100% /yum[root@localhost ~]# echo "/dev/cdrom /yum iso9660 defaults 0 0" >> /etc/fstab [root@localhost ~]# cat /etc/fstab /etc/fstab Created by anaconda on Tue Dec 24 05:39:07 2019 Accessible filesystems, by reference, are maintained under '/dev/disk/'. See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. After editing this file, run 'systemctl daemon-reload' to update systemd units generated from this file. /dev/mapper/rhel-root / xfs defaults 0 0UUID=e48080e4-ba01-45e5-a8fe-90ebb4c17c28 /boot xfs defaults 0 0/dev/mapper/rhel-swap swap swap defaults 0 0/dev/cdrom /yum iso9660 defaults 0 0 [root@localhost ~]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# vim AppStream.repo[AppStream]name=AppStreambaseurl=file:///yum/AppStreamenabled=1gpgcheck=0[root@localhost yum.repos.d]# vim BaseOS.repo[BaseOS]name=BaseOSbaseurl=file:///yum/BaseOSenabled=1gpgcheck=0[root@localhost yum.repos.d]# lsAppStream.repo BaseOS.repo redhat.repo使用yum安装nginx,在RHEL8里已经把nginx加入到appstream源,可以直接安装 [root@localhost yum.repos.d]# yum install -y nginxDNF简介DNF(Dandified Yum)是新一代的RPM软件包管理器。DNF包管理器克服了YUM包管理器的一些瓶颈,提升了包括用户体验,内存占用,依赖分析,运行速度等多方面的内容。DNF使用RPM,libsolv和hawkey库进行包管理操作,Fedora22已经默认使用DNF。DNF包管理器克服了YUM包管理器的一些瓶颈,提升了包括用户体验,内存占用,依赖分析,运行速度等多方面的内容。DNF使用 RPM, libsolv 和 hawkey 库进行包管理操作。DNF 的发行日期是2015年5月11日。 使用方法查看系统中可用的 DNF 软件库dnf repolist查看系统中可用和不可用的所有的 DNF 软件库dnf repolist all列出所有 RPM 包dnf list列出所有安装了的 RPM 包dnf list installed列出所有可供安装的 RPM 包dnf list available搜索软件库中的 RPM 包dnf search nano查找某一文件的提供者dnf provides /bin/bash查看软件包详情dnf info nano安装软件包dnf install nano删除软件包dnf remove nano删除无用孤立的软件包dnf autoremove删除缓存的无用软件包dnf clean all获取有关某条命令的使用帮助dnf help clean查看 DNF 命令的执行历史dnf history查看所有的软件包组dnf grouplist安装一个软件包组dnf groupinstall ‘安全性工具’从特定的软件包库安装特定的软件dnf -enablerepo=epel install nginx重新安装特定软件包dnf reinstall nano
2021年01月
2020年12月
2020年11月
2020年10月
2020年09月
2020年08月