1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
//查看centos版本 cat /etc/redhat-release //查看32位还是64位 getconf LONG_BIT //查看cpu使用情况 top //查看内存使用情况 m为兆 free -m //查看分区使用情况 df //监听每秒的文件变化情况 n1表示1秒 watch -n1 ls -lh //可以看到前一次登录所执行的所有命令 vim ~/.bash_history //给命令取别名 unalias lm 取消别名 alias lm='ls -al' //zip压缩 -r表示递归 把当前目录下的所有文件、文件夹、文件夹中的文件压缩到test.zip zip -r test.zip ./ //zip解压缩 把test.zip解压到当前目录的test文件夹下 -d ./test 不填则解压到当前目录 unzip -d ./test test.zip //tar压缩 -c 产生.tar打包文件 -v 显示详细信息 -f 指定压缩后的文件名 -z 打包同时压缩 tar -zcvf test.tar.gz ./test tar -jcvf test.tar.gz ./test //打包后,以 bzip2 压缩 //tar解压缩 -x 解包.tar文件 帮当前目录的test.tar.gz解压到当前目录 tar -zxvf ./test.tar.gz ./ //可以简写为 tar -zxvf test.tar.gz history //查看历史命令 //查看当前端口占用情况 netstat -tunpl | grep 端口号 //查看进程使用情况 ps -aux | grep 进程名 //同时在test目录中建立test1、test2、test3、test4目录 mkdir -p /test/{test1,test2,test3,test4} //复制某个文件到多个目录中 echo /test/test1 /test/test2/ /test/test3 | xargs -n 1 cp -v /test/test.php //比较两个文件夹 diff /test/test1 /test/test2 //监听某个文件是否有写入 tail -f php_errors.log //连接 telnet ip ports //退出 ctrl ]回车 -> quit //netcat nc -u 127.0.0.1 9501 //-u表示udp -C表示用\r\n结束 默认是用\n //tcp打印任意端口为9501的TCP连接 tcpdump -iany tcp port 9501 //查看进程树 pstree -a | grep server.php //查看进程信息 strace -p 进程号 主进程:strace -f -p 进程号 //查看php脚本的系统调用执行 strace php test.php //在根目录下查找名称为fi开头的文件或目录 find / -name fi\* //全局搜索package开头的文件或目录 通常需要先运行updatedb更新locate的库 locate package* //显示一个二进制文件、源码或man的位置 whereis php //显示一个二进制文件或可执行文件的完整路径 which php //drwxr-xr-x 第一位表示文件类型。d是目录文件,l是链接文件,-是普通文件,p是管道 接下来依次是 所有者 所属组 其他人 r:读--4 w:写--2 x:执行--1 //把当前目录的test目录改成777权限 -R是递归的意思 chmod -R 777 test //下载 wget http://xxx.baidu.com/download/test.zip //远程传输 把本地tmp下的test.sql 传到 192.168.2.104的tmp下 scp /tmp/test.sql 192.168.2.104:/tmp/ //后台运行 例如:nohup php test.php & //自定义nohup输出文件 nohup php test.php > myout.file 2>&1 & nohup Command [Arg...] [&] curl "www.test.com" //curl访问 man xxx //查看帮助 例如man curl //批量杀进程 ps aux | grep php | awk '{print $2}' | xargs kill kill -9 $(ps aux | grep php | awk '{print $2}') //将windows换行转换成unix换行 dos2unix [-kn] file [newfile] //将unix换行转换成windows换行 unix2dos [-kn] file [newfile] //编码转换 iconv --list 查看可转换的编码列表 iconv -f 原编码 -t 新编码 filename [-o newfile] //快捷键 ctrl u //剪切光标前的内容 ctrl k //剪切光标至行末的内容 ctrl y //粘贴 ctrl e //移动光标到行末 ctrl a //移动光标到行首 alt f //跳向下一个空格 alt b //跳回上一个空格 alt backspace //删除前一个单词 ctrl w //剪切光标前一个单词 //chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level<等级代号>][系统服务][on/off/reset] //以mysql为例,将mysql设置为开机自动启动或取消开机自动启动 chkconfig mysqld on chkconfig mysqld off //但是要注意,如果这个服务尚未被添加到chkconfig列表中,则现需要使用–add参数将其添加进去,同理可删除 chkconfig --add mysqld chkconfig --del mysqld //查看mysql在各个运行级别的启动状态 chkconfig –list可查看全部服务 chkconfig --list mysqld //运行级别 0表示:表示关机 1表示:单用户模式 2表示:无网络连接的多用户命令行模式 3表示:有网络连接的多用户命令行模式 //4表示:不可用 5表示:带图形界面的多用户模式 6表示:重新启动 这些级别定义在/ect/inittab文件中 //级别2-5为on就表示设置开机自动启动成功了 0和6状态一般为off,不要去管它 //最先运行的服务是那些放在/ect/rc.d目录下的文件 //svn常用命令 svn co svn:地址 //首先得检出 svn help //查看所有命令 svn info //查看svn目录信息 svn up //更新svn svn ci -m '描述' //svn提交 svn sw svn:地址 //切换svn |