一、官网下载ubuntu-base
http://cdimage.ubuntu.com/ubuntu-base/releases/
本文章使用的是:buntu-base-22.04.5-base-arm64.tar.gz
解压:
mkdir ubuntu_rootfs
sudo tar -zxvf ubuntu-base-22.04.5-base-arm64.tar.gz -C ubuntu22.04
sudo apt-get install qemu-user-static
sudo cp /usr/bin/qemu-arm-static ubuntu20.04/usr/bin/
sudo cp /etc/resolv.conf ubuntu22.04/etc/resolv.conf
chmod 777 ubuntu22.04/tmp
sudo ./mount_rootfs.sh -m ubuntu22.04
ubuntu-ports | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirroryy
#!/bin/bash
# mount : sudo ./mount_rootfs.sh -m debian11_serve/
# unmount : sudo ./mount_rootfs.sh -u debian11_serve/
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt(){
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or bothparameters were missing"
echo ""
echo "1'st parameter can be one ofthese: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full pathof rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m/media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
安装必备软件
apt-get update #首先更新源
apt-get upgrade #升级软件
apt-get install sudo -y
apt-get install openssh-server -y
apt-get install network-manager -y
apt-get install vim -y
apt-get install net-tools -y
apt-get install iproute2 -y
apt-get install udhcpc -y
apt install systemctl -y
apt install gcc -y
apt install make -y
apt install adb -y
apt install ethtool -y
apt install ifupdown -y
apt install htop -y
apt install iputils-ping -y
apt install -y bash-completion
apt install sudo vim udev net-tools ethtool udhcpc netplan.io language-pack-en-base language-pack-zh-han* iputils-ping openssh-sftp-server ntp usbutils alsa-utils libmtp9
新建普通用户无法sudo
问题描述:无法用sudo
sudo:/usr/bin/sudo 必须属于用户 ID 0(的用户)并且设置 setuid 位
解决方法:
最终目的只有一个,想办法执行
$ chmod 4755 /usr/bin/sudo
$ chmod 755 /usr
解决:perl: warning: Please check that your locale settings
问题:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LC_TERMINAL_VERSION = "3.3.3beta2",
LC_TERMINAL = "iTerm2",
LANG = "en_US.utf8"
are supported and installed on your system.
方法
`sudo apt-get install language-pack-en-base language-pack-zh-han*`
在.bashrc的最后加上
export LC_ALL=C
source /root/.bashrc
或者/etc/profile
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
开启 root 账号登录的方法
不建议开启,以下步骤仅供参考。
Debian 默认禁用 root SSH 密码登录(Pubkey 认证不受此限,默认启用),安装时候创建特定用户作为管理员帐号(通过 sudo 执行特权命令),启用 root 用户步骤如下:
- 修改 root 密码(设置密码后可以通过控制台登录)
sudo passwd root
- 修改配置文件(启用 SSH 密码登录)
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.baksudo vi /etc/ssh/sshd_config
找到下面相关配置:
# Authentication:#LoginGraceTime 2m#PermitRootLogin prohibit-password#StrictModes yes#MaxAuthTries 6#MaxSessions 10#PubkeyAuthentication yes# Expect .ssh/authorized_keys2 to be disregarded by default in future.#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
修改如下:
补充:
PermitRootLogin prohibit-password #允许 root 登录,但禁止使用密码认证可以配合使用 Pubkey 认证,默认 `PubkeyAuthentication yes`
- 或者直接快速配置
sudo sed -i.bak "/^#PermitRootLogin/c"PermitRootLogin""yes"" /etc/ssh/sshd_config# 或者sudo sed -i.bak '/^#PermitRootLogin/c\PermitRootLogin yes' /etc/ssh/sshd_config
- 重启服务生效
sudo systemctl restart ssh
最近在Linux新增加用户时,发现新用户登录,终端只显示$,输入时tab键没有补全功能
usermod -s /bin/bash cwt
标签:get,Ubuntu22.04,sudo,文件系统,apt,echo,构建,install,mount
From: https://www.cnblogs.com/Wynterwei/p/18322564