1     前言

本文档介绍了date , clock , hwclork , cal,  ls ,cd , pwd, tty,  whereis ,  which ,stat,  echo , shutdown , halt , reboot , poweroff, who ,w ,whomai命令的详细信息,并提供相应命令的使用案例。

学习这些基础命令是一个Linux爱好者需要具备的首要条件,让小编带领你们进入Linux的世界看看它的一颦一笑。

读者对象:                                                

        本文档(本指南)主要适用于以下人员:

                                                           Linux爱好者

2     概述

2.1   查询命令简介(man commandhelp command

所有的命令大概分两种内部命令及外部命令,内部命令使用help命令查询而外部命令使用maninfo`--help查询为了大家能够快速了解并使用查询命令小编简要概述一下。

什么是外部命令和内部命令?

内部命令:由shell 程序自带的命令

外部命令:每一个命令又都有一个与之对应的且名字同命令的可执行文件:

使用type命令来判定给定的命令是内部命令。还是外部命令。

从上图我们可以看出pwd命令是一个shell自带的命令那么我们叫它内建命令相反ls命令就是一个外部命令。

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify

那么help man有事如何使用的呢?

使用命令man ls 可以看到ls命令的详细信息。

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_02

 

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_03

而使用help ls则无法显示ls命令的信息

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_04

 

使用help pwd则能够查到pwd的命令信息。

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_05

好大家应该命名如何使用查询命令了,那么现在跟着小编开始吧!

2.2   环境简介

项目

配置

宿主

硬件型号

Tinkpad T440P

CPU

I5-4210

内存

4G

操作系统

Windows 8.1

虚拟系统

Vmware workstation 11

虚拟机

CPU

1Core

内存

1G

操作系统

Centos 6.7

 

3     Centos系统命令详解

命令

属性

详解

date

Name

(定义)

date - print or set the system date and time

date:显示或设置系统时间和日期的命

Synopsis

(大纲)

date [OPTION]... [+FORMAT]

查看系统时间命令

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

设置时间命令

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_06

Description(描述)

常用Format讲解:

%A:查看星期

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_07

%F: 查看日期

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_08

%D:查看日期

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_09

%T:查看时间

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_10

%Y:查看年份

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_11

hwclock

Name

(定义)

hwclock - query and set the hardware clock (RTC)

hwclock: 查询和设置硬件时钟

注:Linux系统上使用两套时间

1:系统时间:linux系统时间

2:硬件时间:硬件时间如:biso时间

 

Synopsis

(大纲)

hwclock [functions] [options]

 

Description(描述)

常用Functions:

-s   Set the System Time from the Hardware Clock.

设置系统时间为硬件时间

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_12

-w   Set the Hardware Clock to the current System Time

设置硬件时间为当前系统时间

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_13

-r | --show         read hardware clock and print result

  读取硬件时间并输出结果

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_14

cal

Name

(定义)

cal - displays a calendar

显示日历

Synopsis

(大纲)

cal [-smjy13] [[[day] month] year]

Description(描述)

-smjy13

显示当前月份日历

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_15

显示2015年日历

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_16

显示最近三个月的日历

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_17

 

显示指定月份日历(如:7月份)

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_18

 

ls

Name

(定义)

ls - list directory contents

显示目录内容

 

Synopsis

(大纲)

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

如:opention=[-a]   file=[/etc]

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_19

 

Description(描述)

-a显示隐藏文件

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_20

-l 每行一个文件列表

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_21

-t 根据修改时间排序

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_22

-c 配合-lt:根据ctime 排序并显示ctime(文件状态最后更改的时间)

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_23

cd

 

切换路径

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_24

pwd

Name

(定义)

pwd - print name of current/working directory

输出当前或工作中的目录名称

Synopsis

(大纲)

pwd [OPTION]..

Description(描述)

查看当前目录

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_25

tty

Name

(定义)

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

打印连接到标准输入的终端的文件名

Synopsis

(大纲)

tty [OPTION]...

Description(描述)

tty
--> /dev/pts/1
## -s, --silent, --quiet 什么也不返还,值返回一个退出状态
$ tty -s

Whereis

Name

(定义)

whereis - locate the binary, source, and manual page files for a command

whereis :定位命令的二进制,源,手册文件的位置。

Synopsis

(大纲)

whereis [-bmsu] [-BMS directory...  -f] filename...
学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_26

Description(描述)

 

-m 仅仅搜索手册部分

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_27

 

Which

Name

(定义)

which - shows the full path of (shell) commands

显示shell命令文件位置

 

 

Synopsis

(大纲)

which [options] [--] programname [...]

Description(描述)

找出pwd命令路径

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_28

找出tty命令路径

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_29

Stat

Name

(定义)

stat - display file or file system status

显示文件或文件系统状态

Synopsis

(大纲)

stat [OPTION]... FILE...

Description(描述)

显示ifcfg-eth0文件

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_30

Size :文件大小

Access:最后访问时间

Modify:最后修改时间

Change:状态更改时间(由系统维护,无法随意修改)

echo

Name

(定义)

echo - display a line of text

echo命令用来打印信息,是一个最常用的命令。在命令行中常用来打印环境变量的值,已确定当前环境中是否设置了指定的环境变量。在shell脚本中,常用来打印信息和帮助调试程序

Synopsis

(大纲)

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

       echo LONG-OPTION

Description(描述)

输出wo ai  linux

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_31

-n 输出信息之后不换行。

-e对字符串转义。

 

Shutdwon

Name

(定义)

shutdown  - bring the system down

关闭系统

Synopsis

(大纲)

shutdown [OPTION]...  TIME [MESSAGE]

Description(描述)

OPTIONS

-r  关闭系统并重新启动

 

-h  关机系统

 

-c  取消关机

 

+m m分钟之后执行相应操作

1615分关机

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_32

now = 0 立刻执行相应操作

立刻关机

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_33

poweroff

Name

(定义)

Pweroff reboot, halt命令 - reboot or stop the system

重启或停止系统

Synopsis

(大纲)

reboot [OPTION]...

halt [OPTION]...

poweroff [OPTION]..

Description(描述)

-f 强制重启

 

halt

Name

(定义)

相当于poweroff

Synopsis

(大纲)

参见poweroff

Description(描述)

参见poweroff

reboot

Name

(定义)

停止系统相当于shutdown -h

Synopsis

(大纲)

参见poweroff

Description(描述)

参见poweroff

who

Name

(定义)

who - show who is logged on

显示登录至当前系统的所有用户及登录的终端

Synopsis

(大纲)

who [OPTION]... [ FILE | ARG1 ARG2 ]

Description(描述)

-a相当于-b -d --login -p -r -t -T –u

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_34

-b 最后重启的时间

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_微软雅黑_35

-d 输出死亡程序

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_36

--login 输出系统登录时间

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_37

-r 输出当前运行级别

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_38

-T 添加用户的消息状态(+号或-号)

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_39

-u 列出用户登录

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_40

w

Name

(定义)

w - Show who is logged on and what they are doing

显示谁登录和他们在做什么。

Synopsis

(大纲)

w - [husfiV] [user]

Description(描述)

-h 不输入标题

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_normal_41

-I 显示IP地址代替主机名

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_style_42

whoami

Name

(定义)

Whoami print effective userid

显示当前有效用户ID

Synopsis

(大纲)

whoami [OPTION]...

Description(描述)

学习date , clock , hwclork , cal, ls ,cd , pwd, tty, whereis , which ,stat, e_justify_43