安装 Ubuntu
  VExS4Gg6g4KD 13天前 21 0

安装

(01)获取 Ubuntu 24.04

Ubuntu 24.04(Noble Numbat):下载


[1]  从以下网站下载 Ubuntu 24.04(2024 年 4 月 25 日发布,支持至 2034 年 4 月底)。

https://releases.ubuntu.com/24.04/

 

为 Ubuntu 24.04(U盘)创建安装介质


  将 ISO 映像写入 U盘,为 Ubuntu 24.04 创建安装介质。

  如果您在 Windows 上创建它,请参阅以下内容。

[2]  从以下站点下载并安装 [Fedora Media Writer]。

https://github.com/FedoraQt/MediaWriter/releases

 

[3]  将 U 盘连接到计算机。

  接下来,运行 Fedora Media Writer 并选择 [select .iso file] 选项。

 

[4]  对于 USB 驱动器部分,选择您要编写 ISO 映像的 U盘。对于文件部分,选择您下载的 ISO 映像。如果可以,请点击 [Write] 按钮开始写入。写入完成后,弹出 U盘并继续安装步骤。

 

为 Ubuntu 24.04(DVD)创建安装介质


  将 ISO 映像写入 DVD 以创建 Ubuntu 24.04 的安装介质。

  如果您使用 Windows 10/11 的功能创建它,请参阅以下内容。

 

[5]  将空 DVD 插入光驱。接下来,右键单击 Fedora 的 ISO 映像,并在菜单中选择 [Burn Disk image]。

 

[6]  点击 [Burn] 按钮,开始书写。

  写入完成后,弹出磁盘并继续安装步骤。

 

(02)安装 Ubuntu 24.04

Ubuntu 24.04 LTS:安装


  安装 Ubuntu 24.04 服务器。

 

[1]  插入用于安装 Ubuntu 24.04 的磁盘并重新启动计算机。接下来,选择您的语言并继续下一步。

 

[2]  选择键盘布局。使用 Tab 键移动到下一个字段、使用 Enter 键查看列表、使用光标键选择项目。

 

[3]  选择要安装的 Ubuntu 服务器基础。

 

[4]  这是网络配置部分。如果本地网络中存在DHCP服务器,则会自动分配IP地址。

 

[5]  如果需要,请设置代理服务器 URL。如果不需要,可以继续清空。

 

[6]  输入镜像服务器 URL 从中获取包。通常,它通过检测您的位置自动配置最近的一个。

 

[7]  这是存储配置部分。配置分区布局等。如果您没有特定要求,可以继续使用默认设置。

 

[8]  这是存储配置摘要。如果全部确定,请选择[完成]并继续下一步。

 

[9]  需要确认,因为所选存储中的现有数据已全部格式化。如果确定,选择 [Continue]。

 

[10]  设置管理用户帐户。输入您喜欢的任何用户名和密码。

 

[11] 选择是否升级到 Ubuntu Pro。
  Ubuntu Pro 提供 10 年的付费支持。
  但是,最多可以免费使用 5 台设备供个人使用。(需要 Ubuntu One 帐户)

 

[12]  在此安装过程中选择是否安装 SSH 服务器。

 

[13]  选择它们经常用于服务器使用的应用程序或软件环境。如果您没有特定要求,可以在不检查任何项目的情况下继续操作。

 

[14]  安装过程完成后,选择 [Reboot Now] 以重新启动计算机。

 

[15]  重新启动计算机后,使用您在安装过程中设置的用户和密码登录。 如果正常登录,则您的 Ubuntu Server 安装成功完成。

Ubuntu 24.04 LTS ubuntu ttyS0

ubuntu login: ubuntu
Password:
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Fri Apr 26 01:09:32 UTC 2024

  System load:  0.2                Processes:               143
  Usage of /:   21.9% of 27.39GB   Users logged in:         0
  Memory usage: 5%                 IPv4 address for enp1s0: 10.0.0.213
  Swap usage:   0%

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status



