@IT·互联网

我的一小步

2018-08-18  本文已影响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) 和 外部命令.

命令运行的流程图


image.png

命令的语法通用格式:
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

功能: 显示终端名。

[root@localhost ~]# tty
/dev/pts/1
[root@localhost ~]# 

startx

[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

命令格式: 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

[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

[root@localhost ~]# reboot        #重新启动系统

hwclock

-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

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系统上如何获得命令的帮助?

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目录结构的顶层,一般根目录下面只存放目录,不存放文件。

/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目录相似,都是保存在内存当中的,主要是保存于内核相关信息的。

上一篇 下一篇

猜你喜欢

热点阅读