马哥教育网络班19期第一周课程练习

1、描述计算机的组成及其功能。

从大体上计算机是由cpu、内存、主板、I/O设备、存储设备组成
cpu的功能就好像人的大脑,控制身体的。严格意义上是用来解释计算机指令以及处理软件中的数据的。
内存的功能就好像人的大脑记忆区、来存放眼睛看到的世界。严格意义上是用于暂时存放cpu中的运算数据,以及与硬盘等外部存储器交换的数据
主板的功能就好像人的身体,来链接身体的部件,如大脑。严格意义上就是提供一系列结合点,供cpu,内存,IO设备,存储设备链接
I/O设备的功能就好像人的眼睛、嘴巴等等。输入输出的。严格意义上就是通过键盘,鼠标等设备向计算机设备输入,通过显示器输出。
存储设备的功能就好像外部的世界,存储着各种各样的数据。严格意义上就是存储数据的硬件,可以通输入设备改变数据,通过显示器显示。

2、按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别。

  Redhat
       Rhel
       Centos
       Fedora core
 Debian 
        Ubuntu
              mint
 Slackware
         suse
              opensuse
 archLinux
 gentoo 
 联系:不同的发行版之间都是采用对Linux内核进行的研发
 区别:不同的发型版之间都有不同的风格,程序包管理方式不同。维护方式也是不同的。
一类是商业公司维护的发行版本,一类是社区组织维护的发行版本,
 前者以著名的Redhat(RHEL)为代表,后者以Debian为代表

3、描述Linux的哲学思想,并按照自己的理解对其进行解释性描述。

  Linux的哲学思想
   1.一切都是文件
       Linux把几乎所有文件都改成文件形式,硬件也一样
   2.由众多目的单一的进程组成,每个进程实现一个功能。
     一个程序由一个或多个进程组成来完成复杂任务
   3.避免跟用户交互
        来实现自动化的功能
   4.使用纯文本文档来编写配置文件
        直接能用一款编辑器就能实现修改配置文件

4、说明Linux系统上命令的使用格式;
详细介绍ifconfig、echo、tty、startx、export、pwd、history、shutdown、poweroff、reboot、hwclock、date命令的使用,并配合相应的示例来阐述。**
(1)ifconfig命令使用格式:

   ifconfig interface [aftype] options | address ...

ifconfig命令是用来显示和配置网络接口的

    ifconfig - configure a network interface

ifconfig是用来配置内核的网络接口,必要是可以用他来设置接口,一般用在调试和系统优化。

     Ifconfig is used to configure the kernel-resident network interfaces.  It is used at boot time to set up interfaces as
   necessary.  After that, it is usually only needed when debugging or when system tuning is needed.

如果ifconfig命令没给arguments,会显示当前活动的接口状态,如果只给了一个接口的参数,
那它就只会显示那一个接口的状态,如果只给一个-a的参数。它就会显示所有接口的状态,即使没有的开启的接口也会显示。
它可以用来配置一个接口。

   If no arguments are given, ifconfig displays the status of the currently active interfaces.   If  a  single  interface
   argument  is  given, it displays the status of the given interface only; if a single -a argument is given, it displays
   the status of all interfaces, even those that are down.  Otherwise, it configures an interface.

实例
ifconfig eth0 ip=192.168.1.13 netmask 255.255.255.0
这样设置不是永久保存的。可以用sync命令
(2)echo命令使用格式

  echo [SHORT-OPTION]... [STRING]...

echo命令是用来显示一行的文本的

  echo - display a line of text 
         显示一行的文本
   Echo the STRING(s) to standard output.
    向标准输出的字符串
   -n     do not output the trailing newline
           输出不换行
   -e     enable interpretation of backslash escapes
           反斜线的合理解释
   -E     disable interpretation of backslash escapes (default)
              关闭反斜线的合理解释
    If -e is in effect, the following sequences are recognized:
      使用-e了,那就解释为以下字符
   \\     backslash
           \\为反斜线    
   \a     alert (BEL)
           \a为警告声
   \b     backspace
          \b为退格键
   \c     produce no further output
           最后不输出换行符       
   \f     form feed
            换页
   \n     new  line
          换行光标至行首
   \r     carriage return
         光标移至行首,但不换行
   \t     horizontal tab
           插入 tab表格跳位键
   \v     vertical tab
            纵向制表
   \0NNN  byte with octal value NNN (1 to 3 digits)
            插入八进制的ASCII字符
   \xHH   byte with hexadecimal value HH (1 to 2digits)
              插入十六进制的ASCII字符
   NOTE:  your shell may have its own version of echo, which usually supersedes the version described here.  Please refer
   to your shell’s documentation for details about the options it supports.
      你的shell可能已经用echo的版本。查看描述的版本信息会有更加完整的信息

