• linux一般命令


    关于修改添加环境变量

    rm -f /usr/bin/php
    然后添加新的,你安装多少个 php 版本,就会在 /www/server/php 有多少个,选择你要添加的版本
    在这里我们添加 php7.2
    ln -sf /www/server/php/72/bin/php /usr/bin/php

    关于防火墙

    firewall-cmd --state 如果没有显示状态要先安装 yum install -y firewalld
    开启防火墙
    systemctl enable firewalld
    systemctl start firewalld
    查看版本: firewall-cmd --version
    查看帮助: firewall-cmd --help
    显示状态: firewall-cmd --state
    查看所有打开的端口: firewall-cmd --zone=public --list-ports
    更新防火墙规则: firewall-cmd --reload
    查看防火墙规则:firewall-cmd --list-all
    开放1234端口
    firewall-cmd --zone=public --add-port=1234/tcp --permanent ----》firewall-cmd --reload
    删除端口
    firewall-cmd --permanent --remove-port=端口/tcp
    查看是否生效 firewall-cmd --zone=public --query-port=1234/tcp
    限制IP为192.168.0.200的地址禁止访问80端口即禁止访问机器
    firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.200" port protocol="tcp" port="80" reject"
    解除:firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.200" port protocol="tcp" port="80" accept"

    关于git

    git branch 查看本地所有分支
    git status 查看当前状态 
    git commit 提交 
    git branch -a 查看所有的分支
    git branch -r 查看远程所有分支
    git commit -am "init" 提交并且加注释 
    git remote add origin git@192.168.1.119:ndshow
    git push origin master 将文件给推到服务器上 
    git remote show origin 显示远程库origin里的资源 
    git push origin master:develop
    git push origin master:hb-dev 将本地库与服务器上的库进行关联 
    git checkout --track origin/dev 切换到远程dev分支
    git branch -D master develop 删除本地库develop
    git checkout -b dev 建立一个新的本地分支dev
    git merge origin/dev 将分支dev与当前分支进行合并
    git checkout dev 切换到本地dev分支
    git remote show 查看远程库
    git add .
    git rm 文件名(包括路径) 从git中删除指定文件
    git clone git://github.com/schacon/grit.git 从服务器上将代码给拉下来
    git config --list 看所有用户
    git ls-files 看已经被提交的
    git rm [file name] 删除一个文件
    git commit -a 提交当前repos的所有的改变
    git add [file name] 添加一个文件到git index
    git commit -v 当你用-v参数的时候可以看commit的差异
    git commit -m "This is the message describing the commit" 添加commit信息
    git commit -a -a是代表add,把所有的change加到git index里然后再commit
    git commit -a -v 一般提交命令
    git log 看你commit的日志
    git diff 查看尚未暂存的更新
    git rm a.a 移除文件(从暂存区和工作区中删除)
    git rm --cached a.a 移除文件(只从暂存区中删除)
    git commit -m "remove" 移除文件(从Git中删除)
    git rm -f a.a 强行移除修改后文件(从暂存区和工作区中删除)
    git diff --cached 或 $ git diff --staged 查看尚未提交的更新
    git stash push 将文件给push到一个临时空间中
    git stash pop 将文件从临时空间pop下来
    ---------------------------------------------------------
    git remote add origin git@github.com:username/Hello-World.git
    git push origin master 将本地项目给提交到服务器中
    -----------------------------------------------------------
    git pull 本地与服务器端同步
    -----------------------------------------------------------------
    git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
    git push origin serverfix:awesomebranch
    ------------------------------------------------------------------
    git fetch 相当于是从远程获取最新版本到本地,不会自动merge
    git commit -a -m "log_message" (-a是提交所有改动,-m是加入log信息) 本地修改同步至服务器端 :
    git branch branch_0.1 master 从主分支master创建branch_0.1分支
    git branch -m branch_0.1 branch_1.0 将branch_0.1重命名为branch_1.0
    git checkout branch_1.0/master 切换到branch_1.0/master分支
    du -hs
    
    git branch 删除远程branch
    git push origin :branch_remote_name
    git branch -r -d branch_remote_name
    -----------------------------------------------------------
    
    初始化版本库,并提交到远程服务器端
    mkdir WebApp
    cd WebApp
    git init 本地初始化
    touch README
    git add README 添加文件
    git commit -m 'first commit'
    git remote add origin git@github.com:XXXXX/XXX.git
    
    记住用户名密码
    git config --global credential.helper store
    

    git冲突

    方法1

    git pull 出现冲突后可以暂存本地修改git stash save "savemessage",然后git pull 更新代码,git stash list可查看暂存记录列表,释放本地暂存 git stash apply stash@{0} ,出现冲突文件,找到并解决,然后可以提交git add .加入索引库,然后本地提交git commit -m '注释' 最后git push到远程

    方法2:

    当执行git pull更新代码时,发现以下错误
    error: Your local changes to the following files would be overwritten by merge:application.yml
    Please commit your changes or stash them before you merge.
    ​ 这说明你的application.yml与远程有冲突,你需要先提交本地的修改然后更新。

    git add application.yml,然后使用 git commit -m '冲突解决',

    提交本地的application.yml文件,不进行推送远程

    git pull,更新代码会出现以下错误提示

    Auto-merging application.yml
    CONFLICT (content): Merge conflict in application.yml
    Automatic merge failed; fix conflicts and then commit the result.
    更新后你的本地分支上会出现 (develop|MERGING)类似这种标志

    找到你本地的application.yml文件,并打开

    你会在文件中发现<<<<<<< HEAD ,======= ,>>>>>>> ae9a0f6b7e42fda2ce9b13cfc5344d61

    这种标记,<<<<<<< HEAD和=======中间的是你自己的代码, ======= 和>>>>>>>中间的是其他人修改的代码

    自己确定保留那一部分代码,最后删除<<<<<<< HEAD ,======= ,>>>>>>>这种标志

    重新使用git add application.yml,然后git commit -m '冲突解决结束',再次将本地的application.yml文件提交

    解决冲突后,使用git push,将文件推送到远程

    关于linux系统一般操作命令

    端口查看

    netstat -apn|grep 80 netstat -apn |grep redis 杀死进程:kill -9 pid

    系统重启状态之类

    systemctl restart httpd.service

    查看linux系统

    cat /prod/version 内核 cat /etc/redhat-release 查看系统 uname -a

    系统排错

    uptime

    系统负载情况

    mpstat -P ALL 1

    这个命令显示每个CPU的时间使用百分比,你可以用它来检查CPU是否存在负载不均衡。单个过于忙碌的CPU可能意味着整个应用只有单个线程在工作。

    pidstat 1

    pidstat看上去就像top,不过top的输出会覆盖掉之前的输出,而pidstat的输出则添加在之前的输出的后面。这有利于观察数据随时间的变动情况,也便于把你看到的内容复制粘贴到调查报告中。

    top

    top命令包括很多我们之前检查过的指标。它适合用来查看相比于之前的命令输出的结果,负载有了哪些变动。

    不能清晰显示数据随时间变动的情况,这是top的一个缺点。相较而言,vmstat和pidstat的输出不会覆盖掉之前的结果,因此更适合查看数据随时间的变动情况。另外,如果你不能及时暂停top的输出(Ctrl-s暂停,Ctrl-q继续),也许某些关键线索会湮灭在新的输出中。按C可显示具体的command

    sudo shutdown -r now

    服务器重启

    实用命令

    • 在查找大日志文件中某些字符第一次出现的位置, 使用grep -C 10 "utf8" demo.log | tail -21 命令理解为在demo。log中查找该字符最后一次出现的位置上的前后一共21行内容 21=10*2+1 ; 比如只需要知道测试日志有没有新的修改 可以使用 grep -c "utf8" demo.log 知道字符一共出现的次数。
    • 查看最后n行的文件的内容 tail -n 20 demo.log
    高山仰止,景行行止,虽不能至,心向往之。
  • 相关阅读:
    虚拟内存分页机制的页面置换
    wait函数的作用
    Kubernetes中Pod生命周期
    ufw 禁用端口未生效
    Kubernetes各个组件的概念
    Kubernetes存储卷的使用
    虚拟内存分页机制的地址映射
    GUNgettext 无效
    响应HTTP服务的shell脚本
    yaml语法
  • 原文地址:https://www.cnblogs.com/yudubujue/p/14627278.html
Copyright © 2020-2023  润新知