1--查看版本

查看内核版本

# cat /proc/version

查看linux版本

# lsb_release -a 或者 cat /etc/issue ,遇见了一个centos的虚拟机上边的都看不出来,可以 cat /etc/redhat-release

2--linux服务器测速

speedtest-cli

wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli

运行

./speedtest-cli   #不指定服务器未知
./speedtest-cli --server 5120 #编号获取:http://www.speedtest.net/speedtest-servers-static.php

关于wget

encode your username and password within a URL:

ftp://user:password@host/path
http://user:password@host/path

在命令行指定了包含密码的URL ,用户名和密码会在系统上的所有用户可见(用PS)

所以,用wget -i

一些选项(可以使用前边的省略形式)

“-q” “quiet” 关闭Wget的输出

“-O" "output" 制定写入到哪个文件。 比如wget -O haha.txt http://XXXXXXX

"--limit-rate=20k" 限制20k/s 还可以用m

3--Vim 保存只读文件的修改内容

:w !sudo tee %

w执行写文件操作。这里调用了sudo命令,使得我们有root权限;将文件写入到tee来处理,这里tee的后缀参数为文件名。而%在Vim中的意思是当前文件名。

4--使用except实现自动登陆脚本

示例(登陆一台机器后再上边登陆另一台机器):

#!/usr/bin/expect
set timeout 30
set password "123456789"
spawn ssh jcuan@222.222.222.222
expect "*password*"
send "$password\r"
expect "*Last login*"
send "ssh root@172.17.0.3\r"
expect "*password*"
send "1234567890\r"
interact

注意:

#!/usr/bin/expect  

spawn是进入expect环境后才可以执行的expect内部命令!!

[interact]执行完成后保持交互状态,把控制权交给控制台,这个时候就可以手工操作了。如果没有这一句登录完成后会退出。

5--用proxychains为程序设置代理

proxychains支持http/https/socks4/socks5。

sudo apt-get install proxychains

配置文件/etc/proxychains.conf

dynamic_chain,按照列表中出现的代理服务器的先后顺序组成一条链,如果有代理服务器失效,则自动将其排除,但至少要有一个是有效的。

strict_chain,按照后面列表中出现的代理服务器的先后顺序组成一条链,要求所有的代理服务器都是有效的

random_chain,列表中的任何一个代理服务器都可能被选择使用,这种方式很适合网络扫描操作(参数chain_len只对random_chain有效)。

例子:shadowsocks,本地端口1080

 [ProxyList]
socks5 127.0.0.1 1080

6--管理开机启动项目

相关目录

  • /etc/init.d 包含许多系统各种服务的启动和停止脚本
/etc/init.d/networking restart    #可以这样使用
  • /etc/rc*.d/ 每次系统进入这个脚本的时候都会运行这个下边的脚本

    S开头的是需要运行的,K开头的是需要停止的

    S或者K的后边有两位数,这个是有关运行顺序的,自己填的数字,运行update-rc.d mysql defaults(比如我修改的是mysql的)会自动调整

  • 关于inittab

    ubuntu类似这个文件的功能是/etc/init/rc-sysinit.conf,在这个地方可以看见我的运行级别是2

关于运行级别

linux.com:introduction-services-runlevels-and-rcd-scripts

# 0 - 停机
# 1 - 单用户模式
# 2 - 多用户
# 3 -
# 4 – 多用户
# 5 - 多用户
# 6 - 重新启动

可以安装rcconf来快速地管理服务

       --on service[,service,...]
Set services to be on. This option enables rcconf in command line
mode and no select menu will be displayed. --off service[,service,...]
Set services to be off. This option enables rcconf in command
line mode and no select menu will be displayed. --list
List services which includes current status(on/off). This option
enables rcconf in command line mode and no select menu will be
displayed. Use --expert option together if you want to list all
services. This result can be used as config_file of --config.

关于/etc/rc.local

This script is executed at the end of each multiuser runlevel.

7--允许root通过ssh登录

修改/etc/ssh/sshd_config,设置PermitRootLogin yes就行

8--boot分区满了

需要卸载掉以前安装的内核,一定不要乱删里边的东西!

deinstalled的表示已经移除了

#先查看安装过的内核版本
jxdz@jxdz:/$ sudo dpkg --get-selections |grep linux-imagelinux-image-3.13.0-143-generic install
linux-image-3.13.0-24-generic deinstall
linux-image-3.13.0-66-generic deinstall
linux-image-3.13.0-67-generic deinstall
linux-image-3.13.0-68-generic deinstall
linux-image-3.13.0-71-generic install
linux-image-3.13.0-74-generic install
linux-image-3.13.0-76-generic install
linux-image-3.13.0-77-generic install
linux-image-extra-3.13.0-143-generic install
linux-image-extra-3.13.0-24-generic deinstall
linux-image-extra-3.13.0-66-generic deinstall
linux-image-extra-3.13.0-67-generic deinstall
linux-image-extra-3.13.0-68-generic deinstall
linux-image-extra-3.13.0-71-generic deinstall
linux-image-extra-3.13.0-74-generic install
linux-image-extra-3.13.0-76-generic install
linux-image-extra-3.13.0-77-generic deinstall
linux-image-extra-3.13.0-79-generic deinstall
linux-image-generic install ### 查看当前使用的版本
uname -a
Linux jxdz 3.13.0-76-generic #120-Ubuntu SMP Mon Jan 18 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux ### 删除非当前的版本
sudo apt-get remove linux-image-xxx-generic

