琐碎积累

pg 库命令行连接

env PGPASSWORD={password} psql -h {host} -p {port} -U {username} -d {database}

mysql库命令行连接

mysql -h {host} -u {username} -p{password} -t -P {port} {database} --default-character-set=utf8

从压缩文件检索匹配字符串

zgrep "example string" test.tar.gz

centos 安装py2.7

安装SCL
sudo yum install centos-release-SCL
安装python27
yum install python27
virtualenv -p /opt/rh/python27/root/usr/bin/python V_ENV 报错
error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
解决方法:
cd /etc/ld.so.conf.d/
echo /opt/rh/python27/root/usr/lib64 > python2.7.conf
sudo ldconfig

shell命令date的格式化输出

Lenovo-E4430:~$ date "+%Y-%m-%d %H:%M:%S"
2016-03-25 11:08:08
Lenovo-E4430:~$ date "+%H:%M:%S"
11:08:10

presto客户端启动

./presto --server {host}:{port} --catalog hive --schema default

rsync简单命令

rsync -avz {loalfile} {remotehost}::{model}/{path}/

wiki中的几个常用标记

换行: <br />
标题(并且可以自动生成目录):
= 一级标题 =
== 二级标题 ==
=== 三级标题 ===
....
json表示:
<syntaxhighlight lang="bash">
{
    "filed1":value1,
    "filed2":value2
}
</syntaxhighlight>
代码表示:在行首加四个空格
插入图片:首先上传图片,然后记住文件路径(一般为"文件:Push type.png"这种格式),然后采用下面的标记插入图片
[[文件:type.png|缩略图|左|type与跳转对应关系]]

unbutu查看已经安装哪些软件包

sudo dpkg -l

unbutu系统版本查看

Lenovo-E4430:~$ uname -a
Linux Lenovo-E4430 3.16.0-23-generic #31-Ubuntu SMP Tue Oct 21 17:56:17 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Lenovo-E4430:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.10
Release:    14.10
Codename:   utopic
Lenovo-E4430:~$ getconf LONG_BIT
64

unbutu安装docker

apt-get update
安装最新版本docker,其实就是下载了一个shell脚本来执行安装
curl -fsSL https://get.docker.com/ | sh
或者
wget -qO- https://get.docker.com/ | sh
上面这步执行完执行可能会有这样的提示,可以不用管,就用root
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker {yourname}

Remember that you will have to log out and back in for this to take effect!

验证安装是否正确
Lenovo-E4430:~/code/golang/docker/install$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository hello-world
975b84d108f1: Download complete 
3f12c794407e: Download complete 
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

docker重启

sudo /etc/init.d/docker restart

docker几个有用的网址

https://docs.docker.com/engine/userguide/eng-image/baseimages/
https://docs.docker.com/linux/step_four/

查看当前的默认shell

echo $SHELL

ubuntu docker pull 出错

错误信息
FATA[0511] Error pulling image (latest) from mysql, Server error: Status 0 while fetching image layer
解决方法
原文链接: http://www.zhihu.com/question/30154998/answer

echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"" | sudo tee -a /etc/default/docker 
sudo service docker restart

git 获取远程分支

Lenovo-E4430:~/code/monitor_alert$ git branch -a
* master
  remotes/origin/develop
  remotes/origin/master
Lenovo-E4430:~/code/monitor_alert$ git checkout develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch 'develop'
Lenovo-E4430:~/code/monitor_alert$ git branch
* develop
  master

输入一个逗号分割字符串,然后遍历里边的每一个内容

# test.sh
# ./test.sh 127.0.0.1,127.0.0.2,127.0.0.3
# 127.0.0.1
# 127.0.0.2
# 127.0.0.3
hostlist=$(echo $1|tr "," "\n")
for host in $hostlist; do
    echo $host
done

tar压缩制定文件和目录

# 将Makefile, setup.py以及src目录下的所有内容压缩进squirrel.tar.gz
tar zcf squirrel.tar.gz  Makefile setup.py src/

tar制定解压到某个路径

tar zxf /home/ubuntu/squirrel/squirrel.tar.gz -C /home/ubuntu/squirrel/

alias永久生效方式

我是采用放到当前用户的.bashrc文件中的方法,即放到~/.bashrc文件中

mysql几个更改表结构的命令

# 删除主键
alter table active_records drop primary key;
# 增加组合唯一键
alter table active_records add unique key(user_id, app);

awscli的一个简单例子

(aws) ubuntu@ip-172:~/tmp$ aws dynamodb query --table-name user_activity --key-condition-expression "user_id = :v1" --expression-attribute-values file://express.json
{
    "Count": 2, 
    "Items": [
        {
            "doc": {
                "S": "[\"\\u5b9e\\u65bd3\", \"ceshi4\", \"\\u6d4b\\u8bd55\"]"
            }, 
            "user_id": {
                "S": "abcdeliujinliu"
            }, 
            "timestamp": {
                "N": "1484032069"
            }
        }, 
        {
            "doc": {
                "S": "[\"test11\", \"test12\", \"test13\", \"test14\", \"test15\", \"test16\"]"
            }, 
            "user_id": {
                "S": "abcdeliujinliu"
            }, 
            "timestamp": {
                "N": "1484296591"
            }
        }
    ], 
    "ScannedCount": 2, 
    "ConsumedCapacity": null
}
(aws) ubuntu@ip-172-31-32-151:~/tmp$ cat express.json 
{
   ":v1": {"S": "abcdeliujinliu"}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值