我的一小步

作者: 奇怪小栗子 | 来源:发表于2018-08-18 10:53 被阅读1次
此处输入图片的描述

什么是计算机

计算机:一种能够按照程序运行,自动、高速处理海量数据的现代化智能电子设备。

  1. 计算机系统
    计算机系统:由硬件(Hardware)系统和软件(Software)系统俩大部分组成
image.png

debian,三大发行版中唯一以社区形式运作,不以商业公司形式运作。是一个致力于创建自由操作系统的合作组织。而且debian开发者所创建的操作系统中绝大部分基础工具来自于GNU工程。
Ubuntu(乌版图)是一个以桌面应用为主的linux操作系统。Ubuntu的目标在于为一般用户提供一个最新的、同时又相当稳定的主要由自由软件构建而成的操作系统

siackware
suse linux,针对个人用户

Red Hat
Red Hat ,是redhat自己的发行的企业版,是redhat的一个重要节点
Fedore是一款基于linux的操作系统,也是一组维持计算机正常运行的软件集合。由红帽公司赞助。
Centos是一个基于redhat linux 提供的可自由使用源代码的企业级linux发行版本。目前Centos已被收购,成为redhat旗下的一个组织。

红旗linux
红旗linux的发行版,包括桌面版、工作站版、数据中心服务器版、HA集群版和红旗嵌入式linux等产品,是中国较大、较成熟的linux发行版之一。

Linux发行版众多,但是实际上只有一个内核,发行版只是给这个内核加上一些应用程序而组成的系统。而这些应用大部分都是来源于GNU社区,代码基本都一样,因此,各发行版之间差别不大。

Linux的哲学实现

  • 一切皆文件

意思:一切皆文件普通的文件,目录、字符设备、块设备、Linux 中都是以文件被对待;可以统一进行读取,写入,修改,创建,删除五个步骤,使管理统一标准化,便于管理

  • 由众多单一目的的小程序,一个程序只实现一个功能,多个程序组合完成复杂任务

意思:单一小程序,组合成的程序功能大于个各程序之总和,使程序达到协同效应.

  • 文本文件保存配置信息

意思:用的文本编辑器即能完成系统配置工作

  • 尽量避免与用户交互
  • 为了稳定的自动完成众多功能。要尽量避免与用户交互。

Linux系统上命令的使用格式

inux命令分为两大类:内置命令(uiltin) 和 外部命令.

  • 内置命令:由SHELL程序自带的命令。

  • 外置命令 :有对应独立的可执行的程序文件,文件名即命令名

  • 发起一个命令,请求内核将某个二进制程序运行为一个进程。
    系统是有顺序的.它会先在shell自动的程序中,是否有该命令.有则执行,无则在
    $PATH中寻找.有则执行,无则输出无该命令.

命令运行的流程图


image.png
  • 普通用户命令放在: /bin , /usr/bin , /usr/local/bin 目录下。
  • 管理命令一般放在: /sbin,/usr/sbn, /usr/local/sbin 目录下

命令的语法通用格式:
COMMAND(命令) OPTION(选项) ARGUMENT (参数)

一些基础命令

ifconfig

  • 功能: 显示或者配置网卡。

命令格式:

ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype] options | address …

