linux常用的配置有哪些?
admin
2023-03-25 23:01:21
0

变量值

echo $USER
echo $?
echo $PS1
echo $PATH


配置文件修改部分:

[root@node4~]#cp /etc/DIR_COLORS ~/dir_colors 
vim  ~/dir_colors 
 88 DIR 01;33       # directory
[root@centos6 ~]#vim ~/.bashrc 
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias grep='grep --color=auto'
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
alias cdnet='cd /etc/sysconfig/network-scripts/' 
[root@centos6 ~]#. .bashrc
[root@node4~]#cat   ~/.vimrc
set nu
set cul
set ai 
set paste
set ic
set ai

 
 
 centos6 防火墙:
 service iptables stop
 chconfig iptables off 
 centos7:防火墙:
 systemctl stop firewalld 
 systemctl disable firewalld

日志清理部分:

[root@centos6 /proc/10]#find / -mount  -type f -size +100M  |xargs -i du -sh {}|sort -nr
3.8G    /root/centos6.9.iso


脚本部分:

df |grep ^/dev/sd |sed -r "s/.*[ ]+([0-9]{1,3})%.*/\1/"
df -i  |grep ^/dev/sd |sed -r "s/.*[ ]+([0-9]{1,3})%.*/\1/"
[root@node4~]#ifconfig  eth0  |head -n2 |tail -n1 |tr -s " "  |cut -d " " -f3
192.168.137.47
[root@centos6 ~]#ifconfig  eth0  |head -n2 |tail -n1 |cut -d ":" -f2 |cut -d " " -f1
192.168.137.6
[root@centos6 /app]#df |tr -s " " "%" |cut -d % -f 5 
[root@node4/var/log/httpd]#cut -d " " -f1  access_log |sort |uniq -c|sort -nr  
      4 192.168.137.1
      2 192.168.0.118
[root@node4/var/log/httpd]#awk '{a[$1]++}END{for (i in a ){print i,a[i]}}'< /var/log/httpd/access_log

[root@node4/app]#seq 1 10 |sort -R |head -n1  随机取数
3

[root@node4/app]#cut -d: -f1,3 /etc/passwd  |sort -t:  -k2 -n
root:0
bin:1
daemon:2
adm:3
lp:4

[root@node4/app]#cat /var/log/httpd/access_log |cut -d " " -f1  |sort |uniq -c |sort -nr 
      7 192.168.137.1
      2 192.168.0.118
      
[root@centos6 /app]#awk 'BEGIN{x=1.5;y=1024;z=85/100;printf "%0.2f\n",x*y*z}'           
1305.60

[root@node4~]#df |grep /dev/sd  |grep  -o "[0-9]\+%" |grep -o "[0-9]\+" |sort -nr |head -n1
29

[root@node4~]#egrep -v "^#|^$" /etc/fstab
[root@node4~]#grep -v -e "^#" -e "^$" /etc/fstab
[root@node4~]#grep -v -e"^[[:space:]]*$" -e "^#" /etc/fstab  

[root@node4~]#cat /etc/passwd |grep "^\(.*\):.*/\1$"
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
[root@node4~]#cat /etc/passwd |egrep "^(.*):.*/\1$" 

axy
[root@node4~]#echo axy |egrep "(a|b)xy"
axy
[root@node4~]#cat /etc/redhat-release|grep -o " [0-9]\+." |grep -o "[0-9]\+"                 
7
[root@node4~]#cat /etc/centos-release |grep -o "[0-9]\+"  |head -n1
7
分组:\(\) 将一个或多个字符捆绑在一起,当作一个整体进行处理,如: 
\(root\)\+ 

分组括号中的模式匹配到的内容会被正则表达式引擎记录于内部的变量中,这 
些变量的命名方式为: \1, \2, \3, ... 

\1 表示从左侧起第一个左括号以及与之匹配右括号之间的模式所匹配到的字符 

示例: \(string1\+\(string2\)*\) 
 \1 :string1\+\(string2\)* 
 \2 :string2 

后向引用:引用前面的分组括号中的模式所匹配字符,而非模式本身 

或者:\| 
示例:a\|b: a或b C\|cat: C或cat \(C\|c\)at:Cat或cat



修改密码部分;

密码部分:
[root@centos6 /app]#openssl rand -base64 100 |tr -dc "[:alnum:]"|head -c12
4oa9aPP1tr9I

[root@centos6 /app]#cut -d : -f 1,3 /etc/passwd 

[root@centos6 /app]#df |tr -s " " "%" |cut -d % -f 5


变量:

[root@centos6 /app]# echo $[$RANDOM%80+1]
30

[root@node4~]#egrep  -w "^(root|sun)" /etc/passwd|cut -d: -f1,7 

root:/bin/bash

sun:/bin/bash

ip地址:

[root@node4~]#egrep  -w "^(root|sun)" /etc/passwd|cut -d: -f1,7 

root:/bin/bash

sun:/bin/bash

相关内容

热门资讯

今日重磅消息“天天爱麻将有没有... 您好:天天爱麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款游...
【第一财经】“南通长牌有没有挂... 您好:南通长牌这款游戏可以开挂,确实是有挂的,需要了解加客服微信【4282891】很多玩家在这款游戏...
【第一财经】“友乐广西麻将究竟... 有 亲,根据资深记者爆料友乐广西麻将是可以开挂的,确实有挂(咨询软件无需...
今日重大发现“夜猫麻将有挂吗?... 家人们!今天小编来为大家解答夜猫麻将透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪里买很...
今日重大发现“情缘怎么装挂?”... 今日重大发现“情缘怎么装挂?”(太坑了果然有挂)您好,情缘这个游戏其实有挂的,确实是有挂的,需要了解...
终于懂了“小南娱乐可以开挂吗?... 终于懂了“小南娱乐可以开挂吗?”(其实是有挂)您好,小南娱乐这个游戏其实有挂的,确实是有挂的,需要了...
玩家分享攻略“新众亿牛牛到底有... 玩家分享攻略“新众亿牛牛到底有挂吗?”(太坑了原来有挂)您好,新众亿牛牛这个游戏其实有挂的,确实是有...
今日重大消息“边锋辽宁游戏开挂... 网上科普关于“边锋辽宁游戏有没有挂”话题很是火热,小编也是针对边锋辽宁游戏作*弊开挂的方法以及开挂对...
女朋友说有种蛆特别好,她逼我每... 女朋友逼迫我吃了两周的蛆,每天一勺,节假日不休。我前天在吃够剂量后,终于忍不住问她为啥让我吃蛆,意欲...
终于懂了“非凡贪玩究竟有挂吗?... 网上科普关于“非凡贪玩有没有挂”话题很是火热,小编也是针对非凡贪玩作*弊开挂的方法以及开挂对应的知识...