zoukankan      html  css  js  c++  java
  • Linux 学会这些基本可以啦

    1,Linux 内壳文件:cat /etc/issue OR /etc/redhat-release
    ubuntu[apt-get install -y vim] centos[yum install -y vim] [sudo yum install epel-release]update install list
    2,可以apt-get update , apt-get -y upgrade yum -y upgrade yum update
    3,service start method: sudo service docker start == /etc/init.d docker start === systemctl docker start
    4,firewall is ok. chkconfig iptables --list |service iptables start

    sudo iptables -L -n
    service iptables status
    service iptables start


    User:===== cat /etc/passwd /etc/shadow /etc/group
    1,useradd -d /home/jianyeruan jianyeruan
    2,passwd user   //chmod 740 /etc/sudoers    440

    3,usermod -a -G jianyeruan root 可以不用操作.
    4,vi /etc/sudoers

    root ALL=(ALL) ALL

    jianyeruan ALL=(ALL) ALL

    5,service sshd restart
    6,shutdown -r now OK后做6.
    7
    禁用root
    /etc/ssh/sshd_config
    PermitRootLogin no

    file.Permission=======================
    ugo==a rwx
    chomd a+r abc
    chmod u=rwx,g=rx,o=rx abc:同上u=用户权限,g=组权限,o=不同组其他用户权限
    chmod u-x,g+w abc:给abc去除用户执行的权限,增加组写的权限
    chomd -R a+r * 归遍历子目录[-R]

    8,command:
    find / -name php.ini || netstat -ntld || lsof -i tcp:80 ||kill -9 $(pgrep nginx) ||ps -eo pid,user,group,args,etime,lstart
    9,autoRun root用户加
    vi /etc/rc.local
    touch /var/lock/subsys/local
    sudo service php-fpm start
    sudo service nginx start

    cat /etc/rc.d/rc.local
    touch /var/lock/subsys/local
    sudo service php-fpm start
    sudo service nginx start
    sudo service mariadb start
    memcached -d m 256 -u root -l 127.0.0.1 -p 11211 -c 510
    php /home/menusifu/nginx/html/workerman/start.php start -d


    10.time
    启动cron进程的方法:/etc/init.d/crond start
    开机就启动cron进程的设置命令:chkconfig --add crond
    方法二:
    把cron加入到启动脚本中:
    # rc-update add vixie-cron default
    crontab -l #查看你的任务
    crontab-e#编辑你的任务
    crontab-r#删除用户的crontab的内容
    分 时 日 月 周 2月2号1点钟干 分 时 日 月 周 周日干什么
    0 1 2 2 1 1 0
    示例:
    0 4 * * 0 root emerge --sync && emerge -uD world #每周日凌晨4点,更新系统
    0 2 1 * * root rm -f /tmp/* #每月1号凌晨2点,清理/tmp下的文件
    0 8 6 5 * root mail robin < /home/galeki/happy.txt #每年5月6日给robin发信祝他生日快乐
    假如,我想每隔2分钟就要执行某个命令,或者我想在每天的6点、12点、18点执行命令,诸如此类的周期,可以通过 “ / ” 和 “ , ” 来设置:
    */2 * * * * root ............... #每两分钟就执行........
    0 6,12,18 * * * root ............... #每天6点、12点、18点执行........
    每两个小时
    0 */2 * * * echo "have a break now." >&gt; /tmp/test.txt
    晚上11点到早上8点之间每两个小时,早上八点
    0 23-7/2,8 * * * echo "have a good dream:)" &gt;&gt; /tmp/test.txt
    每个月的4号与每个礼拜的礼拜一到礼拜三的早上11点
    0 11 4 * 1-3 command line
    1月1日早上4点
    0 4 1 1 * command line

    =========firewall config==========sudo vi /etc/sysconfig/iptables===
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 9000 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 11211 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22999 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 9696 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT
    =========download============
    wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.7-p334.tar.gz
    tar xvf ruby-1.8.7-p334.tar.gz
    cd ruby-1.8.7-p334
    ./configure
    make && make install

  • 相关阅读:
    每日一水 POJ8道水题
    编译和使用 MySQL C++ Connector
    j2ee model1模型完成分页逻辑的实现 详解!
    DB查询分析器访问EXCEL时,要在表名前后加上中括弧或双引号
    指向结构体变量的指针
    EOSS V3.0 企业运营支撑系统(基于RBAC原理的权限管理)
    MybatisGen1.0 Mybatis JavaBean Mapper生成工具
    The table name must be enclosed in double quotation marks or sqare bracket while accessing EXCEL by
    资源-Android:Android
    软件-开发软件:Android Studio
  • 原文地址:https://www.cnblogs.com/jayruan/p/5735016.html
Copyright © 2011-2022 走看看