1. 加入到开机启动 vi /etc/rc.local 加入需要开机自启动的命令,比如: /usr/local/apache/bin/apachectl start /usr/local/bin/redis-server /etc/redis.conf 2. 查看某个服务进程是否在运行 ps -aux |grep httpd ps -ef|grep httpd 3. 查看一个端口是否运行 netstat -tnl|grep 3306 4. 重新编译apache、php、mysql等大型软件 (cat config.nice) 每当新增加一个扩展的时候,我们就必须重新编译软件,这里以Apache和php为例子。 比如:Apache是编码安装的,现在需要增加ssl扩展。那么就需要重新编译源码Apache。 --enable-ssl=static --with-ssl=/usr/local/ssl 加上这一句。那么如何拼接到之前的config里呢? 4.1 到编译apache 的编码目录。比如 /laml/httpd-2.3/ 里面有个config.nice 这个就是上一次编译成功的./configure 的配置。 root@localhost httpd-2.4.3]# cat config.nice #! /bin/sh # # Created by configure "./configure" \ "--prefix=/usr/local/apache/" \ "--enable-mods-shared=all" \ "--enable-deflate" \ "--enable-speling" \ "--enable-cache" \ "--enable-file-cache" \ "--enable-dish-cache" \ "--enable-mem-cache" \ "--enable-so" \ "--enable-expires=shared" \ "--enable-rewrite=shared" \ "--enable-static-support" \ "--sysconfdir=/etc/httpd" \ "--with-z=/usr/local/zlib/" \ "--with-apr=/usr/local/apr-httpd/" \ "--with-apr-util=/usr/local/apr-util-httpd/" \ "--with-pcre=/usr/local/pcre/" \ "--disable-userdir" \ "$@" [root@localhost httpd-2.4.3]# 将这句话--enable-ssl=static --with-ssl=/usr/local/ssl 加到其后面,重新就可以重新编译了。然后再make && make install 4.2 php 编译也一样。也是到php的源码安装包目录。里面也有个config.nice 文件。就是上一次编译成功的config文件。 也可以到php.ini里面去搜寻: [root@localhost httpd-2.4.3]# /usr/local/php/bin/php -i |grep 'Configure' 4.3 mysql 编译就不一样了。源码文件里面没有config.nice文件。 [root@localhost httpd-2.4.3]# grep CONFIGURE_LINE /usr/local/mysql/bin/mysqlbug CONFIGURE_LINE="./configure '--prefix=/usr/local/mysql' '--enable-thread-safe-client' '--with-extra-charsets=all'"
5. 检查磁盘空间:df (-h 表示转换成M或者G,不用KB表示)
5.1 查看磁盘空间 df -h 查看整个硬盘的空间状况 [root@localhost usr]# df -h 文件系统 容量 已用 可用 已用%% 挂载点 /dev/sda3 18G 6.1G 11G 37% / tmpfs 244M 124K 244M 1% /dev/shm /dev/sda1 485M 33M 428M 8% /boot 5.2 查看当前空间的一级目录使用空间状况: du -h --max-depth=1 [root@localhost usr]# du -h --max-depth=1 186M ./bin 1.4G ./share 15M ./include 16K ./yangyi 4.0K ./games 4.0K ./etc 466M ./local 22M ./sbin 395M ./lib 954M ./lib64 41M ./libexec 12K ./src 3.4G . 5.3 查看当前目录,总的大小: du -h --max-depth=0 或者 du -sh [root@localhost usr]# du -h --max-depth=0 3.4G .
5.6 查看其他指定目录的大小以及情况 du- sh 目录
[root@localhost usr]# du -sh /usr/local/ /usr/local/apache/ 466M /usr/local/ 60M /usr/local/apache/
free : 查看内存情况。free -m 以M为单位显示。
[root@localhost usr]# free -m total used free shared buffers cached Mem: 487 476 11 0 68 40 -/+ buffers/cache: 368 119 Swap: 2047 18 2029可以看到 只剩下11M的内存了。
total 内存总数
used 已经使用的内存数
free 空闲的内存数
shared 多个进程共享的内存总额
buffers Buffer Cache和cached Page Cache 磁盘缓存的大小
-buffers/cache 的内存数:used - buffers - cached
+buffers/cache 的内存数:free + buffers + cached
可用的memory=free memory+buffers+cached。
手动释放内存
sync : 将内存缓冲区内的数据写入磁盘
echo 3 > /proc/sys/vm/drop_caches
在看看
[root@localhost usr]# free -m total used free shared buffers cached Mem: 487 277 209 0 1 17 -/+ buffers/cache: 258 228 Swap: 2047 18 2029free 可用空间为209M了,很明显。
7. 跟新时区
rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
8. Ubuntu 系统 root 帐号开启 SSH 登录
修改 root 密码
sudo passwd root
2. 以其他账户登录,通过 sudo nano 修改 /etc/ssh/sshd_config :
xxx@ubuntu14:~$ su - root Password: root@ubuntu14:~# vi /etc/ssh/sshd_config
3. 注释掉 #PermitRootLogin without-password,添加 PermitRootLogin ye
# Authentication: LoginGraceTime 120 #PermitRootLogin without-password PermitRootLogin yes StrictModes yes
4. 重启 ssh 服务
root@ubuntu14:~# sudo service ssh restart ssh stop/waiting ssh start/running, process 1499 root@ubuntu14:~#