Ubuntu

Ubuntu是一个开源软件平台,可以在从智能手机、平板电脑和个人电脑到服务器和云端等各种设备上运行。

ubuntu

Title: Desktop Ubuntu desktop->command: Ctrl+Alt+F2~F6 command->desktop: Ctrl+Alt+F7

Login

  • Change to root user
$ sudu su
  • Login to aliyun
houbinbindeMacBook-Pro:~ houbinbin$ ssh root@139.196.28.125
The authenticity of host '139.196.28.125 (139.196.28.125)' can't be established.
ECDSA key fingerprint is SHA256:TuvleHE4/wRMGxcPesBBf2+cNqQZWYGgidKLcrNme0c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '139.196.28.125' (ECDSA) to the list of known hosts.
root@139.196.28.125's password:
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-86-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Welcome to aliyun Elastic Compute Service!

这个阿里云的Ubuntu是14.04.4, 而如果是真正的Ubuntu 系统,可能会16.04.4 及其以后 ,内置php为7.0。可能会导致很不顺利。

Install php5 in Ubuntu

zhihu

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php5.6 libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-xmlrpc
sudo a2dismod php7.0.8
sudo a2enmod php5.6
sudo systemctl restart apache2

install components

git

  • install
root@iZuf60ahcky4k4nfv470juZ:~# apt-get install git

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,306 kB of archives.
After this operation, 21.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty/main liberror-perl all 0.17-1.1 [21.1 kB]
Get:2 http://mirrors.aliyun.com/ubuntu/ trusty-security/main git-man all 1:1.9.1-1ubuntu0.3 [699 kB]
Get:3 http://mirrors.aliyun.com/ubuntu/ trusty-security/main git amd64 1:1.9.1-1ubuntu0.3 [2,586 kB]
Fetched 3,306 kB in 2s (1,227 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 121809 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.3_all.deb ...
Unpacking git-man (1:1.9.1-1ubuntu0.3) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.3_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.3) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:1.9.1-1ubuntu0.3) ...
Setting up git (1:1.9.1-1ubuntu0.3) ...
  • test
root@iZuf60ahcky4k4nfv470juZ:~# git --version
git version 1.9.1

jdk

command

  • download jdk1.8
root@iZuf60ahcky4k4nfv470juZ:~/tools# wget http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz

--2016-09-24 13:18:09--  http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 206.160.170.51, 206.160.170.9
Connecting to download.oracle.com (download.oracle.com)|206.160.170.51|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz [following]
--2016-09-24 13:18:10--  https://edelivery.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.9.199.85
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.9.199.85|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
--2016-09-24 13:18:11--  http://download.oracle.com/errors/download-fail-1505220.html
Connecting to download.oracle.com (download.oracle.com)|206.160.170.51|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5307 (5.2K) [text/html]
Saving to: ‘jdk-8u101-linux-x64.tar.gz’

100%[===============================================================================================================================================================>] 5,307       --.-K/s   in 0s

2016-09-24 13:18:12 (712 MB/s) - ‘jdk-8u101-linux-x64.tar.gz’ saved [5307/5307]

root@iZuf60ahcky4k4nfv470juZ:~/tools# ls
jdk  jdk-8u101-linux-x64.tar.gz
  • unzip
jdk-8u101-linux-x64.tar.gz: HTML document, ASCII text, with very long lines, with CRLF line terminators
root@iZuf60ahcky4k4nfv470juZ:~/tools/jdk# tar -zxvf jdk-8u101-linux-x64.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

the mean of optional:

bz2 format  j
gz format    z
c   create
x   unzip
v   detail info
f   file
root@iZuf60ahcky4k4nfv470juZ:~/tools/jdk# file jdk-8u101-linux-x64.tar.gz
jdk-8u101-linux-x64.tar.gz: HTML document, ASCII text, with very long lines, with CRLF line terminators

Well, we download the jdk into local, and then upload it to the Ubuntu server.