eth0      Link encap:Ethernet  HWaddr 00:0C:29:DB:51:CD  
          inet addr:192.168.221.131  Bcast:192.168.221.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fedb:51cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:437 errors:0 dropped:0 overruns:0 frame:0
          TX packets:358 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:53116 (51.8 KiB)  TX bytes:55190 (53.8 KiB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

echo

  • 功能: 回显,用于显示一行文件。

命令格式: echo [SHORT-OPTION]… [STRING]…

1[root@localhost ~]# echo "我爱你"
2我爱你
3[root@localhost ~]# echo "$PS1"  
4[\u@\h \W]\$ 

tty

功能: 显示终端名。

  • 命令格式: tty [OPTION]…
[root@localhost ~]# tty
/dev/pts/1
[root@localhost ~]# 

startx

  • 功能: 用来启动X Window
    命令格式:startx [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]
[root@localhost ~]# startx
xauth:  file /root/.serverauth.2956 does not exist

(EE) 
Fatal server error:
(EE) Server is already active for display 0
        If this server is no longer running, remove /tmp/.X0-lock
        and start again.
(EE) 
(EE) 
Please consult the CentOS support 
         at http://wiki.centos.org/Documentation
 for help. 
(EE)

export

  • 功能: 用于将shell变量输出为环境变量,或者将shell函数输出为环境变量。

命令格式: export [选项][参数]

[root@localhost ~]# export 
declare -x CVS_RSH="ssh"
declare -x G_BROKEN_FILENAMES="1"
declare -x HISTCONTROL="ignoredups"
declare -x HISTSIZE="1000"
declare -x HOME="/root"
declare -x HOSTNAME="localhost.localdomain"
declare -x KDEDIRS="/usr"
declare -x KDE_IS_PRELINKED="1"
declare -x LANG="en_US.UTF-8"
declare -x LESSOPEN="||/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="root"
declare -x PWD="/root"
declare -x QTDIR="/usr/lib64/qt-3.3"
declare -x QTINC="/usr/lib64/qt-3.3/include"
declare -x QTLIB="/usr/lib64/qt-3.3/lib"
declare -x SELINUX_LEVEL_REQUESTED=""
declare -x SELINUX_ROLE_REQUESTED=""
declare -x SELINUX_USE_CURRENT_RANGE=""
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass"
declare -x SSH_CLIENT="192.168.221.1 49992 22"
declare -x SSH_CONNECTION="192.168.221.1 49992 192.168.221.131 22"
declare -x SSH_TTY="/dev/pts/1"
declare -x TERM="linux"
declare -x USER="root"
declare -x help

pwd

  • 功能: 显示当前工作的目录
    命令格式:pwd [OPTION]…
[root@localhost wo]# pwd
/app/wo

history

功能: 显示历史命令记录文件。

命令格式:history [OPTIONS…]

[root@localhost wo]# history 
    1  shutdown -h now
    2  df
    3  df -m
    4  fd -h
    5  df -h
    6  df -g
    7  df -m
    8  df -h
    9  ls -i
   10  type touch
   11  man touch
   12  /home
   13  cd /home
   14  ls
   15  > wo

shutdown
功能: 关闭系统。

命令格式:shutdown [OPTION]... TIME [MESSAGE]

OPTION:
-c:当执行“shutdown -h 11:50”指令时,只要按+键就可以中断关机的指令;
-f:重新启动时不执行fsck;
-F:重新启动时执行fsck;
-h:将系统关机;
-k:只是送出信息给所有用户,但不会实际关机;
-n:不调用init程序进行关机,而由shutdown自己进行;
-r:shutdown之后重新启动;
-t<秒数>:送出警告信息和删除信息之间要延迟多少秒。

example:

[root@localhost ~]# shutdown -r now            #立即重新启动。
[root@localhost ~]# shutdown -h   now          #立即关机。

poweroff

  • 功能: 关闭系统。

命令格式: poweroff [OPTIONS…]

-选项:

–help # 显示命令帮助。

–halt # 关闭系统

[root@localhost ~]# poweroff – halt #关闭系统 
[root@localhost ~]# poweroff – reboot #重新启动系统

reboot

  • 功能: 重新启动系统 。
    命令格式:
    halt [OPTIONS…]
[root@localhost ~]# reboot        #重新启动系统

hwclock

  • 功能: 查询或设置硬件时钟。
    命令格式:hwclock [++function++] [++option++…]

-s,–hctosys: 以硬件时钟为准,把系统时钟调整为与硬件时间相同。

-w,–systohc: 以系统时钟为准,把硬件时钟调整不与系统时间相同。

date 显示的是系统时间
clock 显示的是硬件时间

选项:-s

example:
[root@localhost wo]# clock
Sat 11 Aug 2018 04:08:47 AM HKT  -0.721472 seconds
[root@localhost ~]# date
Sat Aug 11 04:08:16 HKT 2018
[root@localhost ~]# hwclock -s 
[root@localhost wo]# clock
Sat 11 Aug 2018 04:08:47 AM HKT  -0.721472 seconds
[root@localhost ~]# date
Sat Aug  11 04:08:47 HKT 2018

date

  • 功能: 显示或者设置系统日期和时间。
    命令格式:
    显示日期:date ++[OPTION]++… ++[+FORMAT]++
    设置日期: data [++MMDDhhmm++[[++cc++]++yy++[++.ss++]]]
example:

1.显示日期,时间

[root@localhost ~]# date
Sat Aug 11 04:13:25 HKT 2018
[root@localhost ~]# 

选项:%F    #显示系统完整日期: 年-月-日

[root@localhost ~]# date +%F
2018-08-11
[root@localhost ~]# 

选项: %T   #显示系统完整时间: 时-分-秒
[root@localhost ~]# date +%T
04:14:00
[root@localhost ~]# 


2.设置日期,时间

[root@localhost ~]# date
Sat Aug 11 04:13:25 HKT 2018
[root@localhost ~]# date +%F
2018-08-11
[root@localhost ~]# date +%T
04:14:00
[root@localhost wo]# date 0807033017
Mon Aug  7 03:30:00 HKT 2017
[root@localhost wo]# date +%F
2017-08-07
[root@localhost wo]# date +%T
03:30:23
[root@localhost ~]# 

linux系统上如何获得命令的帮助?

  • linux命令分为两大类
    • 内置命令(bultiin)

    • 外部命令

1. 内置命令获取帮助的方法

内置命令使用help
命令格式:help COMMAND

[root@localhost wo]# help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.
    
    Options:
      -L        print the value of $PWD if it names the current working
        directory
      -P        print the physical directory, without any symbolic links
    
    By default, `pwd' behaves as if `-L' were specified.
    
    Exit Status:
    Returns 0 unless an invalid option is given or the current directory
    cannot be read.

2.外部命令获取帮助的方法

1. 命令自带简要格式的使用帮助

 使用格式为: COMMAND  --help
例如:

[root@localhost ~]# ls --help
Usage: ls [OPTION]... [FILE]...
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
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information);
                               with -l: show ctime and sort by name;
                               otherwise: sort by ctime, newest first