实例:
echo $?
会显示上一个命令的成功还是失败0:表示成功 1-255表示失败
echo “hello there”会直接显示hello there
echo -e “23\b24\n\ao\tds\b”
2\24
o ds 为什么后面的s会还在呢,因为它\b后面根本没有字符,没执行

(3)tty

tty的使用格式

 tty [OPTION]...

tty – print the file name of the terminal connected to standard input

 显示连接到标准输入的终端

   -s, --silent, --quiet
          print nothing, only return an exit status
   使用静默模式,不输出任何信息
   --help display this help and exit
      帮助
   --version
          output version information and exit
           显示着个版本信息

实例:
直接使用tty

 [root@king-liu ~]# tty
  /dev/pts/0也就是模拟终端
/dev/tty也就是虚拟终端
 /dev/console也就是物理终端

(4)startx
startx的使用格式

 startx [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]

startx – initialize an X session
初始化X回话,也就打开图形化界面

   The  startx  script is a front end to xinit that provides a somewhat nicer user interface for running a single session
   of the X Window System.  It is often run with no arguments.
    startx脚本是xinit,运行X窗口系统的单个会话提供了一个良好的用户界面的前端。
   Arguments immediately following the startx command are used to start a client in the same  manner  as  xinit(1).  
    在争论之时,先使用startx命令打开一个 xinit。
   The special  argument ’--’ marks the end of client arguments and the beginning of server options.  
   -表示客户端的结束和着服务器的选择
    It may be convenient to specify server options with startx to change on a per-session basis the default color depth, 
   the  server’s  notion  of  the  number of dots-per-inch the display device presents, 
   or take advantage of a different server layout, as permitted by the Xorg(1) server and specified in the xorg.conf(5) file. 
    它可以方便的指定服务器选项使用startx来每个会话的基础上的默认颜色深度的变化,对每英寸点数显示装置呈现数量的服务器的概念,
   或利用不同的服务器布局,由xorg允许(1)在xorg服务器和指定的conf(5)文件。
   Some examples of specifying  server  arguments  follow;
    指定一些服务器的例子
   consult the manual page for your X server to determine which arguments are legal.

          startx -- -depth 16

          startx -- -dpi 100

          startx -- -layout Multihead


   To  determine  the client to run, startx first looks for a file called .xinitrc in the user’s home directory.  If that
   is not found, it uses the file xinitrc in the xinit library directory.
   确定客户端运行,听的第一个文件,在用户的家目录放。如果没有找到,它在xinit图书馆目录使用文件放。
   If command line client options are given, they override this behavior and revert to the xinit(1) behavior.  To  deter-
   mine  the server to run, startx first looks for a file called .xserverrc in the user’s home directory.  If that is not
   found, it uses the file xserverrc in the xinit library directory.  If command line  server  options  are  given,  they
   override  this behavior and revert to the xinit(1) behavior.  Users rarely need to provide a .xserverrc file.  See the
   xinit(1) manual page for more details on the arguments.
    如果客户端命令行选项给出,他们重写此行为,并恢复到xinit(1)行为。确定我的服务器来运行的,听的第一个文件,在用户的家目录xserverrc。
   如果没有找到,它在xinit图书馆目录使用的文件xserverrc。如果命令行服务器选项给出,他们重写此行为,并恢复到xinit(1)行为。
   用户很少需要提供xserverrc文件。看到xinit(1)在更细节的手册页。
   The system-wide xinitrc and xserverrc files are found in the /etc/X11/xinit directory.
     全系统和xserverrc文件放在/etc/X11目录/ xinit。
   The .xinitrc is typically a shell script which starts many clients according to  the  user’s  preference.   When  this
   shell  script  exits,  startx  kills  the  server and performs any other session shutdown needed.  Most of the clients
   started by .xinitrc should be run in the background.  The last client should run in the foreground; when it exits, the
   session will exit.  People often choose a session manager, window manager, or xterm as the ’’magic’’ client.
    .xinitrc通常是一个shell脚本,很多会话可以根据用户的偏好来设置。当这个shell脚本退出,StartX杀死服务器并执行任何其他会话关闭需要。
    大部分的会话开始,应该放在后台运行。
    最后一个客户端应该在前台运行;当它退出时,会话将退出。人们通常选择会话管理器,窗口管理器,或xterm作为“好极了”客户。