9-kill多个进程

ps -ef|grep php-fpm|grep -v grep|cut -c 9-15|xargs sudo kill -9
  • grep -v grep 是排除含有“grep”的进程
  • cut用来截取PID
  • xargs命令是用来把前面命令的输出结果(PID)作为“kill -9”命令的参数,并执行该命令

10-在后台运行

nohup command 1>output 2>&1 &

linux 常用技巧的更多相关文章

  1. linux常用技巧(资料)

    Linux中查看程序安装位置 如果是rpm的安装,用rpm -ql如果是一般安装 用 whereis 或者 find find /usr -name catalina.out======== 如何查看 ...

  2. Linux常用技巧

    1.解决不能中文显示 xshell 终端语言显示选择UTF-8 #yum groupinstall chinese-support 2.heredocument报错“unexpected end of ...

  3. 【shell 大系】Linux Shell常用技巧

    在最近的日常工作中由于经常会和Linux服务器打交道,如Oracle性能优化.我们数据采集服务器的资源利用率监控,以及Debug服务器代码并解决其效率和稳定性等问题.因此这段时间总结的有关Linux ...

  4. linux 常用命令及技巧

    linux 常用命令及技巧 linux 常用命令及技巧:linux 常用命令总结: 一. 通用命令: 1. date :print or set the system date and time 2. ...

  5. Linux Shell常用技巧(目录)

    Linux Shell常用技巧(一) http://www.cnblogs.com/stephen-liu74/archive/2011/11/10/2240461.html一. 特殊文件: /dev ...

  6. Linux 常用基本命令及应用技巧

    需要pdf 版 联系我 我的文件中有目录一.Linux 的常用基本命令................................................................. ...

  7. Linux Shell编程之常用技巧

    前言 本文集中介绍了bash编程中部分高级编程方法和技巧.通过学习本文内容,可以帮你解决以下问题: 1.bash可以网络编程么? 2..(){ .|.& };. 据说执行这些符号可以死机,那么 ...

  8. linux常用命令与技巧(不断添加与更新)

    linux常用命令:linux命令有很多,不去做全面的介绍与总结,这里只是记录在使用linux过程中遇到的常用命令和技巧,以便以后查阅. # mkdir -p /usr/local/src/ ##递归 ...

  9. [转帖]Linux Shell常用技巧(五)

    Linux Shell常用技巧(五) https://zhuanlan.zhihu.com/p/73451771 1. 变量:在awk中变量无须定义即可使用,变量在赋值时即已经完成了定义.变量的类型可 ...

随机推荐

  1. SAP ECC MM 配置文档

    SAP ECC 6.0 Configuration Document Materials Management (MM) Table of Content TOC \o \h \z 1. Genera ...

  2. GitHub 操作流程示例

    最新文章:Virson's Blog 参考文章: 博客园-Web前端开发,博客园-喻头快跑,GotGitHub 首先.通过github网站新建一个仓库,得到仓库地址 https://github.co ...

  3. JS - Cookie: getCookie, setCookie

    JS function for Cookie 如果cookie未设置,判断时与空字符串‘’比较: function setCookie(cname, cvalue, exdays) { var d = ...

  4. ODAC(V9.5.15) 学习笔记(十五)数据离线模式

    数据离线模式(Disconnected Mode)是指数据库只有在需要的时候才连接,数据的处理放在客户端内存缓冲区中完成.这样做最大的好处是减少了网络资源依赖,对数据库服务器的资源开销和压力也减少.如 ...

  5. Sphinx(coreseek) 安装使用以及词库的扩展

    1.Sphinx(coreseek) 是啥 一般而言,Sphinx是一个独立的全文搜索引擎:而Coreseek是一个支持中文的全文搜索引擎,意图为其他应用提供高速.低空间占用.高结果相关度的中文全文搜 ...

  6. Qt lcdNumber 不能显示完整时间

    利用lcdNumber编了一个电子时钟,发现只显示“分”和“秒”,“时”没有显示出来.作为小白一名,谷歌了一下别人的程序才知道,原因是没有设置lcdNumber可以显示的位数,默认应该是显示4位的,所 ...

  7. Failure is not fatal, but failure to change might be.

    Failure is not fatal, but failure to change might be. 失败不是致命的,但无法改变却可能是致命的.

  8. MyBatis知多少(11)企业数据库

    企业数据库比应用程序数据库更大,其外部影响也更大.它们与其他系统之间存在更多的关系,包括依赖关系和被依赖关系.这些关系可能是Web应用程序与报表工具之间的,但也很有可 能是与其他的复杂系统和数据库的接 ...

  9. 编写高质量JS代码的68个有效方法(八)

    [20141227]编写高质量JS代码的68个有效方法(八) *:first-child { margin-top: 0 !important; } body>*:last-child { ma ...

  10. umbraco之DocumentType

    DocumentType定义了数据字段,这就像我们在数据库中定义表一样,这个数据字段就像表中的一个字段或者一个列.但不同的是,在umbraco里数据是分等级而不是一个表格性质. 这样就可以使用一个基本 ...