Ubuntu使用技巧
命令
获取系统安装包的编译源码及脚本
apt-get source package
查询端口被占用的进程
lsof -i:端口号
配置
配置阿里源
# mv /etc/apt/source.list /etc/apt/source.list.bak
# vim /etc/apt/sources.list
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
SSH允许ROOT登入
### 编辑配置文件,修改'PermitRootLogin without-password'为'PermitRootLogin yes'
# vim /etc/ssh/sshd_config
### 重启ssh服务
# service ssh restart
切换成GNOME界面
# apt-get install gnome-shell
# apt-get install gnome-panel
# apt-get install gnome-terminal
# apt-get install plymouth-label
# apt-get install open-vm-tools
切换窗口管理器
# dpkg-reconfigure gdm
apt源更新报错
E: Failed to fetch cdrom://Ubuntu-Server 16.04 LTS _Xenial Xerus_ - Release amd64
### 删除apt配置文件对应源 deb cdrom:XX
# vim /etc/apt/sources.list
启动VNC服务
### Ubuntu 14.04 TLS
# vnc4server -geometry 1600x1080 :2
# vnc4server -kill :2
时间同步
### 修改时区
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
### 安装NTP并同步时间
# apt install chrony
# chronyc sources
Ubuntu Server添加中文支持
### 安装language support
# apt install language-pack-zh-hans
# apt install language-selector-gnome
### language support的键盘输入模式系统选择iBus
### Region & Language的Input Sources添加Chinese(SunPinyin)
### 最后必须关机
# halt
软件自动更新设置
### 编辑自动更新配置文件,去掉需要自动更新的软件注释
# vim /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
### 开启软件自动更新
# vim /etc/apt/apt.conf.d/10periodic
APT::Periodic::Update-Package-Lists "1"; //显示更新包列表,0表示停用设置
APT::Periodic::Download-Upgradeable-Packages "0"; //下载更新包,0表示停用设置
APT::Periodic::AutocleanInterval "0"; //N日后自动清理软件包
APT::Periodic::Unattended-Upgrade "1"; //启用自动更新,0表示停用自动更新
安装rabbitmq-server
### 安装rabbitmq
# apt-get install rabbitmq-server
# systemctl start rabbitmq-server
# systemctl enable rabbitmq-server
### 开启web访问
# vim /etc/rabbitmq/rabbitmq.config
[{rabbit, [{loopback_users, []}]}].
# rabbitmq-plugins enable rabbitmq_management
# systemctl restart rabbitmq-server