更换软件源
查看Linux版本
lsb_release -a
,获取codename1
2
3
4
5
6root@root:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy替换源
1
2
3sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
sudo chmod 777 /etc/apt/sources.list
sudo gedit /etc/apt/sources.list输入(jammy为第一步获取的名字):
1
2
3
4
5
6
7
8
9
10deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse更新:
1
2sudo apt-get update #这个命令会访问源列表里的每个网址,并读取软件列表,将其保存在本地
sudo apt-get upgrade #这个命令会更新本地已安装的软件
基础配置
配置管理员密码与基础工具
1
2
3
4
5
6
7
8修改管理员密码
sudo passwd root
安装网络工具|ssh|vim
sudo apt-get install net-tools ssh vim -y
关闭防火墙
sudo ufw disable安装远程目录
samba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17sudo apt-get install samba -y
sudo vim /etc/samba/smb.conf
输入
[home]
path = /home
comment = Home Disk
public = yes
writeable = yes
directory mask = 0777
create mask = 0777
browseable = yes
available = yes
force user = root
添加用户
sudo pdbedit -a xxxxx
安装远程挂载服务
nfs
1
2
3
4
5
6sudo apt-get install nfs-kernel-server -y
sudo chmod 777 /etc/exports
sudo vim /etc/exports
再文档最后写上挂载目录
/home *(rw,sync,no_root_squash)
安装远程桌面
1 | 安装xfce4 |
打开windows桌面远程连接,输入账号密码即可:
新建用户
复制用户初始文件到
/etc/skel/
目录下,比如QT配置等添加用户
1
2
3
4
5
6
7
8
9
10
11
12
13添加普通用户
sudo adduser xxxx
ubuntu添加管理员用户
sudo usermod -G sudo xxxx
centos添加管理员用户
chmod u+w /etc/sudoers
vim /etc/sudoers
添加行
xxxx ALL=(ALL) AL
删除权限
chmod u-w /etc/sudoers
Linux扩展命令
查看磁盘情况 [duf](muesli/duf: Disk Usage/Free Utility - a better ‘df’ alternative (github.com)),类似
df
命令,可用来看挂载情况查看文件夹大小 dust -d 1,1表示深度,类似
du
命令查看Linux资源情况 [btm](ClementTsang/bottom: Yet another cross-platform graphical process/system monitor. (github.com)),类似
top
命令
挂载新硬盘到home
查看当前的连接的硬盘
fdisk -l
挂载新硬盘
fdisk /dev/sdb
1
2
3Command (m for help): n(创建新分区)
... ...(全都默认操作)
Command (m for help): w(完成退出)格式化分区
mkfs -t ext4 -c /dev/sdb
挂载临时目录并拷贝home目录文件
1
2
3mount /dev/sdb1 /mnt
cp -rf /home/* /mnt
umount /mnt挂载到home
1
2mount /dev/sdb1 /home/ #将sdb1挂载到/home
blkid /dev/sdb1 #记录sdb1的UUID开机自动挂载
1
2
3
4
5
6查看UUID
lsblk -f
修改开机挂载脚本
vi /etc/fstab
在最后增加一行
UUID=da797df3-cfa3-4a8b-aea6-2df53e41ba42 /home ext4 defaults 1 2