美文网首页
Linux常用命令

Linux常用命令

作者: wolfe404 | 来源:发表于2019-03-05 14:18 被阅读0次
    1.    linux常用命令
      

    Mkdir 创建

    Rm -rf 删除

    Chmod -R 777 权限

    chmod 761 加文件夹 赋予文件夹读写权限

    Mysql -uroot -r

    quit退出

    find / -name svn 查找位置

    1.    关闭防火墙和selinux
      

    Redhat使用了SELinux来增强安全,关闭的办法为:

    ①. 永久有效

    修改 /etc/selinux/config 文件中的 SELINUX="" 为 disabled ,然后重启。

    ②. 即时生效

    setenforce 0

    关闭防火墙的方法为:

    1. 永久性生效

    开启:chkconfig iptables on

    关闭:chkconfig iptables off

    1. 即时生效,重启后失效

    开启:service iptables start

    关闭:service iptables stop

    需要说明的是对于 Linux 下的其它服务都可以用以上命令执行开启和关闭操作

    补充:

    a. 防火墙还需要关闭ipv6的防火墙:

    chkconfig ip6tables off

    并且可以通过如下命令查看状态:

    chkconfig --list iptables

    b. selinux状态可以通过以下命令查看:

    Sestatus

    ===============

    uname -a # 查看内核/操作系统/CPU信息

    head -n 1 /etc/issue # 查看操作系统版本

    cat /proc/cpuinfo # 查看CPU信息

    hostname # 查看计算机名

    lspci -tv # 列出所有PCI设备

    lsusb -tv # 列出所有USB设备

    lsmod # 列出加载的内核模块

    env # 查看环境变量资源

    free -m # 查看内存使用量和交换区使用量

    df -h # 查看各分区使用情况

    du -sh <目录名> # 查看指定目录的大小

    grep MemTotal /proc/meminfo # 查看内存总量

    grep MemFree /proc/meminfo # 查看空闲内存量

    uptime # 查看系统运行时间、用户数、负载

    cat /proc/loadavg # 查看系统负载磁盘和分区

    mount | column -t # 查看挂接的分区状态

    fdisk -l # 查看所有分区

    swapon -s # 查看所有交换分区

    hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)

    dmesg | grep IDE # 查看启动时IDE设备检测状况网络

    ifconfig # 查看所有网络接口的属性

    iptables -L # 查看防火墙设置

    route -n # 查看路由表

    netstat -lntp # 查看所有监听端口

    netstat -antp # 查看所有已经建立的连接

    netstat -s # 查看网络统计信息进程

    ps -ef # 查看所有进程

    top # 实时显示进程状态用户

    w # 查看活动用户

    id <用户名> # 查看指定用户信息

    last # 查看用户登录日志

    cut -d: -f1 /etc/passwd # 查看系统所有用户

    cut -d: -f1 /etc/group # 查看系统所有组

    crontab -l # 查看当前用户的计划任务服务

    chkconfig –list # 列出所有系统服务

    chkconfig –list | grep on # 列出所有启动的系统服务程序

    rpm -qa # 查看所有安装的软件包

    CentOS 7.0默认使用的是firewall作为防火墙
    firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

    [root@localhost ~]#firewall-cmd --state
    not running
    检查防火墙的状态:
    从centos7开始使用systemctl来管理服务和程序,包括了service和chkconfig。

    [root@localhost ~]#systemctl list-unit-files|grep firewalld.service --防火墙处于关闭状态
    firewalld.service disabled
      或者

    [root@localhost ~]#systemctl status firewalld.service
    ● firewalld.service - firewalld - dynamic firewall daemon
    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
    Active: inactive (dead)
    关闭防火墙:

    systemctl stop firewalld.service #停止firewall
    systemctl disable firewalld.service #禁止firewall开机启动
    启动一个服务:systemctl start firewalld.service
    关闭一个服务:systemctl stop firewalld.service
    重启一个服务:systemctl restart firewalld.service
    显示一个服务的状态:systemctl status firewalld.service
    在开机时启用一个服务:systemctl enable firewalld.service
    在开机时禁用一个服务:systemctl disable firewalld.service
    查看服务是否开机启动:systemctl is-enabled firewalld.service
    查看已启动的服务列表:systemctl list-unit-files|grep enabled

    find / -iname jenkins | xargs -n 1000 rm -rf

    sudo wget -O /etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo
    sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.or
    yum install jenkins

    相关文章

      网友评论

          本文标题:Linux常用命令

          本文链接:https://www.haomeiwen.com/subject/xjonuqtx.html