zoukankan      html  css  js  c++  java
  • 一些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

  • 相关阅读:
    查看文件(或文件夹)被哪个进程使用【文件已在另一程序中打开】
    MinGW32和64位交叉编译环境的安装和使用
    MinGW下编译openssl, json-c
    曲演杂坛--SQLCMD下执行命令失败但没有任何错误提示的坑
    Python2.6下基于rsa的加密解密
    MySQL--使用xtrabackup进行备份还原
    Python--过滤Mysql慢日志
    MySQL--将MySQL数据导入到SQL Server
    Python--命令行参数解析Demo
    python--同一mysql数据库下批量迁移数据
  • 原文地址:https://www.cnblogs.com/dfyz/p/4641521.html
Copyright © 2011-2022 走看看