操作系统-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
相关推荐
苹果醋330 分钟前
Java8->Java19的初步探索
java·运维·spring boot·mysql·nginx
不是笨小孩i39 分钟前
开源AI图片处理工具HivisionIDPhotos安装与证件照制作指南
ubuntu
二十雨辰44 分钟前
[linux]docker基础
linux·运维·docker
Jason-河山1 小时前
【自动化更新,让商品信息跳舞】——利用API返回值的幽默编程之旅
运维·自动化
饮浊酒1 小时前
Linux操作系统 ------(3.文本编译器Vim)
linux·vim
lihuhelihu2 小时前
第3章 CentOS系统管理
linux·运维·服务器·计算机网络·ubuntu·centos·云计算
哲讯智能科技2 小时前
SAP Business One市场价格解析
运维·sap·erp
矛取矛求2 小时前
Linux系统性能调优技巧
linux
山东布谷科技官方2 小时前
布谷直播源码部署服务器关于数据库配置的详细说明
运维·服务器·数据库·直播系统源码·直播源码·直播系统搭建·直播软件开发
One_Blanks2 小时前
渗透测试-Linux基础(1)
linux·运维·安全