(5)export

export命令使用格式: 
export [-fnp][变量名称]=[变量设置值]

-f  代表[变量名称]中为函数名称。
-n  删除指定的变量。变量实际上并未删除,只是不会输出到后续指令的执行环境中。
-p  列出所有的shell赋予程序的环境变量。

export-设置和显示环境变量
在shell中执行程序时,shell会提供一组环境变量。 export可新增,修改或删除环境变量,供后续执行的程序使用。export的效力仅及于该此登陆操作。
 一个变量创建时,它不会自动地为在它之后创建的shell进程所知。而命令export可以向后面的shell传递变量的值。
 当一个shell脚本调用并执 行时,它不会自动得到原为脚本(调用者)里定义的变量的访问权,除非这些变量已经被显式地设置为可用。
  export命令可以用于传递一个或多个变量的值到 任何后继脚本。     ----《UNIX教程》

实例
export直接显示所有的环境变量
export tmp="/tmp" 定义变量tmp为/tmp

(6)pwd
pwd使用格式

 pwd [OPTION]...

pwd – print name of current/working directory 打印名字或工作目录

 Print the full filename of the current working directory.
  打印当前工作目录的完整名
   -L, --logical
          use PWD from environment, even if it contains symlinks
    用PWD环境,即使它包含符号链接
   -P, --physical
          avoid all symlinks
     避免所有符号链接
   --help display this help and exit
     显示帮助
   --version
          output version information and exit
     输出版本信息和退出
   NOTE:  your  shell may have its own version of pwd, which usually supersedes the version described here.  Please refer
   to your shell’s documentation for details about the options it supports.
  pwd 显示当前工作目录

(7)history:

 history -历史命令 
 history使用格式
 history [option]  ....

描述:

 history
        环境变量:
            HISTSIZE:命令历史记录的条数;
            HISTFILE:~/.bash_history;
            HISTFILESIZE:命令历史文件记录历史的条数;

        history -d OFFSET   删除指定的历史命令
        -c 清空历史命令
        history #: 显示历史中最近的#条命令;
        -a: 手动追加当前会话缓冲区的命令历史至历史文件中;

    调用历史中的命令:
        !#: 重复执行第#条指令;
        !!:执行上一条命令
        !string,执行命令历史中包含此字符的第一条命令

    调用上一条命令的最后一个参数:
        !$: 
        ESC, .
        Alt+.

    控制命令历史的记录方式:
        环境变量:HISTCONTROL
            ignoredups:忽略重复的命令;连续且相同方为“重复”;
            ignorespace:忽略所有以空白开头的命令;
            ignoreboth:ignoredups, ignorespace;

        修改环境变量值的方式:export 变量名="值"
            变量赋值:把赋值符号后面的数据存储于变量名指向内存空间;

实例:
直接用history可以显示命令历史的所有内容
使用history可以说清空命令历史的所有内容
使用history -d 加数字 可以清除哪一个的命令
(8)shutdown

 shutdown命令的使用格式
 shutdown [OPTION]...  TIME [MESSAGE]

描述:

shutdown - bring the system down
 关机命令
 OPTIONS
   -r     Requests that the system be rebooted after it has been brought down.
      重新启动
   -h     Requests that the system be either halted or powered off after it has been brought down, with the choice as  to
          which left up to the system.
      对系统进行关机
   -H     Requests that the system be halted after it has been brought down.

   -P     Requests that the system be powered off after it has been brought down.

   -c     Cancels a running shutdown.  TIME is not specified with this option, the first argument is MESSAGE.
     取消之前的关机命令
   -k     Only send out the warning messages and disable logins, do not actually bring the system down.

     只发出警告信息不关机
    TIME: 
            now: 立刻
            +m: 相对时间表示法,从命令提交开始多久之后;例如 +3;
            hh:mm: 绝对时间表示,指明具体时间;

实例
直接 shutdown -c 取消
直接 shutdown -k “the is no shutdown”

(9)poweroff
poweroff的使用格式
reboot [OPTION]…
halt [OPTION]…
poweroff [OPTION]…
poweroff – reboot or stop the system
重新启动或关机
描述:

  These programs allow a system administrator to reboot, halt or poweroff the system.
