$sudo passwd root
$vi /etc/hostname
$sudo apt-get install openssh-server
//安装sshd服务 $ sudo apt-get install openssh-server //开启服务 $ /etc/init.d/ssh start //关闭服务 $ /etc/init.d/ssh stop //重启服务 $ /etc/init.d/ssh restart
$ sudo apt-get install python2.7 $ which python2.7 $ which python3 $ python --version Arvin@Arvin:~/tools/pip$ which python2.7 /usr/bin/python2.7 Arvin@Arvin:~/tools/pip$ python2.7 Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python lrwxrwxrwx 1 root root 18 Mar 28 23:23 /usr/bin/python -> /usr/bin/python2.7 lrwxrwxrwx 1 root root 18 Mar 28 23:22 /usr/bin/python2 -> /usr/bin/python2.7 -rwxr-xr-x 1 root root 3546104 Nov 19 01:35 /usr/bin/python2.7 lrwxrwxrwx 1 root root 9 Mar 28 03:22 /usr/bin/python3 -> python3.5 -rwxr-xr-x 2 root root 4460336 Nov 17 11:23 /usr/bin/python3.5
$ sudo apt-get install python-setuptools
Arvin@Arvin:~/tools/pip$ wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate --2017-03-28 22:44:39-- https://bootstrap.pypa.io/get-pip.py Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.72.175 Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.72.175|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1595408 (1.5M) [text/x-python] Saving to: ‘get-pip.py’ get-pip.py 100%[===================>] 1.52M 933KB/s in 1.7s 2017-03-28 22:44:41 (933 KB/s) - ‘get-pip.py’ saved [1595408/1595408]
Arvin@Arvin:~/tools/pip$ sudo python get-pip.py
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
$ mkdir ~/.pip $ vim ~/.pip/pip.conf
[list] format=columns
Linux/Unix: /etc/pip.conf ~/.pip/pip.conf ~/.config/pip/pip.conf
sudo apt-get update $sudo apt-get install python-virtualenv $sudo easy_install virtualenvwrapper
mkdir $HOME/.virtualenvs
2.在~/.bashrc中添加行:
export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
source ~/.bashrc
mkvirtualenv [虚拟环境名称]
workon [虚拟环境名称]
deactivate
rmvirtualenv [虚拟环境名称]
注:创建的环境是独立的,互不干扰,无需sudo权限即可使用 pip 来进行包的管理,如果在虚拟环境中使用sudo安装的包在主环境中使用-p参数指定虚拟环境中python的版本~/.bashrc 文件内容
1 # ~/.bashrc: executed by bash(1) for non-login shells. 2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 # for examples 4 5 # If not running interactively, don't do anything 6 case $- in 7 *i*) ;; 8 *) return;; 9 esac 10 11 # don't put duplicate lines or lines starting with space in the history. 12 # See bash(1) for more options 13 HISTCONTROL=ignoreboth 14 15 # append to the history file, don't overwrite it 16 shopt -s histappend 17 18 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 19 HISTSIZE=1000 20 HISTFILESIZE=2000 21 22 # check the window size after each command and, if necessary, 23 # update the values of LINES and COLUMNS. 24 shopt -s checkwinsize 25 26 # If set, the pattern "**" used in a pathname expansion context will 27 # match all files and zero or more directories and subdirectories. 28 #shopt -s globstar 29 30 # make less more friendly for non-text input files, see lesspipe(1) 31 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 32 33 # set variable identifying the chroot you work in (used in the prompt below) 34 if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 35 debian_chroot=$(cat /etc/debian_chroot) 36 fi 37 38 # set a fancy prompt (non-color, unless we know we "want" color) 39 case "$TERM" in 40 xterm-color|*-256color) color_prompt=yes;; 41 esac 42 43 # uncomment for a colored prompt, if the terminal has the capability; turned 44 # off by default to not distract the user: the focus in a terminal window 45 # should be on the output of commands, not on the prompt 46 #force_color_prompt=yes 47 48 if [ -n "$force_color_prompt" ]; then 49 if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 50 # We have color support; assume it's compliant with Ecma-48 51 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 52 # a case would tend to support setf rather than setaf.) 53 color_prompt=yes 54 else 55 color_prompt= 56 fi 57 fi 58 59 if [ "$color_prompt" = yes ]; then 60 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 61 else 62 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 63 fi 64 unset color_prompt force_color_prompt 65 66 # If this is an xterm set the title to user@host:dir 67 case "$TERM" in 68 xterm*|rxvt*) 69 PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 70 ;; 71 *) 72 ;; 75 # enable color support of ls and also add handy aliases 76 if [ -x /usr/bin/dircolors ]; then 77 test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 78 alias ls='ls --color=auto' 79 #alias dir='dir --color=auto' 80 #alias vdir='vdir --color=auto' 81 82 alias grep='grep --color=auto' 83 alias fgrep='fgrep --color=auto' 84 alias egrep='egrep --color=auto' 85 fi 86 87 # colored GCC warnings and errors 88 #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 89 90 # some more ls aliases 91 alias ll='ls -alF' 92 alias la='ls -A' 93 alias l='ls -CF' 94 95 # Add an "alert" alias for long running commands. Use like so: 96 # sleep 10; alert 97 alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 98 99 # Alias definitions. 100 # You may want to put all your additions into a separate file like 101 # ~/.bash_aliases, instead of adding them here directly. 102 # See /usr/share/doc/bash-doc/examples in the bash-doc package. 103 104 if [ -f ~/.bash_aliases ]; then 105 . ~/.bash_aliases 106 fi 107 108 # enable programmable completion features (you don't need to enable 109 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 110 # sources /etc/bash.bashrc). 111 if ! shopt -oq posix; then 112 if [ -f /usr/share/bash-completion/bash_completion ]; then 113 . /usr/share/bash-completion/bash_completion 114 elif [ -f /etc/bash_completion ]; then 115 . /etc/bash_completion 116 fi 117 fi 118 export WORKON_HOME=$HOME/.virtualenvs 119 source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv -p python python2_tornado
$ sudo apt-get install tree
$ scp aaa.txt [email protected]://home/Arvin/work/scp_test The authenticity of host '192.168.170.129 (192.168.170.129)' can't be established. ECDSA key fingerprint is 25:ee:20:66:89:d3:82:7b:0b:61:2a:05:d8:35:5e:c3. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.170.129' (ECDSA) to the list of known hosts. [email protected]'s password: aaa.txt 100% 68 0.1KB/s 00:00
$ scp -r aaa [email protected]://home/Arvin/work/scp_test/ [email protected]'s password: aaa.txt 100% 68 0.1KB/s 00:00 bbb.txt 100% 0 0.0KB/s 00:00 aaa.txt 100% 68 0.1KB/s 00:00
$ scp [email protected]://home/Arvin/work/scp_test/bbb.txt ./ [email protected]'s password: bbb.txt 100% 0 0.0KB/s 00:00
$ scp -r [email protected]://home/Arvin/work/scp_test/aaa/* ./ [email protected]'s password: aaa.txt 100% 68 0.1KB/s 00:00 aaa.txt 100% 68 0.1KB/s 00:00 bbb.txt 100% 0 0.0KB/s 00:00
远程目录复制到本地
fanyu111@fanyu:~/work/work/scp_test$ scp -r [email protected]://home/Arvin/work/scp_test/aaa/ ./ [email protected]'s password: aaa.txt 100% 68 0.1KB/s 00:00 bbb.txt 100% 0 0.0KB/s 00:00 aaa.txt 100% 68 0.1KB/s 00:00
sz filename
sz filename1 filename2
sz dir/*
$ sudo chmod -R 777 aaa
修改文件夹下文件权限
$ sudo chmod 777 aaa/*
修改文件所有者
$ chown fanyu111 aaa
修改文件所有者和组
$ chown - R fanyu111.bbb aaa
$ cat /proc/sys/fs/file-max 399181
$pip install flask
$ tailf aaa.log $ tail -f aaa.log
$sudo apt-get install mysql-server $sudo apt-get install mysql-client $sudo apt-get install libmysqlclient-dev
$sudo netstat -apn | grep mysql
登录mysql
$mysql -u root -p
mysql> show variables like '%char%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) mysql> show variables like '%colla%'; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+ 3 rows in set (0.01 sec)
$sudo vi /etc/mysql/my.cnf
[client] default-character-set=utf8
在[mysqld]标签下,增加服务器端的字符编码
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci
1 # 2 # The MySQL database server configuration file. 3 # 4 # You can copy this to one of: 5 # - "/etc/mysql/my.cnf" to set global options, 6 # - "~/.my.cnf" to set user-specific options. 7 # 8 # One can use all long options that the program supports. 9 # Run program with --help to get a list of available options and with 10 # --print-defaults to see which it would actually understand and use. 11 # 12 # For explanations see 13 # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 14 15 # 16 # * IMPORTANT: Additional settings that can override those from this file! 17 # The files must end with '.cnf', otherwise they'll be ignored. 18 # 19 20 !includedir /etc/mysql/conf.d/ 21 !includedir /etc/mysql/mysql.conf.d/ 22 23 [client] 24 default-character-set = utf8 25 26 [mysqld] 27 character-set-server = utf8 28 collation-server = utf8_general_ci
使用 service 启动:
sudo service mysql restart
create database *** default character set utf8
$Arvin@Arvin:~$ sudo netstat -apn|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1852/mysqld
$Arvin@Arvin:~$ sudo netstat -apn|grep 3306 tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1852/mysqld
$Arvin@Arvin:~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改 bind-address = 127.0.0.1为 bind-address = 0.0.0.0记得要重启mysql服务
$sudo service mysql restart
use mysql;
select user,host from user;
update user set host ='%' where user='root'; grant all on *.* to root@'%' identified by 'root'; flush privileges;
CREATE USER ''@'%' IDENTIFIED BY ''; GRANT ALL ON .* TO ''@'%';
CREATE USER 'user02'@'192.168.201.128' IDENTIFIED BY ''; GRANT ALL ON .* TO ''@'192.168.201.128';
show grants for root@'localhost';
pip install PyMySQL
安装sqlalchemy
pip install sqlalchemy
$ sudo apt-get install memcached $ pip install python-memcached
$sudo apt-get install redis-server
$redis-server
$redis-cli $pip install redis
$which python (python2_tornado) Arvin@Arvin:~/work/tornado_test/Arvin/1_lesson_helloworld$ which python /home/Arvin/.virtualenvs/python2_tornado/bin/python
sudo apt install curl
22、清除浏览器缓存Ctrl+Shift+Del 清除Google浏览器缓存的快捷键Ctrl+Shift+R 重新加载当前网页而不使用缓存内容使用locale命令查看系统当前编码
ubuntu@ubuntu:~$ locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:en_US:en LC_CTYPE="zh_CN.UTF-8" LC_NUMERIC=zh_CN.UTF-8 LC_TIME=zh_CN.UTF-8 LC_COLLATE="zh_CN.UTF-8" LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES="zh_CN.UTF-8" LC_PAPER=zh_CN.UTF-8 LC_NAME=zh_CN.UTF-8 LC_ADDRESS=zh_CN.UTF-8 LC_TELEPHONE=zh_CN.UTF-8 LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=zh_CN.UTF-8 LC_ALL= ubuntu@ubuntu:~$
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com flask