Linux指令练习
1、date 查找日期
date
date +%Y/%m/%d
date +%H:%M
2、 cal 查看日历
cal
cal 1998
cal [month] [year]
cal 8 2020
3、 bc linux计算器
bc
quit 退出
4、热键 [Tab],[ctrl]-c,[ctrl]-d
[Tab]
$ca[Tab][Tab] #补全命令
r_rehash cache_writeback canberra-boot case
cache_check cairo-sphinx canberra-gtk-play cat
cache_dump cal cancel catchsegv
cache_metadata_size ca-legacy cancel.cups catman
cache_repair calibrate_ppa capsh
cache_restore caller captoinfo
$ls -al ~/.bash[Tab][Tab] #补全文件名
ash_history .bash_logout .bash_profile .bashrc
$date --[tab][tab] #查看可使用选项
--date --help --reference= --rfc-3339= --universal
--date= --iso-8601 --rfc-2822 --set= --version
$ g[tab][tab] #查看有多少以g开头的命令
Display all 241 possibilities? (y or n)
[ctrl]-C 中断运行
$find /
......
[ctrl]+C #退出中断运行
[ctrl]-D 相当于输入exit
[ctrl]-D
[shift]+{[PgUP]|[Pgan]} 上下翻页
5 --help 求助说明
$ date --help
Usage: date [OPTION]... [+FORMAT] #基本语法
or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] #设置时间语法
Display the current time in the given FORMAT, or set the system date.
#下面是主要选项说明
Mandatory arguments to long options are mandatory for short options too.
-d, --date=STRING display time described by STRING, not 'now'
-f, --file=DATEFILE like --date once for each line of DATEFILE
-I[TIMESPEC], --iso-8601[=TIMESPEC] output date/time in ISO 8601 format.
TIMESPEC='date' for date only (the default),
'hours', 'minutes', 'seconds', or 'ns' for date
and time to the indicated precision.
-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
--rfc-3339=TIMESPEC output date and time in RFC 3339 format.
TIMESPEC='date', 'seconds', or 'ns' for
date and time to the indicated precision.
Date and time components are separated by
a single space: 2006-08-07 12:34:56-06:00
-s, --set=STRING set time described by STRING
-u, --utc, --universal print or set Coordinated Universal Time (UTC)
--help display this help and exit #显示此求助说明并离开
--version output version information and exit #显示版本信息并离开
# 下面是重要的格式(FORMAT)的主要项目
FORMAT controls the output. Interpreted sequences are:
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
...省略...
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes.
The following optional flags may follow '%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
^ use upper case if possible
# use opposite case if possible
After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
E to use the locale's alternate representations if available, or
O to use the locale's alternate numeric symbols if available.
# 几个重要范例
Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
$ date --date='@2147483647'
Show the time on the west coast of the US (use tzselect(1) to find TZ)
$ TZ='America/Los_Angeles' date
Show the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'date invocation'
6、 man page 操作说明
$ man date
DATE(1) User Commands DATE(1)
NAME #指令的完整全名,说明简单用途
date - print or set the system date and time
SYNOPSIS #该指令 基本语法
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION #详细说明语法谈到的选项与参数的用法
Display the current time in the given FORMAT, or set the system date.
Mandatory arguments to long options are mandatory for short options too.
-d, --date=STRING
display time described by STRING, not 'now'
-f, --file=DATEFILE
like --date once for each line of DATEFILE
......
FORMAT controls the output. Interpreted sequences are:
#格式化输出的详细数据
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
......
ENVIRONMENT #与这个指令相关的环境参数有如下说明
TZ Specifies the timezone, unless overridden by command line parameters.
If neither is specified, the setting from /etc/localtime is used.
EXAMPLES #可用的范本
Convert seconds since the epoch (1970-01-01 UTC) to a date
$ date --date='@2147483647'
Show the time on the west coast of the US (use tzselect(1) to find TZ)
$ TZ='America/Los_Angeles' date
Show the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report
date translation bugs to <http://translationproject.org/team/>
DATE STRING #格式说明
The --date=STRING is a mostly free format human readable date string such as
"Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next
Thursday". A date string may contain items indicating calendar date, time of
day, time zone, day of week, relative time, relative date, and numbers. An
empty string indicates the beginning of the day. The date string format is
more complex than is easily documented here but is fully described in the
info documentation.
AUTHOR #指令作者
Written by David MacKenzie.
COPYRIGHT #著作权保护
Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL ver‐
sion 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 #还可以从哪里查看与date相关的说明文档
The full documentation for date is maintained as a Texinfo manual. If the
info and date programs are properly installed at your site, the command
info coreutils 'date invocation'
should give you access to the complete manual.
对DATE(1)中的(1)的说明
-
一般使用者可使用的指令
-
了解或者是直接查询相关的数据
代号 代表内容
1 使用者在shell环境中可操作的指令或可执行文件
2 系统核心可调用的函数与工具等
3 一些常用函数(function) 与函数库(library),大部分的C的函数库(libc)
4 设备文件的说明,通常在/dev下的文件
5 配置文件或者是某些文件的格式
6 游戏
7 惯例与协定等,让Linux文件系统,网络协定,ASCllcode等等说明
8 系统管理员可用的管理指令
9 跟kernel有关的文件
可使用man man 获取更详细的说明
man page 主要部分的说明
代号 内容说明
NAME 简短的指令、数据名称说明
SYNOPSIS 简短的指令下达语法(syntax)简介
DESCRIPTION 较完整的说明,最好仔细看
OPTION 针对SYNOPSIS部分中,有列举的所有可用选项说明
COMMANDS 当这个程序在执行时,开在此程序中下达的指令
FILES 这个程序或数据所使用或参考或链接到的某些文件
SEE ALSO 可以参考的,跟这个指令或数据有相关的其他说明
EXAMPLE 可参考的范例
man page 中的常用快捷键
按键 进行工作
空格 向下翻一页
[page down] 向下翻一页
[page up] 向上翻一页
[home] 去到第一页
[end] 去到最后一页
/string 向"下"搜寻string字串,
?string 向"上"搜寻string字串
n,N 利用/或?搜寻字串时,可以用n来继续下一个搜寻,可以利用N进项”反向“搜寻
q 结束这次man page
man查阅技巧
- 先看NAME,粗略看下这个数据的意思
- 在详看DESCRIPTION,这里会提到许多相关的数据与使用时机
- 如果熟悉的指令,主要查询OPTIONS部分,可以下达比较细部的命令
- 最后看下跟这个相关的那些东西可以使用SEE ALSO
whatis [指令] ==man -f [指令]
$ whatis man
$ man -f man
apropos [指令] == man -k [指令]
$ apropos man
$ man -k man
6 info
File: info.info, Node: Top, Next: Getting Started, Up: (dir)
Info: An Introduction
*********************
The GNU Project distributes most of its on-line manuals in the "Info
format", which you read using an "Info reader". You are probably using
an Info reader to read this now.
There are two primary Info readers: 'info', a stand-alone program
designed just to read Info files (*note What is Info?: (info-stnd)Top.),
and the 'info' package in GNU Emacs, a general-purpose editor. At
present, only the Emacs reader supports using a mouse.
If you are new to the Info reader and want to learn how to use it,
type the command 'h' now. It brings you to a programmed instruction
sequence.
......
* Menu:
* Getting Started:: Getting started using an Info reader.
* Advanced:: Advanced Info commands.
* Expert Info:: Info commands for experts.
* Index:: An index of topics, commands, and variables.
6 关机
sync 数据同步写入硬盘
sync #保存
shutdown [-krhc] [时间] [警告信息]
-
-k 不要真关机
-
-r 重启(常用)
-
-h 关机
-
-c 取消已经在进行的shutdown指令
shutdown -h now
shutdown -h 09:56
shutdown -h +10
shutdown -r now
shutdown -k now 'waring'
一般重启操作
sync;sync;sync;reboot
systemctl [指令]
- halt
- poweroff
- reboot
- suspend
网友评论