初识CentOS服务命令大全

前端之家收集整理的这篇文章主要介绍了初识CentOS服务命令大全前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://www.cnblogs.com/kluan/p/4458264.html

(1)系统架构

查看内核

  1. #uname-s-r
  2. Linux2.6.32-358.el6.x86_64



查看发布版本

#cat/etc/redhat-release
  • CentOSrelease6.4(Final)


  • 查看cpu架构

    #arch
  • x86_64(x86_64表示64位机器/i686表示32位机器)
  • #getconfLONG_BIT
  • 64


  • (2)用户设置

    添加用户

    #/usr/sbin/useradduser1-d/home/user1-Gnobody
  • #passwduser1
  • Newpassword:123456
  • Retypenewpassword: passwd:allauthenticationtokensupdatedsuccessfully.


  • 确认用户

    #iduser1



    删除用户

    #userdel-ruser1



    赋予root权限

    #usermod-Gwheelhoge
  • #vi/etc/pam.d/su
  • authrequiredpam_wheel.souse_uid#<=取消注释


  • 用户一览

    #cat/etc/passwd



    (3)网络设置

    设置IP

    #vi/etc/sysconfig/network-scripts/ifcfg-eth0
  • DEVICE="eth0"
  • OTPROTO="static"#<=
  • HWADDR="00:0C:29:53:A5:AE"
  • IPV6INIT="no"#<=
  • NM_CONTROLLED="yes"
  • ONBOOT="yes"
  • TYPE="Ethernet"
  • UUID="1ca6acf4-ebce-415a-a89b-bf89a67819ff"
  • IPADDR="xxx.xxx.xx.xx"#<=
  • NETMASK="255.255.255.0"#<=
  • GATEWAY="xxx.xxx.xx.xx"#<=
  • DNS1="xxx.xxx.xx.xx"#<=
  • #servicenetworkrestart
  • Shuttingdowninterfaceeth0:
  • ......
  • Connectionactivated[OK]
  • #ifconfig
  • eth0Linkencap:EthernetHWaddr00:0C:29:2F:D5:58
  • inetaddr:xxx.xxx.xx.xxBcast:xxx.xxx.xx.xxMask:255.255.255.0
  • ......


  • 卸载NestworkManager服务

    #chkconfigNetworkManageroff
  • #yum-yremoveNetworkManager


  • 关闭IPv6

    #serviceip6tablesstop
  • #chkconfigip6tablesoff
  • #echo"installipv6/bin/true">>/etc/modprobe.d/disable-ipv6.conf
  • #vi/etc/sysconfig/network
  • NETWORKING_IPV6=no
  • IPV6INIT=no
  • #shutdown-rnow
  • #lsmod|grepipv6
  • 没有ipv6模块
  • #netstat-an|grepffff
  • 没有:ffff:开始的IP
  • 没有inet6addr开始的文字


  • (4)包管理设置

    yum清理

    #yumcleanall
  • Loadedplugins:fastestmirror,security
  • Cleaningrepos:baseextrasupdates
  • CleaningupEverything
  • #yummakecache
  • Determiningfastestmirrors
  • ………….
  • MetadataCacheCreated


  • yum更新

    #yum-yupdate



    自动更新

    #yum-yinstallyum-cron
  • #vi/etc/sysconfig/yum-cron
  • CHECK_ONLY=yes
  • DOWNLOAD_ONLY=yes
  • #/etc/rc.d/init.d/yum-cronstart
  • #chkconfigyum-cronon
  • #chkconfig--listyum-cron


  • 自动查找最快镜像

    #yum-yinstallyum-plugin-fastestmirror
  • #vi/etc/yum/pluginconf.d/fastestmirror.conf
  • enabled=0←0:无效1:有效


  • 添加repository

    #vi/etc/yum.repos.d/CentOS-Base.repo
  • #rpm-Uvhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
  • #vi/etc/yum.repos.d/rpmforge.repo
  • 0
  • #yum--enablerepo=rpmforgeinstallxxxx
  • #rpm-Uvhhttp://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
  • #vi/etc/yum.repos.d/epel.repo
  • #yum--enablerepo=epelinstallxxxx


  • (5)设置vim

    #yum-yinstallvim-enhanced
  • #vi/etc/profile
  • aliasvi='vim'
  • #source/etc/profile
  • #vi/etc/vimrc


  • (6)安全设置

    关闭SELinux

    #getenforce
  • #setenforce0←临时关闭
  • #vi/etc/sysconfig/selinux
  • SELINUX=enforcing
  •    ↓
  • SELINUX=disabled


  • 停止iptables

    #/etc/rc.d/init.d/iptablesstop
  • iptables:Flushingfirewallrules:[OK]
  • iptables:SettingchainstopolicyACCEPT:filter[OK]
  • iptables:Unloadingmodules:[OK]
  • #chkconfigiptablesoff
  • #chkconfig--listiptables
  • iptables0:off1:off2:off3:off4:off5:off6:off


  • (7)系统运行情况

    磁盘使用情况

    #df-h
  • #yum-yinstallsysstat
  • #iostat


  • 内存使用情况

    #free-m



    cpu和内存

    #cat/proc/cpuinfo
  • #cat/proc/meminfo


  • (8)其他

    本地语言化

    #yum-ygroupinstall"JapaneseSupport"
  • #vi/etc/sysconfig/i18n
  • LANG="en_US.UTF-8"
  • LANG="ja_JP.UTF-8"
  • #source/etc/sysconfig/i18n
  • #echo$LANG
  • ja_JP.UTF-8
  • #shutdown-rnow


  • 停止不必要的服务

    #chkconfig--list|grep3:on
  • #chkconfigip6tablesoff


  • 编码转换nkf(Network Kanji Filter)

    #yum-yinstallnkf
  • #vireadme.txt
  • test
  • 漢字
  • #nkf-greadme.txt
  • UTF-8(LF)
  • #nkf-s--overwritereadme.txt
  • Shift_JIS(LF)
  • #nkf-j--overwritereadme.txt
  • ISO-2022-JP(LF)


  • 安装gcc

    #rpm-qagcc
  • #yum-yinstallgccgcc-c++
  • #gcc-v
  • Usingbuilt-inspecs.
  • Target:i686-redhat-linux
  • …………
  • gccversion4.4.720120313(RedHat4.4.7-4)(GCC)


  • 安装PCRE

    #cd/usr/local/src
  • #wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
  • #tarzxvfpcre- #cd/usr/local/src/pcre-8.35
  • #./configure--prefix=/usr/local/pcre/ #makeclean
  • #make&&makeinstall
  • #PATH=/usr/local/pcre/8.35/bin:$PATH
  • #vi/etc/ld.so.conf
  • /usr/local/pcre/8.35/lib←末尾追加
  • #ldconfig
  • #rpm-qapcre
  • pcre-7.8-6.el6.x86_64
  • #pcretest-C
  • PCREversion7.82008-09-05


  • 安装OpenSSL

    #wgethttp://www.openssl.org/source/openssl-1.0.1h.tar.gz
  • #tarxzvfopenssl- #cdopenssl-1.0.1h
  • #./configshared-fPIC
  • /usr/local/ssl/lib←末尾追加
  • #ldconfig-f/etc/ld.so.conf-vp|grepssl/lib
  • libssl.so.1.0.0(libc6)=>/usr/local/ssl/lib/libssl.so.1.0.0
  • libssl.so(libc6)=>/usr/local/ssl/lib/libssl.so
  • libcrypto.so.1.0.0(libc6)=>/usr/local/ssl/lib/libcrypto.so.1.0.0
  • libcrypto.so(libc6)=>/usr/local/ssl/lib/libcrypto.so
  • #/usr/local/ssl/bin/opensslversion
  • OpenSSL1.0.1h5Jun2014


  • NTP同步时间

    引用
    # yum -y install ntp
    # mv /etc/ntp.conf /etc/ntp.conf.org
    # vi /etc/ntp.conf
    driftfile /var/lib/ntp/drift
    server 0.jp.pool.ntp.org
    server 1.jp.pool.ntp.org
    server 2.jp.pool.ntp.org
    server 3.jp.pool.ntp.org
    # ntpdate 0.jp.pool.ntp.org
    # /etc/init.d/ntpd start
    # ntpq -p
    # ntpstat
    1. #yumupdateglibc
    2. #rpm-qa|grepglibc
    3. 2.12-1.149.el6_6.5
    原文链接:https://www.f2er.com/centos/382139.html

    猜你在找的CentOS相关文章