新闻资讯
看你所看,想你所想

Debian

Debian

Debian

广义的Debian是指一个致力于创建自由作业系统的合作组织及其作品,由于Debian项目众多核心分支中以Linux宏核心为主,而且 Debian开发者 所创建的作业系统中绝大部分基础工具来自于GNU工程 ,因此 “Debian” 常指Debian GNU/Linux。

非官方核心分支还有只支持x86的Debian GNU/Hurd(Hurd微核心),只支持amd64的Dyson(OpenSolaris混合核心)等。这些非官方分支都存在一些严重的问题,没有实用性,比如Hurd微核心在技术上不成熟,而Dyson则基础功能仍不完善。

“Debian” 正式发音为 /ˈdɛ.bi.ən/ ,Debian 是国际化协作项目,官方未指定任何非英文名称。

基本介绍

  • 开发社区:Debian Project
  • 核心分支:Linux,Hurd,OpenSolaris
  • 用户空间:GNU,X11
  • 发行许可:GPL,AGPL,LGPL,FDL,公共域MIT
  • 软体管理:APT/dpkg
  • 支持架构:x86,arm,mips,ppc,s390,sparc

版本记录

Debian的发行及其软体源有五个分支:旧稳定分支(oldstable)、稳定分支(stable)、测试分支(testing)、不稳定分支(unstable)、实验分支(experimental)。
当前的稳定分支即Stretch(即下一个旧稳定分支),所有开发代号均出自Pixar的电影《玩具总动员》。
Debian GNU/Linux历史版本一览表
版本号以及代号发布日期玩具总动员的对应角色主要特点
0.01至0.91
1993年8月至1994年1月
0.93R5
1995年3月
0.93R6
1995年11月
1.1 Buzz
1996年6月17日
巴斯光年
使用Linux核心2.0
1.2 Rex
1996年12月12日
暴龙
1.3 Bo
1997年6月2日
放羊的女孩
2.0 Hamm
1998年7月24日
小猪扑满
2.1 Slink
1999年3月9日
玩具狗
APT问世
2.2 Potato
2000年8月15日
Potato Head先生
3.0 Woody
2002年7月19日
胡迪,电影主角之一的牛仔
3.1 Sarge
2005年6月6日
绿色塑胶玩具士兵的首领
4.0 Etch
2007年4月8日
玩具黑板
5.0.0 Lenny
2009年2月14日
望远镜
6 squeeze
2011年2月16日
三只眼睛的绿色大嘴玩具外星人
7 wheezy
2013年5月4日
一只带着领结的玩具企鹅
加强MultiArch,稳定版本
8 Jessie
2015年4月26日
玩具总动员第二部中的角色,是一个女牛仔
禁用了旧版不安全的SSLv3协定
默认使用 Systemd
9 stretch
2017年06月17日
Debian
10 Buster
2019年中期
这只狗这只狗
11 Bullseye
这匹马这匹马
12 Bookworm
Debian
9 Sid
每日更新
Debian

席德,隔壁的男孩,玩具终结者
软体较新,适合桌面和软体测试

软体管理

