Linux基本知识

图形界面与命令行模式切换

[Ctrl]+[Alt]+[F1][F6]:命令行模式tty1tty6
[Ctrl]+[Alt]+[F7]:图形界面

阅读全文

Eclipse启动问题

Ubuntu Eclipse运行报错

提示jvm版本过低,需要安装1.x及以上版本

  • 已经安装要求版本或以上版本:检查环境变量JAVA_HOME,JRE_HOME,CLASSPATH,PATH
  • 未安装对应版本,去安装

阅读全文

Ubuntu新系统常用开发配置

Oh-my-zsh

  • 安装zsh:$sudo apt-get install zsh
  • 确认zsh安装:$zsh --version
  • 直接用$ sodu vim /etc/passwd更改对应用户所用的shell,将root用户和自己用户(katherine)的shell从bash改为zsh。
  • 注销重新登录
  • 确认zsh是否是默认SHELL,输出/usr/bin/zsh:$echo $SHELL
  • 安装Oh-My-Zsh:$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" (如果提示没安装cur,那么先$ sudo apt-get install curl先安装)
  • Oh-My-Zsh的默认配置文件在~/.zshrc,样式重启终端后生效

.zshrc

在.zshrc上部加入如下内容:

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
# LLVM
export LLVM_HOME=${HOME}/LLVM/llvm-30
# export Melton_HOME=${HOME}/LLVM/Melton/build/bin
export Melton_HOME=${HOME}/LLVM/Melton/llvm/Release+Asserts/bin

# PANDA_HOME
export PANDA_HOME=${HOME}/LLVM/preprocess/panda

# BEAR_HOME
export BEAR_HOME=${HOME}/LLVM/preprocess/bear

# Java
# export JAVA_HOME=/home/katherine/Java/jdk1.7.0_80
export JAVA_HOME=${HOME}/Java/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export CATALINA_HOME=${HOME}/Software/apache-tomcat-8.5.35

export MAVEN_HOME=${HOME}/Software/apache-maven-3.6.0

# If you come from bash you might have to change your $PATH.
export PATH=.:${Melton_HOME}:${PANDA_HOME}:${BEAR_HOME}:${HOME}/LLVM/preprocess/bear:${LLVM_HOME}/build/bin:${JAVA_HOME}/bin:${JRE_HOME}/bin:${MAVEN_HOME}/bin:$HOME/bin:/usr/local/bin:$PATH

# node
export N_PREFIX=/usr/local #node实际安装位置
export PATH=$N_PREFIX/bin:$PATH

Vim及其插件配置

1
sudo apt-get install vim

详细配置见:[Vim安装及我喜欢的配置]

apt源

系统:【Ubuntu 18.04】(其他版本请查找源名称)
将系统自带的source.list备份:

1
$ sudo cp /etc/apt/source.list /etc/apt/source.list.back

将内容全部删除,并更新为 阿里 or 中科大 的源:

1
$ sudo vim /etc/apt/source.list

阿里源:

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

中科大源:

1
2
3
4
5
6
7
8
9
10
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更新源:

1
$ sudo apt-get update

nodejs

1.用PPA安装
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install -y nodejs
2.第一种办法由于不能翻墙,或者网速等各种原因,日常失败,这里使用另一中方法。
淘宝镜像手动安装:参考链接
https://npm.taobao.org/mirrors/node/
找到你所需要的版本包,我使用的是https://npm.taobao.org/mirrors/node/v6.12.0/node-v6.12.0-linux-x64.tar.gz
解压,改名,放入指定目录:

1
2
3
$ tar -zxvf node-v6.12.0-linux-x64.tar.gz
$ mv node-v6.12.0-linux-x64 node-v6.12.0
$ mv node-v6.12.0 ~/Software

这个包是已经编译好了的,只需要添加两个软链接:

1
2
$ sudo ln -s /home/katherine/Software/node-v6.12.0/bin/node /usr/local/bin
$ sudo ln -s /home/katherine/Software/node-v6.12.0/bin/npm /usr/local/bin

查看node和npm的版本:

1
2
$ node -v
$ npm -v

GDebi

GDebi能够根据软件库自行解决.deb包的依赖关系。

1
$ sudo apt-get install gdebi

下载.deb安装包后,安装时不要直接双击使用Ubuntu软件中心安装,推荐右键使用GDebi打开安装。

缺少依赖包

首先sudo apt update
从我的安装经验来说,Ubuntu14.04安装时没有这个现象,Ubuntu16.04安装时即使update了,也提示’The following packages hava unmet dependencies’。
那么对于Ubuntu16.04进行如下操作可解决该问题:
1.$ sudo gedit /etc/apt/sources.list
2.将以下内容粘贴到文本的最下方:
deb cdrom:[Ubuntu 16.04.3 LTS Xenial Xerus - Release amd64 (20170801)]/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
3.$ sudo apt update

阅读全文

Mac下查看已安装的jdk版本及其安装目录

查看已安装的jdk版本及安装目录

1、打开终端,输入:/usr/libexec/java_home -V
注意:输入命令参数区分大小写(-v是不对的,必须是-V)

阅读全文

如何让外网访问主机服务

配置web服务器环境

暂且略过

测试环境是否可用

本机访问:

1
2
$ curl localhost:2333
$ cur 127.0.0.1:2333

以上两种均能访问

外网访问:

1
$ curl 124.16.137.61:2333

却不能访问

此处的124.16.137.61是服务器的外网IP,可以使用curl members.3322.org/dyndns/getip来获取主机外网IP

阅读全文