Linux学习

本文最后更新于1年前(2023-1-10 09:36:10),链接可能失效,内容可能难以复现。请注意甄别。

最后编辑:1年

鸟哥的Linux私房菜 [smile]
本站的Linux教程已经撰写完成,点击这里捐赠获得付费会员,即可免费浏览。
《Linux配置操作》
《Linux通用命令》
《Linux通用命令(二)》
《Linux通用命令(三)》
《Linux通用命令(四)》
《Linux Shell》
《Linux服务器网站的配置》

Linux配置操作

本文最后更新于1年前(2018-7-2 09:41:59),链接可能失效,内容可能难以复现。请注意甄别。

0.USB安装
Ubuntu10.04LTS(lucid)为例:
进入“帮助” — F6

install cdrom-detect/try-usb=true

1.设置wlan

# wpa_passphrase SSID PASSWORD > /etc/wpa_config.conf #SSID:网络名,PASSWORD:密码
# vi /etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp //注意在无线路由器上开启DHCP功能
wpa-conf /etc/wpa_config.conf
# /etc/init.d/networking restart #重启网络

安装界面配置静态地址,Subnet(子网的网段)格式:

静态IP地址(有线):

# vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.3.123 
netmask 255.255.255.0
gateway 192.168.3.1
dns-nameserver 114.114.114.114 8.8.8.8 
# /etc/init.d/networking restart

Ubuntu18.04LTS(bionic)

# cd /etc/netplan
/etc/netplan# ll
total 12
drwxr-xr-x  2 root root 4096 Aug 15 03:04 ./
drwxr-xr-x 90 root root 4096 Aug 15 02:46 ../
-rw-r--r--  1 root root  580 Aug 15 02:43 50-cloud-init.yaml #新版本的网络配置在这个文件里
/etc/netplan# vi 50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens33:
            addresses:
            - 192.168.3.123/24
            dhcp4: false
            gateway4: 192.168.3.1
            nameservers:
                addresses:
                - 192.168.3.1
                search: []
    version: 2
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"50-cloud-init.yaml" 17L, 580C                                5,1           All

2.设置更新源
可能由于版本太旧或者更新太慢的问题,需要设置更新源。

# vi /etc/apt/sources.list

格式:

deb [URL] [版本代号] main restricted universe multiverse
deb [URL] [版本代号]-security main restricted universe multiverse
deb [URL] [版本代号]-updates main restricted universe multiverse
deb [URL] [版本代号]-proposed main restricted universe multiverse
deb [URL] [版本代号]-backports main restricted universe multiverse
deb-src [URL] [版本代号] main restricted universe multiverse
deb-src [URL] [版本代号]-security main restricted universe multiverse
deb-src [URL] [版本代号]-updates main restricted universe multiverse
deb-src [URL] [版本代号]-proposed main restricted universe multiverse
deb-src [URL] [版本代号]-backports main restricted universe multiverse
版本号 代号 发布时间
18.04 LTS Bionic Beaver 2018/4/26
17.10 Artful Aardvark 2017/10/19
16.04 LTS Xenial Xerus 2016/4/21
15.10 Wily Werewolf 2015/10/22
15.04 Vivid Vervet 2015/04/23
14.10 Utopic Unicorn 2014/10/23
14.04 LTS Trusty Tahr 2014/04/18
13.10 Saucy Salamander 2013/10/17
13.04 Raring Ringtail 2013/04/25
12.10 Quantal Quetzal 2012/10/18
12.04 LTS Precise Pangolin 2012/04/26
11.10 Oneiric Ocelot 2011/10/13
11.04Unity成为默认桌面环境 Natty Narwhal 2011/04/28
10.10 Maverick Meerkat 2010/10/10
10.04 LTS Lucid Lynx 2010/04/29
9.10 Karmic Koala 2009/10/29
9.04 Jaunty Jackalope 2009/04/23
8.10 Intrepid Ibex 2008/10/30
8.06官方查不到此版本发布信息 Haughty Husky 2008/06/07
8.04 LTS Hardy Heron 2008/04/24
7.10 Gutsy Gibbon 2007/10/18
7.04 Feisty Fawn 2007/04/19
6.10 Edgy Eft 2006/10/26
6.06 LTS Dapper Drake 2006/06/01
5.10 Breezy Badger 2005/10/13
5.04 Hoary Hedgehog 2005/04/08
4.10初始发布版本 Warty Warthog 2004/10/20

