1.获取命令帮助

Linux中的命令按可分类shell内嵌命令外部命令,获取命令帮助信息前需要区分命令类型。

1.1 type - 查看命令类型
[root@VM_0_171_centos ~]# type echo
echo 是 shell 内嵌
[root@VM_0_171_centos ~]# type pwd
pwd 是 shell 内嵌
[root@VM_0_171_centos ~]# type cd
cd 是 shell 内嵌
[root@VM_0_171_centos ~]# type ls
ls 是 `ls --color=auto' 的别名
[root@VM_0_171_centos ~]# type man
man 是 /usr/bin/man
[root@VM_0_171_centos ~]# type whatis
whatis 是 /usr/bin/whatis
[root@VM_0_171_centos ~]# type whereis
whereis 是 /usr/bin/whereis
[root@VM_0_171_centos ~]#
1.2 help 内嵌命令 - 查看shell内嵌命令帮助
[root@VM_0_171_centos ~]# help echo
echo: echo [-neE] [参数 ...]
将参数写到标准输出。 在标准输出上显示 ARG 参数后跟一个换行。 选项:
-n 不要追加换行
-e 启用下列反斜杠转义的解释
-E 显式地抑制对于反斜杠转义的解释 `echo' 对下列反斜杠字符进行转义:
\a 警告(响铃)
\b 退格
\c 抑制更多的输出
\e 转义字符
\f 格式提供
\n 换行
\r 回车
\t 横向制表符
\v 纵向制表符
\\ 反斜杠
\0nnn 以 NNN (八进制)为 ASCII 码的字符。 NNN 可以是
0到3个八进制数字
\xHH 以 HH (十六进制)为值的八比特字符。HH可以是
一个或两个十六进制数字 退出状态:
返回成功除非有写错误发生。
[root@VM_0_171_centos ~]#
1.3 whatis - 显示手册页描述

通常用于辅助man命令,确定帮助手册章节

[root@VM_0_171_centos ~]# whatis whatis
whatis (1) - display manual page descriptions
[root@VM_0_171_centos ~]#
1.4 man [章节] 外部命令 - 查看外部命令帮助

man命令用来查看外部程序的帮助,有时需要配合whatis使用,因为man命令的帮助文档会按章节划分,各章节分别存放不同内容的帮助信息

帮助信息章节划分

1.用户命令

2.系统调用

3.C库调用

4.设备文件及特殊文件

5.文件格式(配置文件格式)

6.游戏使用帮助

7.杂项

8.管理工具及守护进程

[root@VM_0_171_centos ~]# man man
MAN(1)                        Manual pager utils                        MAN(1)

