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

相关内容

热门资讯

美媒证实一艘美国商船遭伊朗无人... 新华社华盛顿5月10日电 (记者徐剑梅 黄强)据美国福克斯新闻数字网报道,一艘美国商船10日在波斯湾...
特朗普声称伊朗47年来一直在“... 美国总统特朗普于当地时间5月10日在社交媒体发文,“猛烈抨击”伊朗长期“玩弄”美国和世界,同时还痛批...
学生放学回家后又返回学校坠亡,... 学生符某放学后回到家中,后又从家中返回学校,并于当晚从学校教学楼楼顶坠亡。符某父母随后将学校告上法庭...
泽连斯基称乌已向俄方提交100... 当地时间10日,乌克兰总统泽连斯基表示,乌俄双方将以“千人换千人”的方式交换战俘,乌方已向俄方提交了...
国网上海市电力公司举办“明灯引... 5月7日至9日,在第十个“中国品牌日”来临之际,国网上海市电力公司(以下简称“国网上海电力”)以“明...
字跳申请会话信息的发送方法专利... 国家知识产权局信息显示,北京字跳网络技术有限公司申请一项名为“会话信息的发送方法、装置、电子设备、存...
非开挖定向钻机厂家选择指南:郑... 导语:非开挖定向钻机作为市政管道铺设、能源管线穿越等场景的核心设备,其性能稳定性与厂家服务能力直接影...
你昂贵的DDR5内存可能是假货... 快科技5月10日消息,内存价格近期持续走高,亚洲市场出现大量假冒DDR5内存模块,且外观极具迷惑性。...
6G,迎利好!工信部批复 工信部批复6G技术试验频率。 为进一步推动我国6G技术研发、标准研制与产业化进程,工业和信息化部近日...
涉疫邮轮5名法国公民回国,一人... △“洪迪厄斯”号邮轮(资料图)法国总理勒科尔尼10日在社交媒体说,涉汉坦病毒疫情邮轮“洪迪厄斯”号上...