$   scp jdk-8u102-linux-x64.tar.gz root@139.196.28.125:/root/tools/jdk
$   tar -zxvf jdk-8u101-linux-x64.tar.gz

root@iZuf60ahcky4k4nfv470juZ:~/tools/jdk# ls
jdk1.8.0_102  jdk-8u102-linux-x64.tar.gz
root@iZuf60ahcky4k4nfv470juZ:~/tools/jdk# mv jdk1.8.0_102 jdk1.8
root@iZuf60ahcky4k4nfv470juZ:~/tools/jdk# ls
jdk1.8  jdk-8u102-linux-x64.tar.gz
  • config jdk env path

1、edit .bashrc

$   vi ~/.bashrc

You can copy the file if necessary cp .bashrc .bash_original

2、add these at the end of file

export JAVA_HOME=/root/tools/jdk/jdk1.8
export CLASSPATH=${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

3、make it work at once

$   source ~/.bashrc

4、test jdk

$   java -version

java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

maven

Before this, you need install the jdk first.

  • download
$   wget http://apache.fayea.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

--2016-09-24 14:55:08--  http://apache.fayea.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
Resolving apache.fayea.com (apache.fayea.com)... 119.6.242.164, 119.6.242.165
Connecting to apache.fayea.com (apache.fayea.com)|119.6.242.164|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8491533 (8.1M) [application/x-gzip]
Saving to: ‘apache-maven-3.3.9-bin.tar.gz’

100%[===============================================================================================================================================================>] 8,491,533   5.54MB/s   in 1.5s

2016-09-24 14:55:10 (5.54 MB/s) - ‘apache-maven-3.3.9-bin.tar.gz’ saved [8491533/8491533]

root@iZuf60ahcky4k4nfv470juZ:~/tools/maven# ls
apache-maven-3.3.9-bin.tar.gz
  • unzip
$   tar -zxvf apache-maven-3.3.9-bin.tar.gz

root@iZuf60ahcky4k4nfv470juZ:~/tools/maven# ls
apache-maven-3.3.9  apache-maven-3.3.9-bin.tar.gz
  • config maven

1、edit .bashrc

$   vi ~/.bashrc

2、append these lines at the file end

# set maven environment
export M2_HOME=/root/tools/maven/apache-maven-3.3.9
export PATH=$M2_HOME/bin:$PATH

3、work at once

$   source ~/.bashrc

4、 test maven

$ mvn --version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /root/tools/maven/apache-maven-3.3.9
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /root/tools/jdk/jdk1.8/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-86-generic", arch: "amd64", family: "unix"

mysql

install mysql

  • install mysql-server
$   apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server-5.5
  mysql-server-core-5.5
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  libsql-statement-perl libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server
  mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,927 kB/8,971 kB of archives.
After this operation, 96.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-common all 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
Err http://mirrors.aliyun.com/ubuntu/ trusty-updates/main mysql-server all 5.5.49-0ubuntu0.14.04.1
  404  Not Found [IP: 112.124.140.210 80]
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-common_5.5.49-0ubuntu0.14.04.1_all.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/libmysqlclient18_5.5.49-0ubuntu0.14.04.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-client-core-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-client-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-server-core-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-server-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]

