在ubuntu软件商店安装vscode
1 |
$ sudo snap install --classic code |
报错:
无法安装visual studio code,
1 |
$ snap vscode has install-snap change in process |
Ubuntu(友邦拓,网友也喜欢称之为“乌班图”)是一个以桌面应用为主的Linux操作系统,其名称来自非洲南部祖鲁语或豪萨语的“ubuntu”一词,意思是“人性”、“我的存在是因为大家的存在”,是非洲传统的一种价值观,类似华人社会的“仁爱”思想.
在ubuntu软件商店安装vscode
1 |
$ sudo snap install --classic code |
报错:
无法安装visual studio code,
1 |
$ snap vscode has install-snap change in process |
最近升级到ubuntu 20.04
之后,大量的软件都已经通过snap
方式安装了,但是由于国内没有镜像服务器,导致下载速度很慢,解决方式如下:
1 2 3 4 5 6 7 |
$ sudo apt-get install snapd $ sudo snap install snap-store $ sudo snap install snap-store-proxy $ sudo snap install snap-store-proxy-client |
1 2 3 4 5 6 7 8 |
$ sudo snap install snap-store $ sudo snap install snap-store-proxy $ sudo snap install snap-store-proxy-client # 更新已经安装的软件 $ sudo snap refresh |
另外更推荐的方法是通过 Tomcat 的配置文件完成,而不是修改代码,具体配置方法为:
在 conf/server.xml 配置文件中的 <Host> 配置项中添加如下配置:
1 |
<Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" /> |
配置项说明:
其他的方案跟 Ubuntu 14.04隐藏Tomcat-7.0.52的版本号与操作系统类型 是一致的,但是具体的细节上存在不小的差异,还是需要记录一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ cd ~ $ mkdir catalina $ cd catalina $ cp /usr/share/tomcat9/lib/catalina.jar . $ unzip catalina.jar $ cd org/apache/catalina/util $ vim ServerInfo.properties |
可以看到里面的内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. server.info=Apache Tomcat/9.0.16 (Ubuntu) server.number=9.0.16.0 server.built=Sep 11 2019 19:47:51 UTC |
直接注释掉里面的内容,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # server.info=Apache Tomcat/9.0.16 (Ubuntu) # server.number=9.0.16.0 # server.built=Sep 11 2019 19:47:51 UTC |
修改完成后,把修改完成的数据存储到catalina.jar
中。
1 2 3 4 5 6 7 |
$ cd ~ $ cd catalina $ sudo apt install openjdk-11-jdk-headless $ jar uvf catalina.jar org/apache/catalina/util/ServerInfo.properties |
把修改后的catalina.jar
放回到Tomcat
的目录下面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ cd ~ $ cd catalina $ sudo unlink /usr/share/tomcat9/lib/catalina.jar $ sudo mv /usr/share/java/tomcat9-catalina.jar /usr/share/java/tomcat9-catalina.jar.old $ sudo cp catalina.jar /usr/share/java/ $ sudo chmod +r /usr/share/java/catalina.jar $ cd /usr/share/tomcat9/lib $ sudo ln -s ../../java/catalina.jar catalina.jar |
重启Tomcat
的服务
1 |
$ sudo service tomcat9 restart |
腾讯云Ubuntu Server 16.04.7 LTS
升级系统到Ubuntu Server 18.04.5 LTS
之后,letsencrypt
证书更新出现异常,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ sudo ./letsencrypt-auto Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt: Traceback (most recent call last): File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in <module> from certbot.main import main File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 2, in <module> from certbot._internal import main as internal_main File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/_internal/main.py", line 6, in <module> import logging.handlers File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module> import sys, os, time, cStringIO, traceback, warnings, weakref, collections File "/usr/lib/python2.7/weakref.py", line 14, in <module> from _weakref import ( ImportError: cannot import name _remove_dead_weakref |
原因为系统版本变化过大导致以前安装的Python
组件不能适应最新的系统,最简单的方法就是删除之前安装的Python
组件,让letsencrypt
重新安装即可。
1 2 3 4 5 |
$ sudo apt-get install python-pip $ sudo rm -rf /opt/eff.org/ $ sudo ./letsencrypt-auto |
Cannot renew certificate “ImportError: cannot import name _remove_dead_weakref”
参考 阿里云ECS ubuntu 14.04.5 LTS升级到ubuntu 16.04.2 LTS / 阿里云从ubuntu16.04.5升级到ubuntu 18.04.3后调整PHP 7.0到PHP 7.2 整个的升级步骤是差不多的,腾讯的升级流程更加顺利。
但是在升级完成之后,遇到了一个域名解析问题,报错如下:
1 2 3 4 5 6 7 8 9 10 |
$ ping www.baidu.com ping: www.baidu.com: Temporary failure in name resolution $ sudo apt-get update Err:1 http://mirrors.tencentyun.com/ubuntu bionic InRelease Temporary failure resolving 'mirrors.tencentyun.com' Err:2 http://mirrors.tencentyun.com/ubuntu bionic-security InRelease Temporary failure resolving 'mirrors.tencentyun.com' Err:3 http://mirrors.tencentyun.com/ubuntu bionic-updates InRelease Temporary failure resolving 'mirrors.tencentyun.com' |
这个原因是因为我们在安装过程中,覆盖了腾讯设置的域名解析服务配置文件。
这个配置文件是/etc/resolv.conf
。
但是,在Ubuntu Server 18.04.5 LTS
系统上,直接修改/etc/resolv.conf
的话,重启系统之后,设置会被还原。我们需要修改/etc/systemd/resolved.conf
才行。
根据地域的不同,服务器的地址存在差异,参考下面的脚本即可。
广州服务器:
1 2 3 4 5 6 7 8 |
# 不存在则增加 $ sudo sed -i "s/^#DNS=.*/DNS=10.138.224.65 10.182.20.26 10.182.24.12/g" /etc/systemd/resolved.conf # 存在则替换 $ sudo sed -i "s/^DNS=.*/DNS=10.138.224.65 10.182.20.26 10.182.24.12/g" /etc/systemd/resolved.conf # 重启服务,配置生效 $ sudo systemctl restart systemd-resolved.service |
上海服务器:
1 2 3 4 5 6 7 8 |
# 不存在则增加 $ sudo sed -i "s/^#DNS=.*/DNS=10.236.158.106 10.237.148.54 10.237.148.60/g" /etc/systemd/resolved.conf # 存在则替换 $ sudo sed -i "s/^DNS=.*/DNS=10.236.158.106 10.237.148.54 10.237.148.60/g" /etc/systemd/resolved.conf # 重启服务,配置生效 $ sudo systemctl restart systemd-resolved.service |
香港服务器:
1 2 3 4 5 6 7 8 |
# 不存在则增加 $ sudo sed -i "s/^#DNS=.*/DNS=10.243.28.52 10.145.0.57 10.145.0.58/g" /etc/systemd/resolved.conf # 存在则替换 $ sudo sed -i "s/^DNS=.*/DNS=10.243.28.52 10.145.0.57 10.145.0.58/g" /etc/systemd/resolved.conf # 重启服务,配置生效 $ sudo systemctl restart systemd-resolved.service |
今天发现cn.archive.ubuntu.com
不能更新了,只能换成国内源:
1 2 3 4 |
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak # 阿里云 $ sudo sed -i "s/cn.archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list |
重新安装的ubuntu 18.04系统上初次安装python3-pip
之后,执行升级命令,出现如下错误信息:
1 2 3 4 5 6 7 |
$ sudo apt-get install python3-pip $ sudo pip3 install --upgrade pip Traceback (most recent call last): File "/usr/local/bin/pip3", line 7, in <module> from pip._internal import main ModuleNotFoundError: No module named 'pip._internal' |
解决方法为重新升级安装一次 pip,如下:
1 |
$ python3 -m pip install --upgrade pip |
如果 Synology NAS 出现故障,则可以使用计算机和 Ubuntu live CD 轻松恢复其硬盘上存储的数据。确保 Synology NAS 硬盘上运行的文件系统是 EXT4 或 Btrfs,然后按照以下步骤恢复数据。此处我们以 Ubuntu 18.04 版本为例。
通过 /var/log/auth.log
文件可以查看一些关于 ssh
登陆、sudo
命令的信息。尤其是 denyhosts
依赖这个日志拦截非法的登陆攻击。 但是,我最近遇到了一个问题,在阿里云的一些主机上没有这个文件,或者日志文件在自动备份(比如被重命名成 /var/log/auth.log.1
)之后,没有重新生成新的 /var/log/auth.log
。
检查 /var/log
目录的所有者信息,如下:
1 2 |
$ ls -l /var/ | grep log drwxr-xr-x 23 root syslog 4096 Apr 8 18:04 log |
这里的所有者权限信息是不正确的,缺少所有者所在组的文件创建权限,导致文件创建出现问题。因此需要如下命令:
1 2 3 4 |
$ chmod -R 775 /data/log $ ls -l /var/ | grep log drwxrwxr-x 23 root syslog 4096 Apr 8 18:04 log |
接着手工创建日志文件,如下:
1 2 3 4 5 6 7 |
$ touch /var/log/auth.log $ chmod 640 /var/log/auth.log $ chown syslog.adm /var/log/auth.log $ ls -la /var/log/auth.log |