• Linux Command


    Help Command

    man [command]
    
    help [command]
    
    [command] --help
    

    echo、head、tail命令

    输出内容到控制台

    echo $PATH
    

    查看文件前几行

    head -n 25 filename
    

    查看文件后几行

    tail -n 30 -f filename
    

    ln、history、date命令

    建立软连接和硬链接

    ln -s /path1/file  /path2/file
    ln /path3/file  /path4/file
    

    查看、清空历史命令

    history [option]
    echo > /root/.bash_history
    

    显示、设置系统时间

    date [option]
    

    find、locate、grep命令

    指定目录查找文件,可以根据名字、拥有者、大小查询

    find directoryPath -name fileName
    

    可以快速定位文件位置,前提是建立lacate数据库

    yum -y install mlocate
    updatedb
    locate [option] fileName
    

    查找文件内容中是否含有指定字符("|"可以把前面的结果传递给后面)

    cat fileName | grep [option] string
    

    zip/unzip、tar命令

    压缩目录或者文件,较常用

    yum -y install zip
    zip -r package.zip directoryOrFile
    unzip -d path package.zip
    

    在安装软件的时候经常用到

    yum -y install tar
    tar -zcvf package.tar.gz directoryOrFile
    tar -zxvf package.tar.gz
    

    crontab、mount命令

    Linux crontab命令用来定期执行程序的命令。

    crontab [option]
    

    Linux mount命令用于挂载Linux系统外的文件。

    mount [option]
    

    磁盘命令

    查看磁盘整体情况

    df -h
    

    查看目录占用情况

    du -h directory
    

    统计目录下文件个数

    ll /myApps |grep "^-"|wc -l
    

    统计目录下目录的个数

    ll /myApps |grep "^d"|wc -l
    

    查看目录的树

    yum -y install tree
    tree directory
    

    其它命令

    查看本机IP地址

    ifconfig
    

    查看Linux版本

    uname -m
    

    进程管理

    查看进程

    ps -ef | grep tomcat
    

    终止进程

    kill -9 PID
    killall PNAME
    

    查看进程树

    pstree -p
    

    动态监控进程,刷新时间3s

    top
    

    服务管理

    systemctl兼容了service,作用差不多

    systemctl ServiceName start|stop|restart|reload|status
    

    列出系统的所有服务

    ls -l /etc/init.d/
    

    rpm、yum命令

    rpm原本是Red Hat Linux发行版专门用来管理Linux各项套件的程序。

    查看是否安装docker
    rpm -qa | grep docker
    
    卸载安装的docker
    rpm -e docker
    

    yum是rpm软件包管理器,可以自动安装软件。

    查看yum服务器上是否有firefox安装包
    yum list | grep firefox
    
    安装最新firefox
    yum -y install firefox
    
  • 相关阅读:
    数组
    JavaScript语法
    Math.random()
    第二第三周暑期集训总结
    第一周
    ACM课程学习总结
    专题四---总结
    专题四--1004
    专题四--1005
    专题四--1006
  • 原文地址:https://www.cnblogs.com/feiqiangsheng/p/12615796.html
Copyright © 2020-2023  润新知