一,APT以及dpkg常见用法如下:
APT——Advanced Package Tool
功能具体语句
软体源设定
/etc/apt/sources.list
更新软体源数据
apt-get update
更新已安装软体
apt-get upgrade
更新系统版本
apt-get dist-upgrade
通过安装包或卸载包来修复依赖错误
apt-get -f install
搜寻软体源数据
apt-cache search foo
解压安装软体包
apt-get install foo
重新安装软体包
apt-get --reinstall install foo
删除软体包释放的内容
apt-get remove foo
卸载软体,同时清除该软体配置档案
apt-get --purge remove foo
删除不需要的包
apt-get autoclean
删除所有已下载的包
apt-get clean
自动安装编译一软体所需要的包
apt-get build-dep foo
dpkg——package manager for Debian
功能具体语句
显示DEB包信息
dpkg -I xx.deb
显示DEB包档案列表
dpkg -c xx.deb
安装DEB包
dpkg -i xx.deb
安装DEB包(指定根目录)
dpkg --root=<directory> -i xx.deb
显示所有已安装软体
dpkg -l
显示已安装包信息
dpkg -s foo
显示已安装包档案列表
dpkg -L foo
卸载包
dpkg -r foo
卸载软体包并删除其配置档案
dpkg -P foo
重新配置已安装程式
dpkg-reconfigure foo
从软体源中编译软体流程(适用于少量代码改动或者配置修改)
功能具体语句示例
获取源码
apt-get source foo
apt-get source rox-filer
安装编译依赖
apt-get build-dep foo
apt-get build-dep rox-filer
解压源码
dpkg-source -x foo_version-revision.dsc
dpkg-source -x rox_2.11-3.dsc
修改源码部分
nano ROX-Filer/src/main.c
创建包
dpkg-buildpackage -rfakeroot -b
修改软体可升级状态
echo -e "foo hold" | dpkg --set-selections
二,用dpkg解包打包(或者修改包)的简单用法
1,新建必要档案control
mkdir -p dirname/DEBIAN(dirname名随意,将生成的usr bin lib之类的档案複製到dirname目录下,dirname/为伪根目录)
nano dirname/DEBIAN/control,最简陋的格式如下:
Package: foo
Version: version-revision
Architecture: amd64
Maintainer: xxx
Priority: extra
Description: xxx
2,生成DEB包
dpkg-deb -b --deb-format=2.0 -Zxz -z9 dirname foo_version-revision_arch.deb (为了便于管理包名应遵循DEB包命名格式)
3,解压DEB包安装档案部分
mkdir newdir && dpkg -x foo_version-revision_arch.deb newdir/
4,解压DEB包控制信息部分
mkdir newdir && dpkg -e foo_version-revision_arch.deb newdir/
5,用ar命令解压DEB包
mkdir newdir
cd newdir && ar x foo_version-revision_arch.deb
三,添加常用软体管理命令简短别名
软体管理是一个现代作业系统的基本功能,使用十分频繁,因此有必要设定简短的别名,仅字元界面有效添至~/.profile,仅图形界面有效添至~/.bashrc,比如
export LC_MESSAGES=en_US.UTF-8
alias a="apt-get install --no-install-recommends"
alias b="dpkg-deb -b --deb-format=2.0 -Zxz -z9"
alias c="SDCV_PAGER=more sdcv --color -0 -1"
alias i="dpkg -i"
alias l="dpkg -l | grep"
alias la="ls --file-type -a"
alias ll="la --time-style=long-iso -lh"
alias s="apt-cache search"
alias r="apt-get --purge remove"
alias u="apt-get update;apt-get upgrade"

中文设定

中文显示

複製常用字型
mkdir ~/.fonts && cp simsun.ttc tahoma.ttf tahomabd.ttf unifont.pcf ~/.fonts/
终端显示调整
编辑 ~/.Xdefaults,添加
XTerm*background: grey20
XTerm*foreground: white
XTerm*faceName: unifont
XTerm*utf8Title: true
UXTerm*background: grey20
UXTerm*foreground: white
UXTerm*faceName: unifont
UXTerm*utf8Title: true

中文输入

nano ~/.xinitrc,添加
export LC_CTYPE=en_US.UTF-8
export LC_MESSAGES=zh_CN.UTF-8
eval `dbus-launch --sh-syntax --exit-with-session`
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx
exec fcitx &
nano~/.config/fcitx/profile,启用需要的输入法

虚拟机安装

