Linux发行版本和基础命令

常见Linux的发行版及它们的联系与区别

  • 各大Linux发行版的主要异同:支持标准
     每个Linux发行版使用的内核都由https://www.kernel.org网站所发布,而它们所选择的软件,几乎都是很知名的软件,重复性相当的高,例如网页服务器的Apache,电子邮件服务器的Postfix/sendmail,文件服务器的Samba等。
     为了让所有的Linux发行版本不至于差异太大,且让这些开发商在开发的时候有所依据,还有Linux Standard Base(LSB)以及目录结构File System Hierarchy Standard(FHS)等标准来规范开发商,唯一的差别,可能就是该厂商所开发出来的管理工具,以及套件管理的模式有所不同。
  • 基于安装软件方式来发区分行版本

  1. RPM包管理
 商业公司:

RHEL(Redhat)

SUSE(Micro Focus)

 网络社区:


Fedora
openSUSE

CentOS

 2. DPKG包管理

 商业公司:


Ubantu(Canonical Ltd.)

 网络社区:


Debian

  3.其他

Gentoo


date命令的使用

  • 打印显示当前时间,格式是:20181209211008
[root@localhost ~]# date +%Y%m%d%H%M%S
20190322144310

poweroff命令的使用

  • 实现晚上20:30自动关机,并提示用户
 poweroff -h 20:30 "It's time to shut down the machine."

历史命令管理以及用法

  • 最基本的查看历史命令
history
  • 执行编号为n的历史命令
!666             # !后只需要跟上你想要执行命令在历史命令里的序列号即可
  • !-n 倒数第n个历史命令
!666           # 用 ! - (倒数第几个命令)来执行历史命令,比如 !-1 就是倒数第一个命令, !-3就是倒数第三个命令
  • !! 上一条命令
!!            # !! 表示上一条命令,相当于 !-1或者直接按方向键上
  • !word 查找包含该word的历史命令
!vim    #查找包含vim的历史命令,回车执行这条历史命令,若有相同名称的则取最近一次命令
  • !$ 上一条命令的最后一条参数
[root@localhost ~]# ls /var/lib/cobbler/kickstarts/
default.ks    install_profiles      sample_esx4.ks   sample_esxi6.ks  sample.seed
esxi4-ks.cfg  legacy.ks         sample_autoyast.xml  sample_esxi4.ks  sample.ks       
esxi5-ks.cfg  pxerescue.ks      sample_end.ks        sample_esxi5.ks  sample_old.seed  
[root@localhost ~]# cd !$
cd /var/lib/cobbler/kickstarts/
[root@localhost kickstarts]# pwd
/var/lib/cobbler/kickstarts
  • !^ 上一条命令的第一个参数
[root@localhost ~]# cp anaconda-ks.cfg anaconda-ks.cfg.bak
[root@localhost ~]# vim !^
vim anaconda-ks.cfg
  • !:n 第n个参数

^与$表示第一个参数和最后一个参数,而 :n 就表示第n个参数,比如 !:2就表示上一条命令的第2个参数

[root@localhost ~]# cp anaconda-ks.cfg anaconda-ks.cfg.bak
[root@localhost ~]# vim !:2
vim anaconda-ks.cfg.bak

注意,参数符号不仅是可以 !$、!^、!:n 这样用,这些关于参数的符号都是可以和!表达式任意组合使用的,比如

cd !762:2 (表示762号历史命令的第2个参数)

ls !-3^  (表示倒数第3个命令的第一个参数)

  • HISTCONTROL=ignoredups 去除重复命令

这样设置后,多次的相同的命令连续执行就会只记录一次。

  • HISTSIZE=0 不记录命令

如果不想记录命令,可以设置HISTSIZE=0。如果想恢复或调整最大记录条数,可以在设置HISTSIZE为一个大于零的值(默认为500或者1000)


Linux帮助用法

  • whatis

 whatis命令是用于查询一个命令执行什么功能,并显示手册部分的页眉行。

[root@localhost ~]# whatis pwd
pwd (1)              - print name of current/working directory
  • command--help

 用于显示shell内部命令的帮助信。

[root@localhost ~]# type cd
cd is a shell builtin
[root@localhost ~]# cd --help
-bash: cd: --: invalid option
cd: usage: cd [-L|[-P [-e]]] [dir]
  • man
    man命令的实用性非常高,基本上所有的类Unix系统都支持,提供man命令帮助的文件存在/usr/share/man目录下。
[root@localhost ~]# man ls
LS(1)                                                     User Commands                                                    LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX
       nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters

       --block-size=SIZE
              scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units  of  1,048,576  bytes;  see
              SIZE format below

man命令的操作按键:

按键 作用
空格键 向下翻一页
Page Down 向下翻一页
Page Up 向上翻一页
y,k 向文件首部翻一行
e,j 向文件尾部翻一行
b 向文件首部翻屏
u 向文件首部翻半屏
d 向文件尾部翻半屏
HOME 直接前往首页
END 直接前往尾页
1G 回到文件首部
G 翻至文件尾部
跳转至第#行
/关键词 向文件尾部翻半屏
?关键词 从下至上搜索某个关键
n 定位到下一个搜索到的关键词
N 定位到上一个搜索到的关键词
q 推出帮助文档

man命令的帮助文档分类:

序号 含义
1 User Commands 一般用户命令
2 系统内核可调用的函数与工具
3 C函数库命令
4 /dev下的各种设备文件
5 配置文件或者是某些文件的格式
6 游戏
7 惯例与协议,例如文件系统、网络协议、ASCll code等说明
8 系统管理员可用的管理命令
9 kernel有关文件
  • info
    info页面比man page编写得要更好、更容易理解,也更友好,一个man page只有一页,而info页面几乎总是将它们的内容组织成多个区段(称为节点),每个区段也可能包含子区段(称为子节点)。
[root@localhost ~]# info date
File: coreutils.info,  Node: date invocation,  Next: arch invocation,  Up: System context

21.1 'date': Print or set system date and time
==============================================

Synopses:

     date [OPTION]... [+FORMAT]
     date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ]

   Invoking 'date' with no FORMAT argument is equivalent to invoking it
with a default format that depends on the 'LC_TIME' locale category.  In
the default C locale, this format is ''+%a %b %e %H:%M:%S %Z %Y'', so
the output looks like 'Thu Mar  3 13:47:51 PST 2005'.

   Normally, 'date' uses the time zone rules indicated by the 'TZ'
environment variable, or the system default rules if 'TZ' is not set.
*Note Specifying the Time Zone with 'TZ': (libc)TZ Variable.

   If given an argument that starts with a '+', 'date' prints the
current date and time (or the date and time specified by the '--date'
option, see below) in the format defined by that argument, which is
similar to that of the 'strftime' function.  Except for conversion
specifiers, which start with '%', characters in the format string are
printed unchanged.  The conversion specifiers are described below.

   An exit status of zero indicates success, and a nonzero value
indicates failure.

* Menu:

* Time conversion specifiers::     %[HIklMNpPrRsSTXzZ]
* Date conversion specifiers::     %[aAbBcCdDeFgGhjmuUVwWxyY]
* Literal conversion specifiers::  %[%nt]
* Padding and other flags::        Pad with zeros, spaces, etc.
* Setting the time::               Changing the system clock.
* Options for date::               Instead of the current time.
* Date input formats::             Specifying date strings.
* Examples of date::               Examples.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容