JeffyLu.github.io icon indicating copy to clipboard operation
JeffyLu.github.io copied to clipboard

ubuntu常见的几个问题

Open JeffyLu opened this issue 9 years ago • 10 comments

ubuntu常见的几个问题

  • 1. 关闭客人会话
  • 2. WPS提示系统缺失的字体
  • 3. 修改mysql默认字符编码
  • 4. jdk环境变量设置
  • 5. 解决eclipse无法识别apt-get安装的tomcat
  • 6. 配置python3.5虚拟环境
  • 7. myeclipse启动tomcat出现Permission denied
  • 8. python导入sqlite3提示错误:No module named _sqlite3
  • 9. 关闭用户登录权限
  • 10. 解决gedit和vim打开gbk编码文件出现乱码问题

JeffyLu avatar Feb 19 '17 04:02 JeffyLu

1. 关闭客人会话

打开lightdm.conf文件

$ sudo vi /etc/lightdm/lightdm.conf

在文件中添加如下内容:

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
allow-guest=false

重启系统

JeffyLu avatar Feb 19 '17 04:02 JeffyLu

2. WPS提示系统缺失的字体

  • 下载字体:wps_symbol_fonts.zip
  • 解压后将整个文件夹拷到/usr/share/fonts/目录下
  • 添加权限
$ cd /usr/share/fonts/
$ sudo chmod 755 wps_symbol_fonts
$ cd wps_symbol_fonts 
$ sudo chmod 644 *

JeffyLu avatar Feb 19 '17 08:02 JeffyLu

3. 修改mysql默认字符编码

  • 打开mysql配置文件:
$ vim /etc/mysql/my.cnf
  • [client]下追加:
default-character-set=utf8
  • [mysqld]下追加:
character-set-server=utf8
  • [mysql]下追加:
default-character-set=utf8
  • 重启mysql服务器
$ sudo service mysql restart

JeffyLu avatar Feb 20 '17 03:02 JeffyLu

4. jdk环境变量设置

$ sudo vim /etc/profile

添加如下内容:

export JAVA_HOME=/opt/jdk1.8.0_121    <your jdk path>
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

JeffyLu avatar Feb 20 '17 06:02 JeffyLu

5. 解决eclipse无法识别apt-get安装的tomcat

$ sudo ln -s /var/lib/tomcat7/conf /usr/share/tomcat7/conf
$ sudo ln -s /etc/tomcat7/policy.d/03catalina.policy /usr/share/tomcat7/conf/catalina.policy
$ sudo ln -s /var/log/tomcat7 /usr/share/tomcat7/log
$ sudo chmod -R 777 /usr/share/tomcat7/conf

JeffyLu avatar Feb 22 '17 07:02 JeffyLu

6. 配置python3.5虚拟环境

安装python

$ sudo apt-get install libssl-dev
$ cd ~
$ wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
$ tar -xvzf Python-3.5.1.tgz
$ cd ~/Python-3.5.1
$ ./configure --prefix=/usr/local/python35
$ make
$ sudo make install

创建并进入虚拟环境,安装pip(安装了virtualenv和virtualenvwrapper的情况下)

$ mkvirtualenv -p /usr/local/python35/bin/python3 py35
$ workon py35
$ curl https://bootstrap.pypa.io/get-pip.py|python
$ pip install --upgrade pip

JeffyLu avatar Feb 23 '17 12:02 JeffyLu

7. myeclipse启动tomcat出现Permission denied

添加一个系统用户tomcat,并且设置为不可登录系统。

$ sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

设置用户tomcat对tomcat目录的访问权限

$ chown -R tomcat:tomcat /usr/tomcat/
$ chmod -R 777 /usr/tomcat

JeffyLu avatar Feb 26 '17 07:02 JeffyLu

8. python导入sqlite3提示错误:No module named _sqlite3

$ sudo apt-get Install sqlite-devel

或者

$ sudo apt-get install libsqlite3-dev

重新编译安装python

$ cd path/to/python/package
$ ./configure --prefix=/usr/local/python35 --enable-loadable-sqlite-extensions && make && sudo make install

JeffyLu avatar Mar 05 '17 03:03 JeffyLu

9. 关闭用户登录权限

$ cd /var/lib/AccountsService/users
$ sudo vi username

添加如下信息:

[User]
SystemAccount=true

保存退出 重启

JeffyLu avatar Mar 16 '17 14:03 JeffyLu

10. 解决gedit和vim打开gbk编码文件出现乱码问题

  • gedit

终端输入以下命令,注意不要使用sudo:

$ gsettings set org.gnome.gedit.preferences.encodings auto-detected "['GB18030', 'GB2312', 'GBK', 'UTF-8', 'BIG5', 'CURRENT', 'UTF-16']"
$ gsettings set org.gnome.gedit.preferences.encodings shown-in-menu "['GB18030', 'GB2312', 'GBK', 'UTF-8', 'BIG5', 'CURRENT', 'UTF-16']"
  • vim

.vimrc配置文件中添加如下内容:

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8

JeffyLu avatar Mar 26 '17 11:03 JeffyLu