Appearance
基础配置
网络
sh
$ ip link show
$ ip -s link show <iface>
# 启动关闭网卡
$ ip link set <iface> up
$ ip link set <iface> down
# 混合模式
$ ip link set <iface> promisc on
$ ip link set <iface> promisc off
# 设置最大传输单位
$ ip link set <iface> mtu <n>
# ipaddr
$ ip link add <ip4 addr/24> dev <iface>
$ ip link del <ip4 addr/24> dev <iface>
# 路由
$ ip route show
$ ip route list
# 默认路由
$ ip route add defautl via <route ip> dev <iface>
$ ip route add <ip4 addr> via <route ip> dev <iface>
$ ip route del default
$ ip route del <route addr> dev <iface>
# 网络邻居 neighbor
$ ip neigh show
# NetworkManager
$ apt install network-manager
$ yum install NetworkManager
$ systemctl status NetworkManager
$ nmcli connection show [uuid|iface]
$ nmcli c add con-name <cname> ifname <iface> type <enternet|birdge|tun|loopback>
$ nmcli c modify <iface> ipv4.method auto
$ nmcli c up <iface>防火墙
sh
# administraction tool for IPv4/IPv6 packet filtering and NAT
$ iptables
# nftables: iptables 代替品
# firewalld: RHEL 默认
# ufw: ubuntu 简化工具日期时间
NTP, Network Time Protocol
sh
$ apt install chrony
# rockylinux, /etc/chrony.conf
# debian, /etc/chrony/chrony.conf
# NTP Pool Project: https://www.ntppool.org/zh/
server <ntp server> iburst
# china ntp server cn.pool.ntp.org
server server 0.cn.pool.ntp.org iburst
server server 1.cn.pool.ntp.org iburst
server server 2.cn.pool.ntp.org iburst
server server 3.cn.pool.ntp.org iburst
$ chronyc sources
# control system time and time
$ timedatectl
# 查看时区
$ cat /etc/timezone
# 查看时区表
$ timedatectl list-timezones
# 设置时区
$ timedatectl set-timezone=Asia/Shanghai
# 打印或设置系统日期和时间
$ date
# 写入 BIOS 时间钟
# 虚拟机 BIOS 也是虚拟的,因此不需要使用 hwclock 写入
$ hwclock -w语系
sh
# 打印时区相关系统变量
$ locale
# 打印可使用时区
$ locale -a
# 临时设置语言
$ LANG=<locale>
# control the system locale and keyboard layout settings
$ localectl
$ localectl list-locales
$ localectl set-locale <locale>主机名称
sh
# control the system hostname
$ hostnamectl
# 设置
$ hostnamectl set-hostname --static '<hostname>'
# 传统方式修改 /etc/hostname
# 生效
$ systemctl restart --static systemd-hostnamed
# 一些操作系统需改重载网络模块
# centos
$ systemctl restart NetworkManager
# debian
$ systemctl restart networking
# 之后,确保 /etc/hosts 的映射关系
127.0.0.1 localhost <new-hostname>命令别名
sh
# define or display aliases
$ alias
alias la='ls $LS_OPTIONS -lA'
alias ll='ls $LS_OPTIONS -l'
alias ls='ls $LS_OPTIONS'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'帮助文件
sh
# display one-line manual page descriptions
$ whatis <cmd>
# search the manual page names and descriptions
$ apropos <cmd>
# manual
$ man [n] <cmd>
# n=1: 用户指令
# n=2: 系统调用
# n=3: 库函数
# n=4: 设备文件,/dev 目录下文件
# n=5: 文件格式和配置文件
# n=6: 游戏
# n=7: 杂项
# n=8: 系统管理员命令
# n=9: Kernal 相关文件
# man 操作,man 内容查看使用 less(cmd) ;见篇,文件系统/内容检索
# equivalent to whatis
$ man -k <key>
# equivalent to apropos
$ man -f <key>
# 创建或更新帮助手册索引缓存
$ mandb登出与关机
登出,终止 terminal 关联的 bash 进程,不会停止其他任务执行。
sh
# 登出
$ exit
$ logout
# 快捷键方式
# [ctrl] + [d]
# 关机
# 需要切换管理员权限
$ poweroff
$ shutdown -h now
$ halt
$ systemctl poweroff命令历史
sh
# display or manipulate the history list
$ history
# 清空历史记录
$ history -c
# 将当前历史记录写入文件
$ history -w
# 重复执行命令 history 打印排序的第 n 条命令
$ !<n>
$ !<-n>
# 等价于 !-1
$ !!
# 重复执行命令 根据关键词最近最相似的命令
$ !<key>
# history 系统变量
# HISTSIZE:当前会话内存保存命令数
# HISTFILESIZE:~/.bash_history 历史文件保存命令数
# HISTFILE:历史文件路径
# 打印相关参数
$ set | grep HIST数学计算
sh
# an arbitrary precision calculator language
$ bc
# equivalent pi
$ echo "scale=10;4*a(1)" | bc -l打印机
CUPS, Common Unix Printer System
sh
cups
cups-browsed
cups-client
cups-common
cups-core-drivers
cups-daemon
cups-filters
cups-filters-core-drivers
cups-ipp-utils
cups-ppdc
cups-server-common