The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu:~$

 

初始设置

(01)添加用户

初始设置:添加用户账户


  安装 Ubuntu 系统后,除了系统帐户之外,在安装过程中只配置了一个用户,并且该用户是管理用户。

  如果要在系统上添加更多常用用户帐户,请按如下方式进行配置。

 

[1]  例如,添加 [noble] 用户。

ubuntu@localhost:~$ sudo adduser noble
ubuntu@localhost:~$
[sudo] password for ubuntu:  # input your password
info: Adding user `noble' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `noble' (1001) ...
info: Adding new user `noble' (1001) with group `noble (1001)' ...
info: Creating home directory `/home/noble' ...
info: Copying files from `/etc/skel' ...
New password:           # set user password
Retype new password:    # confirm
passwd: password updated successfully
Changing the user information for noble
Enter the new value, or press ENTER for the default
        Full Name []:   # input user info (OK with empty all if you do not need)
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
info: Adding new user `noble' to supplemental / extra groups `users' ...
info: Adding user `noble' to group `users' ...

 

[2]  如果要向新用户授予权限,请按如下方式进行配置。

ubuntu@localhost:~$ sudo usermod -aG sudo noble
ubuntu@localhost:~$ su - noble
Password:
# try to run a command which requires root privilege
noble@localhost:~$ sudo ls -la /root
[sudo] password for noble:     # input self password
total 28
drwx------  4 root root 4096 Apr 26 01:43 .
drwxr-xr-x 23 root root 4096 Apr 26 01:07 ..
-rw-------  1 root root   21 Apr 26 01:43 .bash_history
-rw-r--r--  1 root root 3106 Apr 22 13:04 .bashrc
drwx------  2 root root 4096 Apr 26 01:43 .cache
-rw-r--r--  1 root root  161 Apr 22 13:04 .profile
drwx------  2 root root 4096 Apr 26 01:09 .ssh

 

[3]  如果要删除用户帐户,请按如下方式进行配置。

# remove a user [noble] (only removed user account)
ubuntu@localhost:~$ sudo deluser noble
# remove a user [noble] (removed user account and his home directory)
ubuntu@localhost:~$ sudo deluser noble --remove-home

 

(02)启用root用户

初始设置:启用root用户帐户


  默认情况下,Ubuntu 中的 root 帐户是禁用的,因为他的密码没有设置。 要使用 root 权限,基本上最好将 sudo 命令用于管理帐户。 但是,如果您出于某种原因想使用root帐户本身,则可以使用如下所示。

 

[1]  安装过程中添加的用户帐户是使用 Sudo 设置的管理帐户,因此很容易获得 root 帐户的 shell,如下所示。

ubuntu@localhost:~$ sudo -s
[sudo] password for ubuntu:   # input self password
root@localhost:/home/ubuntu#  # just switched

 

[2]  或者可以使用标准 su 命令切换到 root 帐户来设置 root 帐户的密码。

ubuntu@localhost:~$ sudo passwd root
ubuntu@localhost:~$ su -
[sudo] password for ubuntu:   # input self password
New password:                 # set root password
Retype new password:          # confirm
passwd: password updated successfully


Password:                     # input root password
root@localhost:~#             # just switched

 * 此站点上的示例按 root 用户帐户显示。如果您使用 sudo,请在命令的头部添加 [sudo]。

  如果启用 root 帐户,最好将可以 [su] 的用户限制为 root,如下所示。对于Sudo的使用, 可以在 sudoers 配置中限制为禁止 shell,请参阅有关 Sudo 设置的详细信息。

 

[3]  对于 [su] 命令限制,请按如下方式设置。

root@localhost:~# vi /etc/pam.d/su
# line 15 : uncomment and add a group which is allow to run [su] command
# add an user you allowed to run [su] to the group you set above
root@localhost:~# usermod -aG adm ubuntu
auth       required   pam_wheel.so  group=adm

 

