Linux 基本命令

一、文件

 setenforce 0

查:dir、ls -l (查看文件大小,修改时间)、ls -lht(查看当前文件夹下的文件大小)、df -h(查看系统硬盘使用情况)、du -h(查看文件夹内的文件大小)、top (查看cpu使用情况)

find / -name 文件  、du -s -h ./* 查看当前文件夹中最大的文件

删除:rm -rf 文件

 移动:mv    重命名:mv

复制:cp xx/. xx

sudo yum update //更新系统

  

二、xshell

传输文件

yum install  lrzsz -y

  

查看是否完成

rpm -qa |grep lrzsz

  

 提升文件权限

chmod +x build.sh

  

1.查看日志常用命令
    tail:  
       -n  是显示行号;相当于nl命令;例子如下:
            tail -100f test.log      实时监控100行日志

            tail  -n  10  test.log   查询日志尾部最后10行的日志;

            tail -n +10 test.log    查询10行之后的所有日志;

    head:  

        跟tail是相反的,tail是看后多少行日志;例子如下:

            head -n 10  test.log   查询日志文件中的头10行日志;

            head -n -10  test.log   查询日志文件除了最后10行的其他所有日志;

    cat: 

        tac是倒序查看,是cat单词反写;例子如下:

            cat -n test.log |grep "debug"   查询关键字的日志

查询日志中最后十行

cat hall_gate.log | tail -n 10

  

批量删除

find . -maxdepth 1  -regex ".*18.*" | xargs rm -rf

  

设置xshell传输文件

yum install lrzsz -y

  

移动单个文件中所有文件到另外一个文件夹

mv ./* ../download/

  

创建一个文件写入东西

echo "劉表時間快點發貨儘快發貨就卡死" > ./android.apk

  

修改文件写入用户

chown -R nginx.nginx ./

  

关闭linux防火墙 

systemctl disable firewalld  (永久关闭)
systemctl stop firewalld   (临时关闭)
systemctl status firewalld   (防火墙状态)

  

selinux 

getenforce  (状态查询)

  

 查看端口

netstat -tnlp      (查看所有端口)
ps -ef | grep redis   (查看进程相关信息)

  

 在某个路径上创建快捷明

ln -s /root/android/ /root/      (/源文件 /目标文件)     

  

 创建软路由

alias android="cd /usr/local/nginx/html/android

查看是否创建完成
cat /root/.bashrc

生效
source /root/.bashrc

  

  

原文地址:https://www.cnblogs.com/liubiaos/p/9435626.html