VMPlayer创建虚拟机,虚拟磁碟设定4G左右即可(如果使用swap可能需要更多),全部作为根分区,档案系统使用
btrfs (mkfs.btrfs -dsingle -l16384 -msingle -n16384 -K -f /dev/sda1) 或者
zfs (zpool create -f -o ashift=12 -o cachefile= -O utf8only=on -O compression=lz4 -O dedup=off -O xattr=off -O secondarycache=none -O checksum=off -O atime=off -m /mountpoint zroot /dev/sda1,需要重新编译核心并生成新的初始化档案系统)
打开 debian-7.5.0-amd64-netinst.iso (无稳定网路使用 debian-7.5.0-amd64-DVD-1。iso )进入安装界面,根据提示安装完毕。
安装基本工具:
dhclient eth0
dpkg --remove-architecture i386 && apt-get update
apt-get install --no-install-recommends \
xserver-xorg-input-evdev xserver-xorg-video-vesa xserver-xorg xterm xinit \
openbox pcmanfm gvfs lxpanel \
fcitx fcitx-pinyin fcitx-ui-classic fcitx-frontend-qt5 \
gtk2-engines gnome-icon-theme clearlooks-phenix-theme \
vim-gtk gpicview lxtask \
unzip unrar p7zip bzip2 xarchiver \
alsa-utils mesa-utils libtxc-dxtn-s2tc0 libgl1-mesa-dri
echo -e "for f in \"pcmanfm --desktop\" lxpanel\ndo\nexec \$f > /dev/null/ 2>&1 &\ndone\nexec openbox" > ~/.xinitrc
startx
#添加chrome浏览器
#取消pcmanfm的root警告
sed -i 's/geteuid/getppid/' /usr/bin/pcmanfm
#使用默认的Clearlooks主题并设定字型
nano ~/.gtkrc-2.0
gtk-font-name = "Sans 10"
gtk-icon-theme-name = "GNOME"
gtk-theme-name = "Clearlooks-Phenix"
#设定GTK+3主题(确定已安装相应的主题引擎)
cp -r /usr/share/themes/Clearlooks-Phenix/gtk-3.0 ~/.config/gtk-3.0
echo -e "gtk-theme-name = Clearlooks-Phenix\ngtk-icon-theme-name = GNOME" >> ~/.config/gtk-3.0/settings.ini
#设定一个滑鼠主题
nano ~/.Xdefaults
Xcursor.theme: OpenZone
几种常见的联网方式
1,使用ppp拨接(ppp依赖libpcap0.8)
####
cat > /etc/ppp/peers/wan << EOF
user "账号"
password "密码"
defaultroute
hide-password
noauth
persist
plugin rp-pppoe.so eth0
usepeerdns
EOF
####
ifconfig eth0 up
poff -a #断开
pon wan #连线
2,连线无线网路
3,USB共享联网
dhclient usb0
合盖不休眠
nano /etc/systemd/logind.conf,添加一行
HandleLidSwitch=ignore

常见问题

自动登录
以root为例,其余用户类似
1,/lib/systemd/system/getty@.service
ExecStart=-/sbin/agetty --noclear %I 38400 linux -a root
2,/etc/rc.local
touch /tmp/X
3,/root/.profile
[ -f /tmp/X ] && rm /tmp/X && /usr/bin/startx
VIM基本设定
nano ~/.vimrc
"vi
language messages en_US.UTF-8
set autoread history=1000 laststatus=2 nobackup nocompatible
set encoding=utf-8 fileencoding=utf-8 fileencodings=ucs-bom,utf-8,gbk,euc-jp,euc-kr,latin1 fileformat=unix termencoding=utf-8 "set termencoding=gbk
set makeprg=make shell=bash shellcmdflag=-c
"vim
if has("vertsplit")
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
color desert
filetype indent on
if expand('%:p') == ''
chdir ~/Document/WORK "$VIM\\..\WORK
endif
"环境变数
let $PS1="\$PWD # "
set autochdir
set linespace=1 list listchars=tab:·\ ,eol:¬ number
syntax on
"绑定键盘
map <F2> :echom "Done"<CR>
imap <F2> <Esc><F2>li
endif
"gvim
if has("gui_running")
"添加选单项
amenu Edit.- :
highlight SpecialKey ctermfg=0 guifg=grey30
highlight NonText guibg=grey20 guifg=grey30
set columns=85 lines=36
set guifont=unifont\ 12 guioptions=aeim guitablabel=%t
endif
MPlayer设定
编译打包MPlayer以便去掉大量无用的依赖库
nano ~/.mplayer/config
af=volnorm,volume=5
ao=alsa
autosync=30
cache=10240
font=SimSun
osdlevel=3
overlapsub=1
quiet=yes
stop-xscreensaver=yes
sub-fuzziness=1
subfont-autoscale=1
subfont-osd-scale=5
subfont-text-scale=6
subcp=utf-8
vo=xv
xy=800
zoom=yes
省电设定
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
for f in /sys/class/scsi_host/host*/link_power_management_policy; do echo min_power > $f; done
for f in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $f; done
1,cpu频率调节设定
ondemand
2,将bbswitch编入核心
任何情况下都不要使用类似nvidia的闭源驱动cp bbswitch.c linux-3.15/drivers/acpi/
sed -i "403s/DEVICE_ACPI_HANDLE/ACPI_HANDLE/" linux-3.15/drivers/acpi/bbswitch.c
sed -i "53iacpi-y\t\t\t\t+= bbswitch.o" linux-3.15/acpi/Makefile
Openbox基本设定
mkdir -p ~/.config/openbox && cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml

添加4个基本的快捷键
F1 打开终端
Ctl+F1 退出
Alt+F1 重启
Mod+F1 关闭视窗
lunar提供的Solar2Lunar函式可以提供公曆农曆转换

<keybind key="W-F1">
<action name="Close"/>
</keybind>
<keybind key="A-F1">
<action name="Restart"></action>
</keybind>
<keybind key="C-F1">
<action name="Exit"><prompt>no</prompt></action>
</keybind>
<keybind key="F1">
<action name="Execute"><command>xterm</command></action>
</keybind>

杂七杂八

由于许多Debian相关词条内容缺失,所以暂时添加一些繁琐的内容附在后面
GRUB2
syslinux不支持btrfs(开启压缩)和zfs,而grub2支持常见的档案系统,扩展性强。此外,非Linux平台可以使用grub4dos。
######/boot/grub/grub.cfg
insmod all_video
insmod gettext
insmod gfxterm
insmod part_msdos
insmod zfs
loadfont $prefix/fonts/unicode。pf2
set default="0"
set gfxmode=auto
set have_grubenv=true
set lang=
set locale_dir=$prefix/locale
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
set timeout=3
terminal_output gfxterm
menuentry 'Debian -- The Universal Operating System' {
linux /@/boot/vmlinuz acpi_backlight=vendor MOUNT="/bin/zpool import -f zroot" ROOT="" INIT="/lib/systemd/systemd"
initrd /@/boot/initrd.img
}
#引导ISO
menuentry 'ISO' {
linux16 /boot/syslinux/memdisk raw iso
initrd16 /boot/xx.iso
}
#使用其他分区引导
menuentry 'Other Bootloader' {
set root='(hdX,msdosY)'
chainloader +1
}
安装至磁碟主引导或者分区引导
grub-install --root-directory=/path/to/root/ --no-floppy /dev/sdX(Y)
nano /path/to/root/boot/grub/grub.cfg
字型
<fontconfig>
<selectfont><acceptfont><pattern>
<patelt name="family"><string>unifont</string></patelt>
</pattern></acceptfont></selectfont>
<match target="font" >
<test compare="less" name="size" ><double>8</double></test>
<edit mode="assign" name="size" ><double>8</double></edit>
</match>
<match>
<test name="family"><string>SimSun</string></test>
<test name="style"><string>Regular</string></test>
<edit name="antialias" mode="assign"><bool>false</bool></edit>
</match>
<match>
<test name="family"><string>宋体</string></test>
<test name="style"><string>Regular</string></test>
<edit name="antialias" mode="assign"><bool>false</bool></edit>
</match>
<alias><family>sans-serif</family>
<prefer>
<family>Tahoma</family>
<family>SimSun</family>
</prefer>
</alias>
<alias><family>serif</family>
<prefer>
<family>Tahoma</family>
<family>SimSun</family>
</prefer>
</alias>
<alias><family>monospace</family>
<prefer>
<family>DejaVu Sans Mono</family>
<family>unifont</family>
</prefer>
</alias>
</fontconfig>
虚拟磁碟
file initrd.img #查看档案类型
fdisk -l initrd.img #查看虚拟磁碟分区
mount -t <fs> -o loop,offset=<Start*Sector> initrd.img /mnt#挂载虚拟磁碟(raw格式)分区
cpio -i -d < initrd.img #cpio解压
find . | cpio --quiet -R 0:0 -o -H newc | gzip -9 > ../initrd.img #cpio打包后用gzip压缩
一个busybox製作初始化档案系统简单例子如下:
#编译安装
rm -rf busybox && git clone https://github。com/mirror/busybox
cd busybox
make allyesconfig
make -j 20
make install
#修改档案(/lib64/ld-linux-x86-64。so.2複製到lib64/,其余库档案複製到lib/)
cd _install
mkdir etc
cp -r ../examples/bootfloppy/etc/init{.d,tab} etc/
rm linuxrc && touch etc/fstab
cat > init << EOF
#!/bin/sh
/bin/mkdir /sys && /bin/mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
/bin/mkdir /proc && /bin/mount -t proc -o nodev,noexec,nosuid proc /proc
/bin/mdev -s && /bin/echo /bin/mdev > /proc/sys/kernel/hotplug
[ -z "\$MOUNT" ] && exec /bin/init; \$MOUNT; [ ! -z "\$ROOT" ] && /bin/mount --bind \$ROOT /root; exec /bin/switch_root /root \${INIT:-/lib/systemd/systemd}
EOF
#挂载新根目录位置命令比如 MOUNT="/bin/mount -t btrfs UUID= /root"
#转到新根目录后第一个执行程式路径比如sysvinit INIT="/sbin/init"
核心的部分设定参数也可以添加到init中
比如:
/bin/sync && /bin/echo 3 > /proc/sys/vm/drop_caches
/bin/echo OFF > /proc/acpi/bbswitch
/bin/echo 2 > /proc/sys/vm/overcommit_memory
/bin/echo 0 > /proc/sys/vm/swappiness
/bin/echo 1000 > /sys/class/backlight/intel_backlight/brightness
改变init许可权
chmod 755 init
生成initrd.img
find . | cpio --quiet -R 0:0 -o -H newc | gzip -9 > ../initrd.img
bootstrap
对于一个具体的平台来说,只能安装与当前核心相同架构的Debian系统(64位系统支持32位)。
简单使用流程如下(安装一个amd64架构、sid分支Debian GNU/Linux基础系统):
Debian家族作业系统apt-get install debootstrap即可使用,非Debian家族作业系统(指任何其他GNU/Linux发行版)或者不想安装该软体
git clone git://anonscm.debian。org/d-i/debootstrap.git
注意,debootstrap运行时需要bash脚本MAKEDEV
make -C debootstrap
nano debootstrap/debootstrap #将 /usr/share/debootstrap 替换为 ./debootstrap
#ppp用来拨接,iw、wpasupplicant等用来连线连线无线网路或者创建无线网路
./debootstrap/debootstrap \
--include=debootstrap,initramfs-tools,btrfs-tools,grub2,\
ppp,iw,wpasupplicnat,dnsmasq,bridge-utils,ssh,ftp,axel \
--exclude=aptitude,aptitude-common,nano,tasksel,tasksel-data --arch amd64 sid sid-dir ftp://ftp.debian。org/debian/
cd sid-dir
tar cpJf ../sid-dir.txz *
mount -t btrfs -o defaults,compress=zlib,noatime,nobarrier /dev/sda1 /mnt
tar xpf sid-dir.txz -C /mnt/
#修改 /mnt/etc/fstab如下:
echo -e "en_US.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8" > /mnt/etc/locale.gen
echo "DEBIAN" > /mnt/etc/hostname
echo -e "127.0.0.1\nDEBIAN DEBIAN" >> /mnt/etc/hosts
cat /mnt/usr/share/zoneinfo/Asia/Chongqing > /mnt/etc/localtime #时区设定(BIOS时钟为本地时间)
echo "Asia/Chongqing" > /mnt/etc/timezone
echo -e "\n\nLOCAL" > /mnt/etc/adjtime
mount --bind /dev /mnt/dev
mount -t tmpfs /tmp /mnt/tmp
mount -t proc /proc /mnt/proc
mount -t sysfs /sys /mnt/sys
chroot /mnt /bin/bash
hwclock --systohc
passwd root
echo "nameserver 8.8.8.8" > /etc/resolv.conf
nano /etc/apt/sources.list
apt-get update && apt-get install locales
apt-get install linux-image-amd64 #安装核心或者使用自编译核心(dpkg -i linux-image-x.x.x_x.x.x-1_amd64.deb)
apt-get install grub2
编译核心
一般个人配置核心编译时间在4分钟以内,3.15小于2.5MB(不生成可载入模组)
tar xpf linux-x.x.x.tar.xz
cd linux-x.x.x && cp /boot/config-x.x.x .config
make menuconfig
make -j20 deb-pkg #临时使用只需安装linux-image-x.x.x_x.x.x-1_amd64.deb
几个常见用法:
① make localmodconfig #处理.config(取消当前运行核心未载入模组)
② sed -i 's/=m/=y/' .config #不生成可载入模组