NAME
man - an interface to the on-line reference manuals SYNOPSIS
man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I]
[--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P
pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justifi‐
cation] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z]
[[section] page ...] ...
man -k [apropos options] regexp ...
man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
man -f [whatis options] page ...
man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L
locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t]
[-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ...
man -w|-W [-C file] [-d] [-D] page ...
man -c [-C file] [-d] [-D] page ...
man [-?V] DESCRIPTION
man is the system's manual pager. Each page argument given to man is
Manual page man(1) line 1 (press h for help or q to quit)

手册页常用操作

j | Enter : 向下翻一行

k : 向上翻一行

d : 向下翻半屏

u : 向上翻半屏

Space : 向下翻一屏

b : 向上翻一屏

G : 跳转至最后一行

nG : 跳转至第n行

/关键字 : 从上向下查找关键字(n:定位到下一个 ,N:定位到上一个)

?关键字 : 从下向上查找关键字

2.显示一行文本 echo

SYNOPSIS

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

echo LONG-OPTION

OPTIONS

-n do not output the trailing newline(不输出尾随行)

-e enable interpretation of backslash escapes(启用转义)

-E disable interpretation of backslash escapes (default) (禁用转义)

--help 显示帮助

--version 显示版本信息

EXAMPLES

[root@VM_0_171_centos ~]# echo "hello world"
hello world
[root@VM_0_171_centos ~]# echo $SHELL
/bin/bash
[root@VM_0_171_centos ~]# echo -e "hello\tworld\nlinux"
hello world
linux
[root@VM_0_171_centos ~]#

3.日期时间相关

3.1 date - print or set the system date and time 打印或设置系统日期和时间

SYNOPSIS

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

OPTIONS

-R, --rfc-2822    output date and time in RFC 2822 format.  Example: Mon, 07 Aug 2006 12:34:56 -0600
-s, --set=STRING set time described by STRING (用字符串设置时间,而非使用MMDDhhmm[[CC]YY][.ss])

EXAMPLES

date命令显示日期、时间

[root@VM_0_171_centos ~]# date
2017年 04月 03日 星期一 17:32:35 CST
[root@VM_0_171_centos ~]# date -R
Mon, 03 Apr 2017 17:32:41 +0800
[root@VM_0_171_centos ~]# date "+%Y-%m-%d %H:%M:%S.%N"
2017-04-03 17:33:21.620667704
[root@VM_0_171_centos ~]# date +%s
1491212010
[root@VM_0_171_centos ~]# date +%X
17时33分38秒
[root@VM_0_171_centos ~]# date +%x
2017年04月03日
[root@VM_0_171_centos ~]#

date命令设置日期、时间

[root@VM_0_171_centos ~]# date -s "2016-04-03 17:36:30"
2016年 04月 03日 星期日 17:36:30 CST
[root@VM_0_171_centos ~]# date 040317382017.20
2017年 04月 03日 星期一 17:38:20 CST
[root@VM_0_171_centos ~]#
3.2 hwclock,clock - query or set the hardware clock (RTC) 查询或设置硬件时钟

SYNOPSIS

hwclock [function] [option...]

FUNCTIONS

-s, --hctosys    以硬件为准,把系统调整为与硬件时间相同
-w, --systohc 以系统为准,把硬件时间调整为与系统时钟相同
3.3 cal - display a calendar 显示日历

SYNOPSIS

cal [options] [[[day] month] year]

OPTIONS

-1, --one    Display single month output.  (This is the default.)
-3, --three Display prev/current/next month output.
-s, --sunday Display Sunday as the first day of the week.
-m, --monday Display Monday as the first day of the week.
-j, --julian Display Julian dates (days one-based, numbered from January 1).
-y, --year Display a calendar for the current year.

EXAMPLES

[root@VM_0_171_centos ~]# cal
四月 2017
日 一 二 三 四 五 六
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
[root@VM_0_171_centos ~]# cal -m
四月 2017
一 二 三 四 五 六 日
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30 [root@VM_0_171_centos ~]# cal -3
三月 2017 四月 2017 五月 2017
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 1 1 2 3 4 5 6
5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13
12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20
19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
30
[root@VM_0_171_centos ~]# cal -y
2017 一月 二月 三月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 5 6 7 1 2 3 4 1 2 3 4
8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11
15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18
22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25
29 30 31 26 27 28 26 27 28 29 30 31 四月 五月 六月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 1 2 3 4 5 6 1 2 3
2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10
9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17
16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24
23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30
30
七月 八月 九月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 1 2 3 4 5 1 2
2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9
9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16
16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23
23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30
30 31
十月 十一月 十二月
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
1 2 3 4 5 6 7 1 2 3 4 1 2
8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9
15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16
22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23
29 30 31 26 27 28 29 30 24 25 26 27 28 29 30
31 [root@VM_0_171_centos ~]#

3.停止、关机、重启

远程操作一般而言禁止关机,只能重启,否则无法开机(本地机房或者云服务器除外,但对服务器操作而言,重启而非关机是一个好的习惯)

3.1 halt, poweroff, reboot - Halt, power-off or reboot the machine

SYNOPSIS

halt [OPTIONS...]
poweroff [OPTIONS...]
reboot [OPTIONS...]

OPTIONS

--halt
Halt the machine, regardless of which one of the three commands is invoked. -p, --poweroff
Power-off the machine, regardless of which one of the three commands is invoked. --reboot
Reboot the machine, regardless of which one of the three commands is invoked. -f, --force
Force immediate halt, power-off, reboot. Do not contact the init system. -w, --wtmp-only
Only write wtmp shutdown entry, do not actually halt, power-off,reboot. -d, --no-wtmp
Do not write wtmp shutdown entry. --no-wall
Do not send wall message before halt, power-off, reboot.

halt、poweroff、reboot这3个命令比较简单,而且可以被shutdown替代

3.2 shutdown - Halt, power-off or reboot the machine

SYNOPSIS

shutdown [OPTIONS...] [TIME] [WALL...]

OPTIONS

-H, --halt
Halt the machine. -P, --poweroff
Power-off the machine (the default). -r, --reboot
Reboot the machine. -h
Equivalent to --poweroff, unless --halt is specified. -k
Do not halt, power-off, reboot, just write wall message. --no-wall
Do not send wall message before halt, power-off, reboot. -c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not "+0" or "now".

EXAMPLES

shutdown这个命令不难,执行结果比较特殊,就不做演示了。

Linux-帮助与基本命令的更多相关文章

  1. Linux的常用基本命令

    Linux的常用基本命令. 首先启动Linux.启动完毕后需要进行用户的登录,选择登陆的用户不同自然权限也不一样,其中“系统管理员”拥有最高权限. 在启动Linux后屏幕出现如下界面显示: …… Re ...

  2. Linux的常用基本命令。

    Linux的常用基本命令. 首先启动Linux.启动完毕后需要进行用户的登录,选择登陆的用户不同自然权限也不一样,其中"系统管理员"拥有最高权限. 在启动Linux后屏幕出现如下界 ...

  3. [Linux] Linux 中的基本命令与目录结构

    Linux 中的基本命令与目录结构 目录 一.Linux 基本目录结构 二.基本命令 三.浏览目录 四.中间命令 五.更改密码 六.环境变量和 shell 变量 七.命令路径 八.文本编辑器 九.获取 ...

  4. Linux系统下基本命令

    <Linux系统下基本命令> Linux系统下基本命令: 要区分大小写 uname 显示版本信息(同win2K的 ver) dir 显示当前目录文件,ls -al 显示包括隐藏文件(同wi ...

  5. linux的一些基本命令

    一.linux的一些基本命令(使用的是CentOS7系统): 1.创建用户组,创建新用户并添加到用户组 添加用户,添加用户组命令: 增加用户:useradd -d /usr/username -m u ...

  6. linux应用之基本命令

    linux操作系统的应用层可以细分为两层:1.系统服务层(包括GUI shell.CUI shell.cron.ftp.远程登录openssh等由init调用的服务)2.系统命令和用户应用. linu ...

  7. Linux 下的基本命令

    Linux 下的基本命令 1. ls 命令 格式 : ls [OPTION]... [FILE]... 用途 : 显示目录下的内容 [OPTION] : -l : 列出详细信息 -d : 显示目录本身 ...

  8. 分享linux系统more基本命令python源码

    此python源码是linux系统more基本命令的实现. 实现linux中more的基本功能,当more后加一个文件名参数时候,分屏显示按空格换页,按回车换行',在左下角显示百分比; 以处理管道参数 ...

  9. Linux 的常用基本命令

    一.Linux 的常用基本命令..................................................................................... ...

  10. 【Linux】linux经常使用基本命令

    Linux中很多经常使用命令是必须掌握的,这里将我学linux入门时学的一些经常使用的基本命令分享给大家一下,希望能够帮助你们. 这个是我将鸟哥书上的进行了一下整理的,希望不要涉及到版权问题. 1.显 ...

随机推荐

  1. PhpStorm 为 Laravel 搭建 PhpUnit 单元测试环境

    1.PhpStorm 中打开项目的路径为 Laravel 安装的根目录 2.点击右下角 EventLog 提示按钮, 初始化 Composer 的设置 3.打开单元单测试示例类,按提示点击 Fix . ...

  2. JDK 之资源文件管理

    JDK 之资源文件管理 JDK 规范目录(https://www.cnblogs.com/binarylei/p/10200503.html) 一.文件资源 user.home 用户目录,如 Linu ...

  3. dfs序理解-hdu3887

    dfs序就是相当于把树转化成了一个区间,在区间上进行操作. void dfs(int u, int fa) { l[u]=++key; ; i=e[i].next) { int v=e[i].v; i ...

  4. HQL和SQL查询

     转自http://blog.csdn.net/aaa1117a8w5s6d/article/details/7757097 HQL和SQL的区别 标签: sqlhibernatejavasessio ...

  5. 836. Rectangle Overlap

    class Solution { public: bool isRectangleOverlap(vector<int>& rec1, vector<int>& ...

  6. Codeforces 1093 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 GGG题手速慢了没有在比赛的时候码出来233,FFF题居然没想出来? 五道题滚粗. 先谈谈其他几道题. A题 传送门 不小心看错题 直接看奇 ...

  7. ssh scp 加端口

    scp -P one-infrastructure-api.tar.gz console@172.31.16.2:/root/ ssh -p console@172.31.16.2

  8. MySQL处理表字段小技巧

    MySQL利用正则函数替换值 update dateTest set date=REPLACE(date,'/','') where date REGEXP '\/'; SQL语句讲解: -- 将 所 ...

  9. 变动事件_DOM2级的变动事件(mutation)

    DOM2级定义了如下变动事件: DOMSubtreeModified:在DOM结构中发生任何变化时触发.这个事件在其他任何事件触发后都会触发. DOMNodeInserted:在一个节点作为子节点被插 ...

  10. 触摸屏 adb调试

    1.adb shell cat /proc/kmsg 这条命令肯定是要放在第一位的,可以打印内核信息,对应于驱动程序中的printk语句. 如果出现以下提示,说明权限不够,可以通过adb root获取 ...