这些程序允许系统管理员重新启动,停机或关机系统。
   When  called  with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself and directly
   reboots the system.  Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments.
 当使用武力或在运行级别0或6,这个工具调用reboot(2)系统调用本身直接重启系统。否则,这只简单地调用了适当的参数的shutdown(8)工具。
   Before invoking reboot(2), a shutdown time record is first written to /var/log/wtmp
    在调用前reboot(2),会把之前的关机时间写入/var/log/wtmp
   -f, --force
          Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.

   -p, --poweroff
          Instructs the halt command to instead behave as poweroff.

   -w, --wtmp-only
          Does not call shutdown(8) or the reboot(2)  system  call  and  instead  only  writes  the  shutdown  record  to
          /var/log/wtmp

(10)reboot
重启命令

(11)hwclock
使用格式:

  hwclock [functions] [options]

描述:

   hwclock  is  a  tool  for accessing the Hardware Clock.  You can display the current time, set the Hardware Clock to a
   hwclock是一款访问硬件时钟的工具,这是显示现在的时间,将硬件时钟设置为指定的时间
   specified time, set the Hardware Clock to the System Time, and set the System Time from the Hardware Clock.
  将硬件时钟设置为系统时间,并从硬件时钟设置系统时间。
   You can also run hwclock periodically to insert or remove time from the Hardware Clock to  compensate  for  systematic
   drift (where the clock consistently gains or loses time at a certain rate if left to run).
  你也可以运行hwclock定期插入或从硬件时钟补偿系统漂移消除时间(在时钟始终获得或失去的时间在一定的速度如果不运行)。
     -s, --hctosys  硬件时钟转软件时钟
          Set the System Time from the Hardware Clock.

          Also set the kernel’s timezone value to the local timezone as indicated by the TZ environment  variable  and/or
          /usr/share/zoneinfo,  as tzset(3) would interpret them.  The obsolete tz_dsttime field of the kernel’s timezone
          value is set to DST_NONE. (For details on what this field used to mean, see settimeofday(2).)

          This is a good option to use in one of the system startup scripts.

   -w, --systohc 软件时钟转硬件时钟
          Set the Hardware Clock to the current System Time.

(12)date
使用格式:

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

描述:

   Display the current time in the given FORMAT, or set the system date.
    显示现在的时间
   -d, --date=STRING
          display time described by STRING, not ‘now’
 显示字符串描述的时间,而不是现在
   -f, --file=DATEFILE
          like --date once for each line of DATEFILE

   -r, --reference=FILE
          display the last modification time of FILE
         显示最后修改时间
   -R, --rfc-2822
          output date and time in RFC 2822 format.  Example: Mon, 07 Aug 2006 12:34:56 -0600
            输出日期和时间为rfc2822格式,
   --rfc-3339=TIMESPEC
          output  date  and  time in RFC 3339 format.  TIMESPEC=‘date’, ‘seconds’, or ‘ns’ for date and time to the indi-
          cated precision.  Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00
            输出格式日期和时间为RFC 3339格式,
   -s, --set=STRING
          set time described by STRING
    用字符串描述时间
   -u, --utc, --universal
          print or set Coordinated Universal Time
            打印或设置协调通用时
   --help display this help and exit

       date [MMDDhhmm[[CC]YY][.ss]]:设置
           MM: 月分
           DD:几号
           hh: 小时
           mm: 分钟
           YY: 两位年份
           CCYY: 四位年份
           .ss: 秒钟

实例:

  date +%F 显示日期
  可以用man来看参数

5、如何在Linux系统上获取命令的帮助信息,请详细列出,并描述man文档的章节是如何划分的。
区别内部命令和外部的命令可以使用type

内部命令:
    # help COMMAND
外部命令:
    (1) # COMMAND --help
        # COMMAND -h
    (2) 使用手册(manual)
        # man COMMAND
    (3) 信息页
        # info COMMAND
    (4) 程序自身的帮助文档
        README
        INSTALL
        ChangeLog
    (5) 程序官方文档
        官方站点:Documentation
    (6) 发行版的官方文档
    (7) Google
  man文档的章节
 1  用户命令,  可由任何人启动的。
 2  系统调用,  即由内核提供的函数。
 3  例程,   即库函数。
 4  设备,   即/dev目录下的特殊文件。
 5  文件格式描述,  例如/etc/passwd。
 6  游戏,   不用解释啦!
 7  杂项,   例如宏命令包、惯例等。
 8  系统管理员工具, 只能由root启动。
 9  其他(Linux特定的), 用来存放内核例行程序的文档。
 n  新文档,  可能要移到更适合的领域。
 o  老文档,  可能会在一段期限内保留。
 l  本地文档,  与本特定系统有关的。

