第五章 实用指令

本文探讨了Linux系统的运行级别概念,介绍了如何通过init命令切换到单用户模式来找回丢失的root密码。此外,还对比了help、man和info命令在获取指令帮助上的不同,并列举了ls命令的详细用法。
摘要由CSDN通过智能技术生成

运行级别

  • 0:关机
  • 1:单用户(找回丢失密码)
  • 2:多用户无网络服务
  • 3:多用户有网络服务(最多使用)
  • 4:系统未使用保留给用户
  • 5:图形界面(常用)
  • 6:重启

etc/inittab可以指定系统运行级别

init [012356] :切换到指定运行级别

比如:init 3

如何找回丢失的root密码

思路:进入单用户模式,修改root密码,因为单用户模式不需要密码就可以登陆

帮助指令

对某个指令不熟悉,使用帮助指令,帮助了解

  • man [命令或者配置文件]
man ls
LS(1)                                                                                                     General Commands Manual                                                                                                    LS(1)

NAME
       ls, dir, vdir - 列目录内容

提要
       ls [选项] [文件名...]

       POSIX 标准选项: [-CFRacdilqrtu1]

GNU 选项 (短格式):
       [-1abcdfgiklmnopqrstuxABCDFGLNQRSUX]  [-w  cols]  [-T  cols] [-I pattern] [--full-time] [--format={long,verbose,commas,across,vertical,single-column}] [--sort={none,time,size,extension}] [--time={atime,access,use,ctime,status}]
       [--color[={none,auto,always}]] [--help] [--version] [--]

描述( DESCRIPTION )
       程序ls先列出非目录的文件项,然后是每一个目录中的“可显示”文件。如果   没有选项之外的参数【译注:即文件名部分为空】出现,缺省为   "."   (当前目录)。   选项“    -d    ”使得目录与非目录项同样对待。除非“    -a    ”    选项出现,文
       件名以“.”开始的文件不属“可显示”文件。

       以当前目录为准,每一组文件(包括非目录文件项,以及每一内含文件的目录)分 别按文件名比较顺序排序。如果“ -l ”选项存在,每组文件前显示一摘要行: 给出该组文件长度之和(以 512 字节为单位)。

       输出是到标准输出( stdout )。除非以“ -C ”选项要求按多列输出,输出 将是一行一个。然而,输出到终端时,单列输出或多列输出是不确定的。可以分别 用选项“ -1 ” 或“ -C ”来强制按单列或多列输出。

  • help命令
    [root@localhost ~]# help cd
    cd: cd [-L|[-P [-e]]] [dir]
        Change the shell working directory.
        
        Change the current directory to DIR.  The default DIR is the value of the
        HOME shell variable.
        
        The variable CDPATH defines the search path for the directory containing
        DIR.  Alternative directory names in CDPATH are separated by a colon (:).
        A null directory name is the same as the current directory.  If DIR begins
        with a slash (/), then CDPATH is not used.
        
        If the directory is not found, and the shell option `cdable_vars' is set,
        the word is assumed to be  a variable name.  If that variable has a value,
        its value is used for DIR.
        
        Options:
            -L    force symbolic links to be followed
            -P    use the physical directory structure without following symbolic
            links
            -e    if the -P option is supplied, and the current working directory
            cannot be determined successfully, exit with a non-zero status
        
        The default is to follow symbolic links, as if `-L' were specified.
        
        Exit Status:
        Returns 0 if the directory is changed, and if $PWD is set successfully when
        -P is used; non-zero otherwise.
    
  • info命令
    [root@localhost ~]# info ls
    
    File: coreutils.info,  Node: ls invocation,  Next: dir invocation,  Up: Directory listing
    
    10.1 'ls': List directory contents
    ==================================
    
    The 'ls' program lists information about files (of any type, including
    directories).  Options and file arguments can be intermixed arbitrarily,
    
    

区别:

  1. help命令用于显示shell内部的帮助信息。help命令只能显示shell内部的命令帮助信息。而对于外部命令的帮助信息只能使用man或者info命令查看。
  2. man命令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。man是在程序安装的时候安装的帮助文档,可以在系统的目录下找到,如果软件有配套的页面,就可以使用man来查找。比如通过指令:ls /user/share/man我们可以看到很多man帮助文档的存储,我们从中看到有很多歌man#文件,linux的一些man指令文档就存在于这些文件内。
  3. 一个程序的man帮助文档可能存在多个man中,比如我们用指令:whatis man,查看到man的多个信息。而wahtis ifconfig说明ifconfig指令的帮助文档存在于man8中。
  4. 我们用man ifconfig查看ifconfig的帮助文档,我们看到ifconfig左上角在man8中找到的相应帮助信息。而指令man man发现man在man1中就找到了,说明man手册是按顺序查找的。
  5. info指令是man 指令的详细内容。但man 使用起来要方便的多。一个man 只有一页,而info总是将它们的内容组织成多个区段(节点),每个区段也可能包含子区段(子节点)。info工具可显示更完整的最新的GNU工具信息。通常man中若包含的信息概要在info中也有时,会有提示:“请参考info页更详细内容”。

一般看信息都用查看man文档,而help只是一个简单的描述,方便,但man文档中都包含了。help 是内部命令的帮助,比如cd,man 是外部命令的帮助,比如ls。

history指令

查询系统上执行过的指令

history:显示所有执行过的指令

history 10:显示最近执行的10条指令

!指令编号:执行该指令编号所代表的指令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值