linux 常用技巧
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 常用技巧的更多相关文章
- linux常用技巧(资料)
Linux中查看程序安装位置 如果是rpm的安装,用rpm -ql如果是一般安装 用 whereis 或者 find find /usr -name catalina.out======== 如何查看 ...
- Linux常用技巧
1.解决不能中文显示 xshell 终端语言显示选择UTF-8 #yum groupinstall chinese-support 2.heredocument报错“unexpected end of ...
- 【shell 大系】Linux Shell常用技巧
在最近的日常工作中由于经常会和Linux服务器打交道,如Oracle性能优化.我们数据采集服务器的资源利用率监控,以及Debug服务器代码并解决其效率和稳定性等问题.因此这段时间总结的有关Linux ...
- linux 常用命令及技巧
linux 常用命令及技巧 linux 常用命令及技巧:linux 常用命令总结: 一. 通用命令: 1. date :print or set the system date and time 2. ...
- Linux Shell常用技巧(目录)
Linux Shell常用技巧(一) http://www.cnblogs.com/stephen-liu74/archive/2011/11/10/2240461.html一. 特殊文件: /dev ...
- Linux 常用基本命令及应用技巧
需要pdf 版 联系我 我的文件中有目录一.Linux 的常用基本命令................................................................. ...
- Linux Shell编程之常用技巧
前言 本文集中介绍了bash编程中部分高级编程方法和技巧.通过学习本文内容,可以帮你解决以下问题: 1.bash可以网络编程么? 2..(){ .|.& };. 据说执行这些符号可以死机,那么 ...
- linux常用命令与技巧(不断添加与更新)
linux常用命令:linux命令有很多,不去做全面的介绍与总结,这里只是记录在使用linux过程中遇到的常用命令和技巧,以便以后查阅. # mkdir -p /usr/local/src/ ##递归 ...
- [转帖]Linux Shell常用技巧(五)
Linux Shell常用技巧(五) https://zhuanlan.zhihu.com/p/73451771 1. 变量:在awk中变量无须定义即可使用,变量在赋值时即已经完成了定义.变量的类型可 ...
随机推荐
- 使用B或BL跳转时,下一条指令的地址是这样计算的
B跳转指令:它是个相对跳转指令,其机器码格式如下: [31:28]位是条件码:[27:24]位为“1010”(0xeaffffff)时,表示B跳转指令,为“1011”时,表示BL跳转指令:[23:0] ...
- Backbone之旅——Collection and View篇
上篇文章说了Model,这次说说Collection,collection就是model的集合,用来装载model对象的 定义方法 var Persons = new Backbone.Collect ...
- redis的主从复制部署和使用
reids一种key-value的缓存数据库目前非常流行的被使用在很多场景,比如在数据库读写遇到瓶颈时缓存且读写分离会大大提升这块的性能,下面我就说说redis的主从复制 首先需要启动多个redis实 ...
- cordova 学习笔记
0.sdk安装 http://spring.io/guides/gs/android/ 1.安装(node.js 需要安装https://nodejs.org/) on OS X and Linux: ...
- Linux进程通信 之 信号灯(semphore)(System V && POSIX)
一. 信号灯简介 信号灯与其他进程间通信方式不大相同,它主要提供对进程间共享资源访问控制机制. 相当于内存中的标志,进程可以根据它判定是否能够访问某些共享资源,同时,进程 也可以修改该标志.除了用于访 ...
- C头文件和源文件的连
(http://blog.163.com/yui_program/blog/static/18415541520115177852896/) 一.源文件如何根据#include来关联头文件 1,系统自 ...
- 一起做RGB-D SLAM 第二季 (二)
本节目标 我们要实现一个基本的文件IO,用于读取TUM数据集中的图像.顺带的,还要做一个参数文件的读取. 设计参数文件读取的类:ParameterReader 首先,我们来做一个参数读取的类.该类读取 ...
- 【迁移学习】2010-A Survey on Transfer Learning
资源:http://www.cse.ust.hk/TL/ 简介: 一个例子: 关于照片的情感分析. 源:比如你之前已经搜集了大量N种类型物品的图片进行了大量的人工标记(label),耗费了巨大的人力物 ...
- ruby 除法运算
在Ruby中根据运算对象的值的不同进行不同的操作.除法运算符"/"的两边同为Interger对象时运算符进行整除运算,其中任意一方为Float对象时进行实数的除法运算. 7 / 2 ...
- 字符集与Mysql字符集处理(一)
一.字符集总结 其实大多数的知识在这篇文章里已经讲得非常清楚了.这里只是讲一下自己的感悟. 1. UTF-8虽然是以UTF(unicode transfermation format)开头的,但是 ...