随笔分类 - Linux
摘要:EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux.使用很简单:1. 首先我们需要安装一个叫”epel-release”的软件包,这个软件包会自动配置yum的软件仓库。当然你也可以不安装这个包,自己配置软件仓库也是一样的。安装epel...
阅读全文
摘要:临时修改:重启失效hostname xxx永久修改:hostnamectl set-hostname xxx
阅读全文
摘要:本文基于vmware workstations进行CentOS7安装过程展示,关于vmware workstations安装配置本人这里不再介绍,基本过程相当于windows下安装个软件而已。 1、打开vmware workstations,文件->新建虚拟机,出现如下界面,选择“自定义(高级)”选
阅读全文
摘要:1、先决条件:安装pssh工具的主机针对远程主机需要配置免秘钥认证:ssh-keygen -t rsassh-copy-id [remotehost]2、下载mussh工具安装介质:https://jaist.dl.sourceforge.net/project/mussh/mussh/1.0/mussh-1.0.tgz3、安装musshmussh安装非常简单,直接解压缩安装包即可使用。tar -...
阅读全文
摘要:1、先决条件:安装pssh工具的主机针对远程主机需要配置免秘钥认证:ssh-keygen -t rsassh-copy-id [remotehost]2、下载pssh工具安装介质:https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pdsh/pdsh-2.29.tar.bz23、安装pdsh...
阅读全文
摘要:1、先决条件:安装pssh工具要求python版本大于2.4即可。安装pssh工具的主机针对远程主机需要配置免秘钥认证:ssh-keygen -t rsassh-copy-id [remotehost]2、下载pssh工具安装介质:https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/para...
阅读全文
摘要:[root@chavinking mnt]# cat textfile chavinking 1 2 3 4 5 6nope 1 2 3 4 5 6[root@chavinking mnt]# cat textfile | awk '{for(i=1;i<=$NF+1;i++){sum=sum+$i} {print $1" "sum;sum=0}}'chavinking 21nope 21[roo...
阅读全文
摘要:一、配置防火墙CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。1、关闭firewall:systemctl stop firewalld.servi(www.111cn.net)ce #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动2、安装iptables防火墙yum insta...
阅读全文
摘要:一、docker在CentOS 6上的安装 Docker仅支持64位系统,对于centos 6系统可以使用epel库安装docker,命令如下: #yum -y install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarc
阅读全文
摘要:编写shell脚本难免遇到需要交互式输入指令的步骤: 方法一: # cat action.sh #!/bin/sh read -p "enter number:" no; read -p "enter number:" name; echo you have entered $no,$name; #
阅读全文
摘要:sort命令可以帮助我们对文本文件或stdin输入进行排序,sort通常配合其他命令进行输出操作。uniq是一个经常与sort使用的命令。作用是从文本或stdin读取唯一的行,uniq要求输入必须经过排序。 按数字顺序排序: # sort -n dept 10 ACCOUNTING NEW YORK
阅读全文
摘要:tr命令用来进行对标准输入的内容做替换。例如 # echo 'HELLO WORLD!!!' | tr "A-Z" "a-z" hello world!!! 这里的"A-Z"、"a-z"都表示集合,shell脚本中定义集合类型很简单,即指定集合序列即可,但是对于上边的情形,不得非输入所有集合类型,可
阅读全文
摘要:首先看一下文本信息: # cat text1.txt 1 2 3 4 5 使用xargs格式化一下: # cat text1.txt | xargs 1 2 3 4 5 使用xargs格式化,每两个单词一组: # cat text1.txt | xargs | xargs -n 2 1 2 3 4
阅读全文
摘要:find列出目录下所有文件: # find /shell-script/ # find /shell-script/ -print find列出文件夹中所有开头为text的文件,参数-iname意思忽略大小写: # find /shell-script/ -name "text*"# find /s
阅读全文
摘要:一、分支控制语句 1、if .. fi条件 if condition; then action fi 2、if .. else .. fi条件 if condition;then action; else action fi 3、if .. else if ..else ..fi条件 if cond
阅读全文
摘要:方法: kill –9 `pgrep java` 使用上述命令可以将服务器上运行的所有java进程一次性kill掉。 扩展:子shell和反应用在shell脚本中的作用 先来看一个子shell的例子: # cat text1.txt 1 2 3 4 5 # text01=$(cat text1.tx
阅读全文
摘要:测试脚本如下,我这里主要想测试$0,$1,$2,$n,$@,$*默认都代表了什么? #!/bin/sh echo '$1='$1 echo '$2='$2 echo '$@='$@ echo '$*='$* echo '$0='$0 测试: # sh var.sh 1 2 $1=1 $2=2 $@=
阅读全文
摘要:#!/bin/sh echo -n radio: tput sc #保存当前光标位置 count=0 while true; do if [ $count -lt 10 ];then let count++; sleep 1; #休眠1秒 tput rc; #取出当前光标位置 tput ed #ra
阅读全文
摘要:stty命令是一个终端处理工具。我们可以通过它来实现静默方式输入密码,脚本如下 #!/bin/sh echo –e “enter password:” stty –echo #禁止将输出发送到终端 read password #交互式读取 stty echo #允许将输出发送到终端 echo pas
阅读全文
摘要:脚本内容如下: #!/bin/sh #定义变量 secs=3600unit_time=60 stepts=$(( $secs / $unit_time )) echo CPU usage...; for((i=0;i<stepts;i++))do ps -eo comm,pcpu | tail -n
阅读全文