* 标记的版本为已过时版本,国内没有对应的更新源镜像地址(只能通过http://old-releases.ubuntu.com/更新)。
Ubuntu10.04LTS(lucid)为例:

deb http://old-releases.ubuntu.com/ubuntu lucid main restricted universe multiverse     
deb http://old-releases.ubuntu.com/ubuntu lucid-security main restricted universe multiverse     
deb http://old-releases.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse     
deb http://old-releases.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse    
deb http://old-releases.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse   
deb-src http://old-releases.ubuntu.com/ubuntu lucid main restricted universe multiverse   
deb-src http://old-releases.ubuntu.com/ubuntu lucid-security main restricted universe multiverse    
deb-src http://old-releases.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse    
deb-src http://old-releases.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse   
deb-src http://old-releases.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse

保存后,执行:

# apt-get update #更新源

以下命令非必要时请勿操作。

# apt-get upgrade #升级已安装软件包

3.挂载光驱

# ls -l /dev | grep cdrom #查询包含cdrom的设备
lrwxrwxrwx  1 root root           3 2018-07-03 12:55 cdrom1 -> sr0
crw-rw----  1 root cdrom    21,   0 2018-07-03 12:55 sg0
brw-rw----+ 1 root cdrom    11,   0 2018-07-03 12:55 sr0
# mount /dev/cdrom1 /mnt #把光驱挂载到/mnt目录
mount: block device /dev/sr0 is write-protected, mounting read-only
mount: /dev/sr0 already mounted or /mnt busy
mount: according to mtab, /dev/sr0 is already mounted on /mnt
# cd /mnt #进入cd挂载的目录
# umount /dev/cdrom1 #卸载光驱

4.安装图形界面(Server版本)
Ubuntu10.04LTS(lucid)为例:

# apt-get install xinit
# apt-get install language-support-zh #安装中文支持
# apt-get install gdm #安装GNOME
# apt-get install ubuntu-desktop #安装ubuntu桌面
# apt-get install gsynaptic #安装新立得软件包管理器
# apt-get install network-manager* #安装网络管理器

切换到图形界面,可以用root或者moecat

$ startx

5.挂载U盘、移动硬盘
FAT32文件系统:

# fdisk -l #列出所有分区

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d91e4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2497    20051968   83  Linux
/dev/sda2            2497        2611      916481    5  Extended
/dev/sda5            2497        2611      916480   82  Linux swap / Solaris

Disk /dev/sdb: 8178 MB, 8178892800 bytes
2 heads, 63 sectors/track, 126780 cylinders
Units = cylinders of 126 * 512 = 64512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00969512

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1      126781     7987168    b  W95 FAT32
# mount -t vfat /dev/sdb1 /mnt #挂载U盘
# cd /mnt
# umount /dev/sdb1 #卸载U盘

NTFS文件系统:

# apt-get install ntfs-3g* #安装NTFS挂载软件
# fdisk -l #列出所有分区
...(省略)...
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      121602   976759808    7  HPFS/NTFS
# mount -t ntfs-3g  /dev/sdc1 /mnt -ro force

6.远程桌面

# apt-get install xrdp vnc4server xbase-clients

/usr/share/applications目录下打开“桌面共享”选项,桌面共享选项中首先要开启共享,关于是否允许其他用户控制,远程连接时是否需要本机确认,远程连接的密码等项目根据需要自己设定。如果需要从公网即外部网络访问此ubuntu计算机需要开启”自动配置UPnP路由器开放和转发端口项目”。
下载安装VNC Viewer软件(Windows)。

7.更改默认语言

# vi /etc/default/locale
LANG=”en_US.UTF-8″
LANGUAGE=”en_US:en”
# locale-gen -en_US:en

8.更改时区

# date -R
Wed, 15 Aug 2018 03:14:08 +0000 #现在时区是0
# tzselect
...(省略)...
 4) Aisa
...(省略)...
#? 4
...(省略)...
 9) China
...(省略)...
#? 9
...(省略)...
 1) Beijing Time
...(省略)...
#? 1
...(省略)...
 1) Yes
...(省略)...
#? 1
...(省略)...
# cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
# date -R
Wed, 15 Aug 2018 11:38:49 +0800 #变成东八区

参考资料

  1. https://blog.csdn.net/snaking616/article/details/52966634
  2. https://blog.csdn.net/cccrunner/article/details/78090079
  3. https://www.jianshu.com/p/e682d5143c15