...省略中...

b. 使用手册:manual

[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 alphabeti‐
       cally 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 .

...省略...

   Exit status:
       0      if OK,

       1      if minor problems (e.g., cannot access subdirectory),

       2      if serious trouble (e.g., cannot access command-line argument).

       GNU  coreutils  online  help:  <http://www.gnu.org/software/coreutils/> Report ls translation
       bugs to <http://translationproject.org/team/>

AUTHOR
       Written by Richard M. Stallman and David MacKenzie.

COPYRIGHT
       Copyright © 2013 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3  or  later
       <http://gnu.org/licenses/gpl.html>.
       This  is free software: you are free to change and redistribute it.  There is NO WARRANTY, to
       the extent permitted by law.

SEE ALSO 
       The full documentation for ls is maintained as a Texinfo manual.  If the info and ls programs
       are properly installed at your site, the command

2.manual 手册

章节 man手册类型 name

  1. 用户命令
  2. 系统调
  3. C库调用
  4. 设备文件及特殊文件
  5. 文件格式(配置文件)
  6. 游戏使用方法
  7. 杂项
  8. 管理工具及守护进程
  9. linux内核,

3. infor 命令

4. 很多应用程序会自带帮助文档

5. 主流发行版的官方文档

6.程序的官方文档

7.善用搜索引擎

linux常用目录结构

  • 目录即路径的映射。
  • linux目录结构是一棵倒置树


    image

/

/根目录:一般位于linux目录结构的顶层,一般根目录下面只存放目录,不存放文件。

/boot

/boot:启动相关的文件,系统相关

/etc

/etc目录:配置信息

/sbin

/sbin目录: 用来存放系统的可执行文件(管理员能使用的)

/bin

/bin用来存放常用的可执行文件,如:ls

/root

/root 目录 :系统管理员root的家目录

/home

/home目录:家目录,每个用户都会在这里建一个文件夹,用户登录后就在家目录

/usr

/usr目录:系统软件资源目录。注意usr不是user的缩写,而的“Unix Software Resource”的缩写,所以不是存放用户数据,而是存放系统软件资源的目录。系统中安装的软件大数保存在这个目录。

/dev

/dev目录:设备文件

/var

/var目录:动态数据保存位置

/mnt

/mnt目录:设备挂载目录

/tmp

/tmp目录:临时存放文件的目录

/lib

/lib目录:系统调用的函数库保存的位置。(32位操作系统)

/lib64

/lib目录:系统调用的函数库保存的位置。(64位操作系统)

/opt

/opt目录:第三方安装的软件保存位置。这个目录是放置和安装其他软件的位置。

/media

/media目录 :挂载目录,通常用来挂载软盘和光盘。

/proc

/proc目录 :虚拟文件系统。该目录中的数据并不保存到硬盘中,而是保存在内存当中,主要保存系统的内核,进程,以及外部设备状态。

/srv

/srv目录:服务数据目录,一些系统服务启动之后,可以在这个目录中保存所需要的数据。

/sys

/sys目录:虚拟文件系统,和/proc目录相似,都是保存在内存当中的,主要是保存于内核相关信息的。

相关文章

  • 我的一小步

    什么是计算机 计算机:一种能够按照程序运行,自动、高速处理海量数据的现代化智能电子设备。 计算机系统计算机系统:由...

  • 我的一小步

    「小诗一桩」 我的一小步 如果你问我 我的一小步有多大 我会甩开妈妈的手 勇敢地走给你看 我的一小步 既可以爬上家...

  • 我的一小步

    朋友给我几张游泳,汗蒸,温泉的票,爱人决定陪我去,我俩也只能泡泡温泉,然后汗蒸。 因为是假期,走过泳池时,池子里好...

  • 我的一小步

    周日的上午,是鼓励咨询最后一节课,四月老师说我们来做个毕业总结。大家可以聊一聊自己有什么收获或者感受,在接下来的生...

  • 我的一小步

    前天晚上,用一段2分钟的语音在笑来老师写作营小组群里做了动员,所谓动员不过是邀请大家做个自我介绍,相互认识。整个互...

  • 宝贝,你慢慢来,静候花开,我们不急。

    小步走,向前挪。丫丫,加油,每一步,都是进步。 丫丫:妈妈,我爱你。但是我只能一小步一小步往前走,你别嫌我慢。 我...

  • 小步慢

    小步其实不慢,领悟快,动作快,嘴巴快。但昨晚气到我了,因为小步慢。 昨晚小步在学习,我忙好了...

  • 2020.11.17 中原焦点团队,刘佳佳原创分享第1056天

    一小步 一小步真的非常重要,因为一小步更容易做到。现阶段对于我来说,能够做的一小步就是更多的引领孩子们,首...

  • 每日反思(202/1000)

    小步子原理: 一件事情的深处耕耘,在于坚持。当有懒散出现的时候,就告诉自己,向前迈一小步,只是一小步。 这一小步,...

  • 我的一小小步

    2017年2月9日,买了前往厦门的机票。任性地把所有其它事全部后推,因为在我看来,它是第一位。 决定了就义...

网友评论

    本文标题:我的一小步

    本文链接:https://www.haomeiwen.com/subject/ktmibftx.html