关于用户
1 | 切换成root |
修改默认启动级别
假设现在在图形用户界面,打开终端,输入如下命令:
1 | sudo systemctl set-default multi-user.target |
现在如果想进入图形用户界面(仅进入一次,重启系统后仍然会进入命令行模式),可执行如下命令:
1 | sudo systemctl start lightdm |
如果想设置为系统启动后默认进入图形用户界面,执行如下命令:
1 | systemctl set-default graphical.target |
然后执行reboot命令重启系统即可。
更换镜像源
备份默认源地址
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
删除
sources.list
文件,并新建此文件,粘贴下面这些内容:1
2
3
4
5
6
7
8
9
10
11
12
13默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
预发布软件源,不建议启用
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse更新源
apt-get update
软件操作的相关命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16sudo apt-get update 更新源
sudo apt-get install package 安装包
sudo apt-get remove package 删除包
sudo apt-cache search package 搜索软件包
sudo apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package --reinstall 重新安装包
sudo apt-get -f install 修复安装
sudo apt-get remove package --purge 删除包,包括配置文件等
sudo apt-get build-dep package 安装相关的编译环境
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-cache depends package 了解使用该包依赖那些包
sudo apt-cache rdepends package 查看该包被哪些包依赖
sudo apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
xshell/xftp登陆Win10 Linux子系统
备份文件
1
2cd /etc/ssh
sudo cp sshd_config sshd_config.bak修改sshd_config
1
2
3
4
5sudo vim sshd_config
Port 2233 #修改端口
ListenAddress 0.0.0.0 #打开本地监听
StrictModes yes #注释掉
PasswordAuthentication yes #允许密码登陆重启ssh
sudo service ssh restart
xshell/xftp登录
1
2
3
4
5
6
7
8
9
10xshell连接
ip:127.0.0.1
协议:ssh
端口:2233
-------
xftp连接
ip:127.0.0.1
协议:sftp
端口:22
方式:password
安装nginx+php+mysql
安装nginx
安装
apt-get -y install nginx
nginx默认根目录
/usr/share/nginx/html
修改端口
1
2
3
4
5
6
7
8
9
10
11找到nginx.conf
whereis nginx.conf
cd 到 /etc/nginx 目录下,在nginx.conf文件中没看到listen 80的字样,
切换到/etc/nginx/sites-enabled/找到default文件
server {
listen 80 default_server;
listen [::]:80 default_server;
修改80为888
重启nginx
service nginx stop
service nginx start
配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18server {
listen 8881;
listen [::]:8881;
root /usr/share/nginx/web/yifu/public;
index index.html index.htm index.nginx-debian.html index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}