(03)网络设置

初始设置:网络设置


  如果使用 Ubuntu 作为服务器,请更改为静态 IP 地址。

[1]  接口名称 [enp1s0] 在每个环境中都不同,请将其替换为您自己的接口名称。

# rename to disable default setting
root@localhost:~# mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.org
root@localhost:~# vi /etc/netplan/01-netcfg.yaml
# create new
network:
  ethernets:
    # interface name
    enp1s0:
      dhcp4: false
      # IP address/subnet mask
      addresses: [10.0.0.30/24]
      # default gateway
      # [metric] : set priority (specify it if multiple NICs are set)
      # lower value is higher priority
      routes:
        - to: default
          via: 10.0.0.1
          metric: 100
      nameservers:
        # name server to bind
        addresses: [10.0.0.10,10.0.0.11]
        # DNS search base
        search: [srv.world,server.education]
      dhcp6: false
  version: 2

# apply changes
root@localhost:~# chmod 600 /etc/netplan/01-netcfg.yaml
root@localhost:~# netplan apply
root@localhost:~# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:3c:1c:70 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe3c:1c70/64 scope link
       valid_lft forever preferred_lft forever

 

[2]  如果您不需要 IPv6,可以按如下方式禁用它。

root@localhost:~# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
root@localhost:~# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
root@localhost:~# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:3c:1c:70 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever

 

(04)配置服务

初始设置:服务设置


  要查看服务状态或启用/禁用服务,请按如下方式进行配置。

[1]  显示服务。

# display services which are running
# to add [--all], display all included inactive servises
# to add [--no-pager], do not use pagers like [less/more]
root@localhost:~# systemctl -t service
# display list of all services' setting
root@localhost:~# systemctl list-unit-files -t service
  UNIT                       
  apparmor.service           
  apport.service             
  blk-availability.service   
  console-setup.service      
  cron.service               

.....
.....

  upower.service                 
  user-runtime-dir@1000.service  
  user@1000.service              

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of S>
        SUB    → The low-level unit activation state, values depend on unit typ>

49 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.


UNIT FILE                                    STATE           PRESET
apparmor.service                             enabled         enabled
apport-autoreport.service                    static          -
apport-coredump-hook@.service                static          -
apport-forward@.service                      static          -
apport.service                               enabled         enabled
apt-daily-upgrade.service                    static          -
apt-daily.service                            static          -
apt-news.service                             static          -
autovt@.service                              alias           -
blk-availability.service                     enabled         enabled

.....
.....

xfs_scrub@.service                           static          -
xfs_scrub_all.service                        static          -
xfs_scrub_fail@.service                      static          -

239 unit files listed.

 

[2]  如果有一些不必要的服务,可以停止并关闭自动启动设置,如下所示。(可以省略 [.service] 字)

root@localhost:~# systemctl stop apparmor
root@localhost:~# systemctl disable apparmor

 

(05)更新系统

初始设置:更新系统


  在它成为生产系统之后,也许很难更新系统,但是,至少在安装后,将Ubuntu Server更新到最新版本。

[1]  更新您的 Ubuntu 服务器。

# update List first
root@localhost:~# apt update
# update System
root@localhost:~# apt -y upgrade
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [89.7 kB]
Hit:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Fetched 89.7 kB in 2s (39.0 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

 

(06)配置Vim

初始设置 : Vim 设置


 

 

 

 

(07)配置Sudo

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: NTP/SSH 服务器 下一篇: 【Liunx】Docker安装
  1. 分享:
最后一次编辑于 13天前 0

暂无评论

推荐阅读
  tAaiqedz71Vf   4天前   14   0   0 Linux
  2sqDzWaoi9Ck   4天前   15   0   0 Linux
LVM
  XWcNkifzer3j   4小时前   4   0   0 Linux