6、请罗列Linux发行版的基础目录名称命名法则及功用规定

    /boot:引导文件存放目录,内核文件(vmlinuz)、引导加载器(bootloader, grub)都存放于此目录;
    /bin:供所有用户使用的基本命令;不能关联至独立分区,OS启动即会用到的程序;
    /sbin:管理类的基本命令;不能关联至独立分区,OS启动即会用到的程序;
    /lib:基本共享库文件,以及内核模块文件(/lib/modules);
    /lib64:专用于x86_64系统上的辅助共享库文件存放位置;
    /etc:配置文件目录(纯文本文件);
    /home/USERNAME:普通用户家目录;
    /root:管理员的家目录;
    /media:便携式移动设备挂载点;
        cdrom
        usb
    /mnt:临时文件系统挂载点;
    /dev:设备文件及特殊文件存储位置;
        b: block device,随机访问
        c: character device,线性访问
    /opt:第三方应用程序的安装位置;
    /srv:系统上运行的服务用到的数据;
    /tmp:临时文件存储位置;
    /usr: universal shared, read-only data;
        bin: 保证系统拥有完整功能而提供的应用程序;
        sbin:
        lib:
        lib64:
        include: C程序的头文件(header files);
        share:结构化独立的数据,例如doc, man等;
        local:第三方应用程序的安装位置;
            bin, sbin, lib, lib64, etc, share

    /var: variable data files
        cache: 应用程序缓存数据目录;
        lib: 应用程序状态信息数据;
        local:专用于为/usr/local下的应用程序存储可变数据;
        lock: 锁文件
        log: 日志目录及文件;
        opt: 专用于为/opt下的应用程序存储可变数据;
        run: 运行中的进程相关的数据;通常用于存储进程的pid文件;
        spool: 应用程序数据池;
        tmp: 保存系统两次重启之间产生的临时数据;

    /proc: 用于输出内核与进程信息相关的虚拟文件系统;
    /sys:用于输出当前系统上硬件设备相关信息的虚拟文件系统;
    /selinux: security enhanced Linux,selinux相关的安全策略等信息的存储位置;

原创文章,作者:N19_king,如若转载,请注明出处:http://www.178linux.com/18608

(0)
上一篇 2016-06-18 11:38
下一篇 2016-06-18 22:32

相关推荐

  • 通过Nginx来安装一个discuz,软件并不是编译安装的

    这次由于时间有限,所以我就没有用编译安装来启动LMP,只有Nginx 是编译安装的 因为是在centos7上面安装的Nginx所以我们这里由于能力有限,暂时不能将其加入开机启动,日后我会进行改进,将其加入开机启动。这里我们给出Nginxd的编译选项及环境   yum groupinstall "Development&…

    Linux干货 2016-10-25
  • if、case 语法

    1. 条件选择 if 语句         选择执行:              单分支      &nbs…

    Linux干货 2016-08-22
  • linux软链接与硬链接的区别

    硬链接:相于当给文件增加了一个新名 在添加链接时会增加链接数,其inode结点数不会增加 支持绝对路径与相对路径 硬链接不能对目录来创建 不能跨分区来创建链接 硬链接链接到文件被删除时,依旧可以通过链接文件来访问被删文件的数据 软链接:可以支持对目录来创建链接 (注,当你用rm -rf 删除目录的时候,目录不会删除,但目录中的内容会被删除,并且会删除源文件)…

    Linux干货 2013-07-15
  • 14 用户组和权限管理4

    14 用户组和权限管理4 一、杂项知识整理 1、groups 查看用户所属组列表 [user1@localhost ~]$ groups user3 user1 2、文件属性:-rw-r–r–. 1 root root 0 8月   3 07:56 cgroup.clone_children &…

    Linux干货 2016-08-04
  • 从Linux小白到大牛——与狼共舞的日子7

    马哥教育网络班21期+第7周课程练习 1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; (2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; [root@localhost ~]#&nbsp…

    Linux干货 2016-11-14
  • Linux中的账号管理之命令的使用(中)

    linux中账号管理的命令非常多,我这里主要介绍最常见的几个命令,这些命令分别是针对用户和组的管理 主要介绍对用户管理的命令: 一、用户创建:useradd useradd命令用于Linux中创建的新的系统用户。useradd可用来建立用户帐号。帐号建好之后,再用passwd设定帐号的密码.而可用userdel删除帐号。使用useradd指令所建立的帐号,实…

    Linux干货 2016-08-07

评论列表(1条)

  • 马哥教育
    马哥教育 2016-06-21 22:46

    写的很用心,非常棒,如果可以在讲解一些命令的时候添加一些案例会更加的好,加油!