一些linux命令

cut 命令

eg:cut -d: -f1 /etc/passwd  将/etc/passwd 里面的每行 按照 ':'分割,并且取出分割后的第一个元素

tr命令

eg:tr 'a-z' 'A-Z 将'a-z'替换为'A-Z'

history 命令

用于显示历史命令 

bc 计算命令
eg:bc<<<"scale=2;111/222" sacle 表示有效位数是2位

grep命令

grep能找出带有关键字的行,但是工作中有时需要找出该行前后的行,下面是解释

 1. grep -A1 keyword filename

 找出filename中带有keyword的行,输出中除显示该行外,还显示之后的一行(After 1)

 2. grep -B1 keyword filename

 找出filename中带有keyword的行,输出中除显示该行外,还显示之前的一行(Before 1)

 3. grep -1 keyword filename

 找出filename中带有keyword的行,输出中除显示该行外,还显示之前的一行(After 1)和显示之后的一行(After 1

程序后台执行命令nohup

nohup java -jar checkspace.jar >/var/log/imageStorage/CheckSpaceNohup.log 2>&1 &


防火墙 firewall:
systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动

You can check which zone you are using with firewall-cmd --list-all and change it with firewall-cmd --set-default-zone=<zone>.

You will then know what zone to allow a service (or port) on:

firewall-cmd --permanent --zone=<zone> --add-service=http

firewall-cmd --permanent --zone=<zone> --add-port=80/tcp

You can check if the port has actually be opened by running:

firewall-cmd --zone=<zone> --query-port=80/tcp

firewall-cmd --zone=<zone> --query-service=http
firewall-cmd --reload

查看uuid
nmcli con show
nmcli device show [interface]

egrep -n '(libvirt)' /etc/nova/nova.conf //查看libvirt的情况

虚拟机操作
关闭
vboxmanage controlvm nenew poweroff
打开,后台运行
vboxmanage startvm centos0 --type headless
复制虚拟机镜像
VBoxManage clonehd <空格> 虚拟机硬盘路径 <空格> 生成的新虚拟机硬盘路径
修改虚拟机uuid
VBoxManage internalcommands sethduuid ".vdi path"
linux修改主机名字
sudo hostnamectl --static set-hostname <host-name>
linux 添加端口
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
yum 源只下载插件
sudo yum install yum-plugin-downloadonly
sudo yum install epel-release
修改centos语言环境
显示当前环境:localectl
列出可用的语言
localectl list-locales
设定当前环境
localectl set-locale LANG=zh_CN.UTF-8

原文地址:https://www.cnblogs.com/dfyz/p/4641521.html