对于ubuntu 14.04.5
服务器版,当前用户目录下存在.bash_profile
的时候,会忽略.bashrc
文件。
对于ubuntu 14.04.5
桌面版,当前用户目录下的.bash_profile
会被忽略。
对于ubuntu 14.04.5
服务器版,当前用户目录下存在.bash_profile
的时候,会忽略.bashrc
文件。
对于ubuntu 14.04.5
桌面版,当前用户目录下的.bash_profile
会被忽略。
Ubuntu 17.10
将于1
月11
日“重新”发布,表示不会再让本本变砖~
Canonical
上个月从Ubuntu
的官方网站临时关闭了Ubuntu 17.10
的下载通道,并留下通知:
由于在 某些笔记本电脑(主要为联想)上出现BIOS
固件问题,导致笔记本电脑无法启动,目前不推荐下载Ubuntu 17.10
。待问题解决后,再重新开放。
在macOS High Sierra
系统上使用Safari
进行搜索的时候,总是莫名其妙的被修改搜索词,导致搜索结果驴唇不对马嘴。搜索了一下,这个锅应该是输入法导致的,最可恶的是不能拒绝输入法的推荐词汇,可以使用如下方式关闭输入法的自动英文矫正功能。
参照ubuntu 14.04.5下安装多版本Python(2.7.6/3.4.3/3.6.4),安装配置最新版本的Python 3.6.4
。Jumpserver
需要Python 3.5
以上的版本才能正常运行。
目前我们安装的是2018.01.08
的开发版Jumpserver
,此时的版本信息如下:
1 2 3 4 5 |
commit dfaf029a68f3e3a327a0f22c470306e9bf64aedb Author: ibuler <ibuler@qq.com> Date: Mon Jan 8 15:51:08 2018 +0800 [Bugfix] 资产导入bugfix |
安装流程:
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 |
$ sudo apt-get update $ sudo apt-get upgrade $ pip3 install --upgrade pip # c/_cffi_backend.c:15:17: fatal error: ffi.h: 没有那个文件或目录 $ sudo apt-get install libffi-dev # Modules/LDAPObject.c:17:18: fatal error: sasl.h: 没有那个文件或目录 $ sudo apt-get install libsasl2-dev $ sudo apt-get install slapd ldap-utils # 需要的数据库 $ sudo apt-get install redis-server $ cd ~ $ git clone https://github.com/jumpserver/jumpserver.git $ cd ~/jumpserver $ git checkout dev # 取消可能影响到我们安装路径的环境变量 $ unset PYTHONPATH $ cd requirements && sudo apt-get install -y $(cat deb_requirements.txt) && pip3 install -r requirements.txt $ cd ~/jumpserver $ cp config_example.py config.py $ cd apps && python3 manage.py makemigrations && python3 manage.py migrate $ cd ~/jumpserver # 安装配置coco,coco被配置用来支持远程登陆 $ git clone https://github.com/jumpserver/coco.git $ cd coco $ cd requirements $ pip3 install -r requirements.txt $ cd ~/jumpserver/coco $ cp conf_example.py conf.py $ cd ~/jumpserver $ python3 run_server.py all & #如果提示 “[service ERROR] Access key is not valid”,则需要执行如下操作 #$ rm -rf coco/keys/.access_key $ python3 coco/run_server.py |
如果代码下载失败,可以从本站下载一份代码拷贝。点击这里下载jumpserver,点击这里下载coco
浏览器通过http://127.0.0.1:8080进行访问,默认的用户名密码都是admin
。
上面都启动成功之后,通过如下命令访问jumpserver
1 2 3 |
#$jumpserver_ip为跳板机的访问IP ,$login_user 为跳板机上为登陆用户分配的用户名 $ ssh $jumpserver_ip -p2222 -l $login_user |
系统环境:ubuntu14.04.5 LTS
,系统默认的python
版本为2.7.4/3.4.3
。
但是实际工作中,某些通过pip
安装的开发包需要不低于某个版本的python
才能正常工作,比如ansible-2.4.2.0
,明确只支持python-3.5
以上的版本。在低版本的python
上,无法正常运行。
而如果我们贸然更新系统python
版本的话,会导致系统异常。因此我们借助pyenv
实现基于用户的python
版本定制。
安装pyenv
:
1 2 3 4 5 6 7 8 9 |
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(pyenv init -)"' >> ~/.bashrc $ exec $SHELL -l |
查看可以安装的python
版本:
1 |
$ pyenv install --list |
这里以安装python-3.6.4
为例,首先安装依赖:
1 |
$ sudo apt-get install -y make build-essential |
安装python
:
1 2 3 4 |
# 要求开启Python动态库的支持(默认是全部静态编译),否则在安装某些插件的时候会出现无法正常链接的情况,比如 mod_wsgi $ export PYTHON_CONFIGURE_OPTS="--enable-shared" $ pyenv install 3.6.4 -vvv |
该命令会从github
上下载python
的源代码,并解压到/tmp
目录下,然后在/tmp
中执行编译工作。若依赖包没有安装,则会出现编译错误,需要在安装依赖包之后重新执行该命令。
安装完成之后,需要使用如下命令对数据库进行更新:
1 |
$ pyenv rehash |
查看当前已经安装的python
版本
1 2 3 |
$ pyenv versions * system (set by /home/xxx/.pyenv/version) 3.6.4 |
其中星号代表是当前系统正在使用的python
版本是系统自带的。
设置全局的python
版本
1 2 3 4 5 |
$ pyenv global 3.6.4 $ pyenv versions system * 3.6.4 (set by /home/xxx/.pyenv/version) |
从上面,我们可以看出来当前的python
版本已经变为了3.6.4
。也可以使用pyenv local
或pyenv shell
临时改变python
的版本。
如果需要还原设定的python
版本为系统自带的版本,则执行如下命令:
1 |
$ pyenv global system |
确认python
版本
1 2 3 4 |
$ python Python 3.6.4 (default, Jan 9 2018, 11:21:57) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. |
上面的操作会导致在当前用户下,执行python
或者python3
命令的时候都会被定向到python-3.6.4
,如果只想执行python3
命令的时候被定向到python-3.6.4
,则可以直接删除python
这个链接:
1 2 3 |
# 注意,这个链接删除后,可能导致ros indigo的初始化异常,因此,这部分的改动要慎重 $ rm -rf ~/.pyenv/versions/3.6.4/bin/python |
安装pip
:
1 2 3 4 5 6 7 |
$ wget https://bootstrap.pypa.io/get-pip.py $ python3 get-pip.py $ rm -rf get-pip.py $ pip3 install --upgrade pip |
安装完成之后,需要使用如下命令对数据库进行更新:
1 |
$ pyenv rehash |
python
即可使用新版的python
/usr/bin/python
的方式直接调用老版本的python
,因而不会对系统脚本产生影响pip
安装第三方模块时会安装到~/.pyenv/versions/3.6.4
下,不会和系统模块发生冲突pip
安装模块后,可能需要执行pyenv rehash
更新数据库Ubuntu
版本:16.04.3
Oracle VirtualBox
版本:5.0.40
问题:
1 |
USB 2.0 is currently enabled for this virtual machine. However, this requires the Oracle VM VirtualBox Extension Pack to be installed.Please install the Extension Pack from the VirtualBox download site. After this you will be able to re- enable USB 2.0. It will be disabled in the meantime unless you cancel the current settings changes. |
这是在设置启用USB
时提示的错误。关于如何启用Ubuntu
下Oracle VM VirtualBox
的USB
功能 (Oracle VM VirtualBox
-设置
-USB
-启用USB控制器
-启用USB 2.0 ECHI控制器
)--如果你没有安 装Oracle VM VirtualBox Extension Pack
的话,那么这时就会弹出一个提示框,提示上面给出的那段英文提示。
从国外下载ROS
安装包,有时候会非常耗时。国内镜像的地址参考如下:
1 2 |
#中科大源 $ sudo sh -c 'echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' |
执行如下命令安装:
1 2 3 4 5 6 7 |
$ sudo apt-get update #日志位于 /var/log/upstart/docker.log #解决无法启动 "Shutting down daemon due to errors: Error loading docker apparmor profile: exec: "/sbin/apparmor_parser": stat /sbin/apparmor_parser: no such file or directory ()" $ sudo apt-get install apparmor $ sudo apt-get install -y docker.io |
启动服务:
1 |
$ sudo service docker start |
测试服务是否正常:
1 |
$ sudo docker run hello-world |
创建基础镜像:
1 2 3 4 5 6 7 |
$ cd ~ $ mkdir basic_docker $ cd basic_docker $ touch Dockerfile |
接下来,就是Dockerfile
里面的内容了:
1 2 3 4 5 6 7 8 |
#从基础镜像派生,基础镜像从Docker官网下载 FROM ubuntu:14.04 #镜像所有者 MAINTAINER www.mobibrw.com #安装命令,安装镜像需要的软件 RUN apt-get update && apt-get install -y php5 |
构建Docker
镜像:
1 2 3 4 5 6 |
#注意 -t 参数指定镜像名,后面可以用":"来指定版本号 比如 “-t basic_docker:1.0" #创建好的镜像的默认存放路径为"/var/lib/docker" $ sudo docker build -t basic_docker . #创建完成后,查看机器上已经创建的镜像列表 $ sudo docker images |
运行刚刚创建好的镜像:
1 2 3 |
#执行之后,当前Shell被切换到了Docker内部的Shell中 $ sudo docker run -t -i basic_docker /bin/bash |
导出刚刚创建好的镜像:
1 |
$ sudo docker save basic_docker > basic_docker.tar |
其他机器上加载我们导出的镜像:
1 |
$ sudo docker load --input basic_docker.tar |
删除不再使用的镜像:
1 2 3 4 5 6 7 8 9 10 11 12 |
#停止所有的container,这样才能够删除其中的images $ sudo docker stop $(sudo docker ps -a -q) #删除所有container解除对镜像的引用 $ sudo docker rm $(sudo docker ps -a -q) #创建完成后,查看机器上已经创建的镜像列表 $ sudo docker images $ sudo docker rmi ${IMAGE ID} #想要删除untagged images,也就是那些id为<None>的image的话可以用,注意 awk部分必须是单引号' $ sudo docker rmi $(sudo docker images | grep "^<none>" | awk '{print $3}') |
如果运行时报错:
1 |
Error response from daemon: Cannot start container 915xxxxxxxxxx: [8] System error: mountpoint for devices not found |
则尝试安装:
1 |
$ sudo apt-get install cgroup-bin |
如果 m & (m - 1) == 0,则m是2的n次方
1 2 3 |
public static boolean isPower2(int i){ return (i > 0) && ((i & (i - 1)) == 0); } |
1 2 3 4 5 6 7 |
$ cd ~ $ git clone https://github.com/opencv/opencv.git $ cd opencv $ git checkout 2.4.13.5 |
1 2 3 4 |
$ sudo apt-get install -y cmake #借助系统自带的opencv简化依赖安装步骤 $ sudo apt-get install -y libopencv-dev |
1 2 3 4 5 6 7 8 9 10 11 |
$ cd ~ $ cd opencv $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. $ make -j 10 |
如果要生成DEB
安装包,则上面的命令修改成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ cd opencv $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CPACK_BINARY_DEB=ON .. $ make -j 10 $ sudo make install $ sudo cpack runs #最后在当前目录下生成DEB安装包 |
1 |
$ sudo make install |
如果执行cmake
时候出现如下错误信息
1 2 3 4 5 6 7 8 9 10 |
CMake Error at CMakeLists.txt:11 (message): FATAL: In-source builds are not allowed. You should create separate directory for build files. -- Configuring incomplete, errors occurred! |
则应该是在代码根目录下直接执行过cmake
,导致根目录下生成了CMakeCache.txt
,需要删除CMakeCache.txt
再次执行编译即可。