其他

SPAW 分区

Linux VPS的使用过程中,SWAP交换分区是一个很重要系统缓存分区。他是在内存不够用的情况下,从硬盘中临时分出一部分空间系统当做内存使用。但是,如果SWAP的占用超过30%的时候,系统的性能就会受到影响,这时候就要刷新SWAP。

刷新SWAP

可以执行命令刷新一次SWAP(将SWAP里的数据转储回内存,并清空SWAP里的数据)

$ sudo swapoff -a && sudo swapon -a
关闭SWAP

在内存大于2G时候,一般情况下可以关闭

$ sudo swapoff -a
开启SWAP
$ sudo swapon -a

检查端口通不通

查看端口占用

$ sudo netstat -anp | grep ":80\ "

检查端口通不通

  1. python 检查端口通不通

    #!/usr/bin/env python
    #coding=utf8
    
    ip = '192.168.5.204'
    port  = 5900
    
    import socket
    
    sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    sk.settimeout(1)
    
    try:
        sk.connect((ip,port))
        print 'Server %s:%s  OK!' % (ip,port)
    except Exception:
        print 'Server %s:%s not connect!' % (ip,port)
    sk.close()
    
  2. nc命令检查端口通不通

    $ nc  -vz 192.168.5.204 5904
    
  3. telnet 命令检查端口通不通

    $ telnet 192.168.5.204 5900
    

CenterOS

  1. 检查某服务是否开机启动

    # chkconfig dnsmasq
    
  2. 开启/禁止 某服务开机启动

    # chkconfig dnsmasq on/off
    # systemctl enable/disable  dnsmasq
    
  3. 启动/停止/重启 某服务

    # systemctl start/stop/restart dnsmasq
    

amixer

amixer的用法(音频编码音量控制)

  1. 查看:
$ sudo alsamixer
$ sudo amixer -D pulse
  1. 声音设置
$ amixer -D pulse sset "Master" on
$ amixer -D pulse sset "Master" off    // 静音
$ amixer set "Master" 100%
  1. 录音设置

$ amixer set “Capture” 100%

$ amixer set “Front Mic Boost” 53% $ amixer set “Rear Mic Boost” 53%

alsamixer设置默认声卡及调节音量保存配置

问题

Apache2

重启Apache2出现:
Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName.问题
在/etc/apache2/apache2.conf文件最后加上:
# Server Name
ServerName localhost