E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/m/mysql-5.5/mysql-server_5.5.49-0ubuntu0.14.04.1_all.deb  404  Not Found [IP: 112.124.140.210 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
  • update
$   apt-get update

...

  • re-install
$  apt-get install mysql-server

...
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-common all 5.5.52-0ubuntu0.14.04.1 [12.9 kB]
Get:2 http://mirrors.aliyun.com/ubuntu/ trusty-security/main libmysqlclient18 amd64 5.5.52-0ubuntu0.14.04.1 [596 kB]
Get:3 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-client-core-5.5 amd64 5.5.52-0ubuntu0.14.04.1 [705 kB]
Get:4 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-client-5.5 amd64 5.5.52-0ubuntu0.14.04.1 [1,468 kB]
Get:5 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-server-core-5.5 amd64 5.5.52-0ubuntu0.14.04.1 [3,282 kB]
Get:6 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-server-5.5 amd64 5.5.52-0ubuntu0.14.04.1 [1,845 kB]
Get:7 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-server all 5.5.52-0ubuntu0.14.04.1 [11.3 kB]
  • install mysql-client
$   apt-get install mysql-client

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  mysql-client
0 upgraded, 1 newly installed, 0 to remove and 89 not upgraded.
Need to get 11.1 kB of archives.
After this operation, 130 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty-security/main mysql-client all 5.5.52-0ubuntu0.14.04.1 [11.1 kB]
Fetched 11.1 kB in 0s (970 kB/s)
Selecting previously unselected package mysql-client.
(Reading database ... 123003 files and directories currently installed.)
Preparing to unpack .../mysql-client_5.5.52-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-client (5.5.52-0ubuntu0.14.04.1) ...
Setting up mysql-client (5.5.52-0ubuntu0.14.04.1) ...
  • install libmysqlclient-dev
$   apt-get install libmysqlclient-dev
  • test mysql
$   netstat -tap | grep mysql

tcp        0      0 localhost:mysql         *:*                     LISTEN      7506/mysqld
  • login mysql
$   mysql -u root -p

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.52-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


$   show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
  • attention

Table name in ubuntu is case sensitive, so. If you want it works like in windows. Just:

add the content under [mysqld], and restart it.

vi /etc/mysql/my.cnf

lower_case_table_names = 1

and then use show variables like 'lower_%' test it:

+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   |
| lower_case_table_names | 1     |
+------------------------+-------+

1、Start MySQL

service mysql start or /etc/inint.d/mysql start

2、Stop MySQL

service mysql stop or /etc/inint.d/mysql stop

3、Restart MySQL

service mysql restart or /etc/inint.d/mysql restart

  • Uninstall mysql
service mysql stop
sudo apt-get autoremove --purge mysql-server-5.0
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common

tomcat

  • download
$   wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-9/v9.0.0.M10/bin/apache-tomcat-9.0.0.M10.tar.gz
  • unzip
$   ls
apache-tomcat-9.0.0.M10.tar.gz

$   tar -zxvf apache-tomcat-9.0.0.M10.tar.gz
$   ls
apache-tomcat-9.0.0.M10  apache-tomcat-9.0.0.M10.tar.gz

$   mv apache-tomcat-9.0.0.M10 apache-tomcat9
  • set utf8

add URIEncoding="UTF-8" in conf/server.xml at:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

Visit Web

W3m

  • install
sudo apt-get install w3m w3m-img -y
  • zh_CN
sudo apt-get install zhcon -y

Useful command

  • restart
$   reboot
  • get all run threads
$   ps -ef
  • get version
$   apt-get install mysql-server-

use double tab to get the version list.

方向键错乱

ubuntu下 vi输入方向键会变成ABCD,这是ubuntu预装的是vim tiny版本,安装vim full版本即可解决。

先卸载vim-tiny:

$ sudo apt-get remove vim-common

再安装vim full:

$ sudo apt-get install vim

22 port

Ubuntu 默认22端口是没有开启的。

ssh: connect to host 192.168.1.105 port 22: Connection refused
lost connection
  • check
ps -e|grep ssh

啥都没

  • install
$   sudo apt-get install openssh-server

纯命令行启动

此方法应该只适用于14-*.

blog zh_CN

$ sudo vi /etc/default/grub

修改如下:

  1. 注释 GRUB_CMDLINE_LINUX_DEFAULT
  2. GRUB_CMDLINE_LINUX=”” 改成 GRUB_CMDLINE_LINUX=”text”
  3. GRUB_TERMINAL=console 注释去除
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="text"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

重新生成配置文件

$   sudo update-grub

保持电源关机后仍然运行

修改 Login Manager的配置文件。 打开终端:

$   sudo vi /etc/systemd/logind.conf

然后将其中的:

#HandleLidSwitch=suspend 改成: HandleLidSwitch=ignore

然后重启服务:

$   sudo restart systemd-logind