操作系统-02-Ubuntu 常用命令等汇总

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

the mean of optional:

复制代码
bz2 format  j
gz format    z
c   create
x   unzip
v   detail info
f   file
  • why

    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 jdkfirst.

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

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 startor /etc/inint.d/mysql start

2、Stop MySQL

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

3、Restart MySQL

service mysql restartor /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

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

复制代码
<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 tabto 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
相关推荐
xuanzdhc2 小时前
Linux 基础IO
linux·运维·服务器
愚润求学2 小时前
【Linux】网络基础
linux·运维·网络
bantinghy3 小时前
Linux进程单例模式运行
linux·服务器·单例模式
小和尚同志4 小时前
29.4k!使用 1Panel 来管理你的服务器吧
linux·运维
帽儿山的枪手4 小时前
为什么Linux需要3种NAT地址转换?一探究竟
linux·网络协议·安全
shadon1789 天前
回答 如何通过inode client的SSLVPN登录之后,访问需要通过域名才能打开的服务
linux
小米里的大麦9 天前
014 Linux 2.6内核进程调度队列(了解)
linux·运维·驱动开发
程序员的世界你不懂9 天前
Appium+python自动化(三十)yaml配置数据隔离
运维·appium·自动化
算法练习生9 天前
Linux文件元信息完全指南:权限、链接与时间属性
linux·运维·服务器
忘了ʷºᵇₐ9 天前
Linux系统能ping通ip但无法ping通域名的解决方法
linux·服务器·tcp/ip