使用管理

如果你使用Debian软体包管理器来管理Linux软体,应该详细了解Debian软体仓库的原理,这有助于使用Linux命令将让你更容易管理Debian软体。
Linux软体包管理使用的Debian软体库,Debian提供了软体包的安装源。Debian管理器会自动查找库和安装Debian包的依赖关係。如果没有Debian软体库管理系统,要解决这些Debian软体包的依赖关係是一种烦恼。
按目前的Linux分布情况,主要的Debian软体库管理系统是Debian的软体库管理系统,主要用于Debian、Ubuntu和其Linux衍生系统上,如Linux Mint;Debian软体库管理系统使用默认的Debian软体包格式。Debian用.deb。这些Debian软体包是将软体和元数据压缩和档案。Debian元数据提供了有关软体的版本信息,以及Debian软体包的依赖关係。
但Debian软体包的资料库与Debian软体库很容易混淆。虽然通过Debian软体库管理使这些Debian软体包可以让工作更简单,但这些Debian软体包同时有另一个资料库。这意味着Debian软体包的信息来源可以有多个:Debian包资料库和Debian软体库资料库。
使用Debian包资料库工作

Debian包资料库是Debian软体安装了。在Linux系统里最重要的信息来源。Debian包资料库从伺服器上检索当前安装的Debian软体,Debian包档案通常是一个丰富的Debian文档和Debian软体使用的信息源,这对于Linux系统Debian软体包之间的依赖关係非常有用。
在基于Debian的Linux伺服器,使用dpkg命令。例如,dpkg -L命令可以读取Debian软体包清单,或rpm -ql命令显示哪些档案被包含在一个Debian软体包。
使用Debian软体仓库工作

在安装新的Debian软体或进行Debian软体升级,系统管理员通常使用Debian软体仓库。尤其是更新Debian伺服器补丁的时候,Debian软体仓库会更方便:Debian软体包管理器只需要更新新的软体包,使Debian自动可用,Debian库用户便可以使用它们,这过程完全是透明的。
在基于Debian软体仓库的系统,Debian索引档案需要手动更新,使用Debian的apt-get update命令来更新本地机器上的Debian软体包快取。Debian包快取更新完成后,便可以很容易的Debian安装软体包和更新。
Debian系统会自动比较了软体仓库的Debian安装包和Debian安装在本地系统的Debian软体包列表,以确定一个Debian包已经安装,或者是否有可用的Debian更新。
Debian软体仓库管理系统在处理Debian软体包依赖关係非常好用:目前所有的Linux都提供了丰富的Debian资料库,并提供必要的Debian依赖,这意味着Linux管理员对Debian软体包的依赖恐惧大大减少了。
Debian软体仓库中没有的包

Debian软体仓库中没有的软体,意味着Debian安装起来比较困难。管理员可以创建自己的Debian软体库和複製本地的Debian软体包。这也让管理员从库安装自定义Debian软体包的时候,进一步减少Debian依赖问题。

相关推荐

声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com