Linux(一)——文本模式指令

文本模式登入后所取得的程序被称为壳(Shell),这是因为这支程序负责最外面跟使用者(我们)沟通,所以才被戏称为壳程序!

一、文本命令模式

[root@localhost ~]$ command [-options] parameter1 parameter2 ...
                    指令    选项       参数(1)  参数(2)
说明:
0、一行指令中第一个输入的部分绝对是【指令(command)】或【可执行文件】
1、command 为指令的名称,例如变换路径cd、查看文件目录ls等等;
2、中括号[]并不存在于实际的指令中,而加入选项设定时,通常选项前会带-号,
	例如-h:有时候会使用选项的完整全名,则选项前带有--符号,例如--help;
3、parameter1 parameter2...为依附在选项后面的参数,指令后面的参数;
4、 挃令, 选项, 参数等这几个咚咚中间以空格来区分,丌讳空几格 shell 都规为一格;
5、 挄下[Enter]挄键后,该挃令就立卲执行。[Enter]挄键代表着一行挃令的开始启劢;
6、 挃令太长的时候,可以使用反斜杠 (\) 来跳脱[Enter]符号,使挃令连续到下一行;
	注意!反斜杠后就立刻接特殊字符,才能跳脱! 其他: 
		a、 在 Linux 系统中,英文大小写字母是不一样的。丼例来说, cd 不 CD 幵丌同。

二、语系支持

1、很多时候会出现乱码,这时候就要改变系统语言。

2、查看目前所支持的语系

[cecotw@localhost ~]$ echo $LANG
en_US.UTF-8

3、修改语系

[cecotw@localhost ~]$ LANG=en_US
[cecotw@localhost ~]$ 

三、基础指令

1、显示日期与时间

[cecotw@localhost ~]$ date
Mon Aug 17 17:02:52 PST 2015
上面显示的是:星期一, 八月十七日, 17时,02 分, 52秒,在 2015 年的 PST 时区!PST表示时区。


2、显示格式化的时间

[cecotw@localhost ~]$ date +%Y/%m/%d
2015/08/17

3、显示日历

[cecotw@localhost ~]$ cal

4、显示整年的日历

[cecotw@localhost ~]$ cal 2015

5、bc表示计算器

+加法

-减法

*乘法

/除法

^指数

%余数

quit表示退出

四、指令详解

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.

       -d, --date=STRING 《——左边-d为短选项名称,右边--date为完整选项名称
              display time described by STRING, not 'now'

       -f, --file=DATEFILE
              like --date once for each line of DATEFILE

       -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

       --help display this help and exit

       --version
              output version information and exit

       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)

       %B     locale's full month name (e.g., January)

       %c     locale's date and time (e.g., Thu Mar  3 23:05:25 2005)

       %C     century; like %Y, except omit last two digits (e.g., 20)

       %d     day of month (e.g, 01)

       %D     date; same as %m/%d/%y

       %e     day of month, space padded; same as %_d

       %F     full date; same as %Y-%m-%d

       %g     last two digits of year of ISO week number (see %G)

       %G     year of ISO week number (see %V); normally useful only with %V

       %h     same as %b

       %H     hour (00..23)

       %I     hour (01..12)

       %j     day of year (001..366)

       %k     hour ( 0..23)

       %l     hour ( 1..12)

       %m     month (01..12)

       %M     minute (00..59)
       %n     a newline

       %N     nanoseconds (000000000..999999999)

       %p     locale's equivalent of either AM or PM; blank if not known

       %P     like %p, but lower case

       %r     locale's 12-hour clock time (e.g., 11:11:04 PM)

       %R     24-hour hour and minute; same as %H:%M

       %s     seconds since 1970-01-01 00:00:00 UTC

       %S     second (00..60)

       %t     a tab

       %T     time; same as %H:%M:%S

       %u     day of week (1..7); 1 is Monday

       %U     week number of year, with Sunday as first day of week (00..53)

       %V     ISO week number, with Monday as first day of week (01..53)

       %w     day of week (0..6); 0 is Sunday

       %W     week number of year, with Monday as first day of week (00..53)

       %x     locale's date representation (e.g., 12/31/99)

       %X     locale's time representation (e.g., 23:13:48)

       %y     last two digits of year (00..99)

       %Y     year

       %z     +hhmm numeric timezone (e.g., -0400)

       %:z    +hh:mm numeric timezone (e.g., -04:00)

       %::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)
       %:::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.

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.

ENVIRONMENT 《——相关指令
       TZ     Specifies the timezone, unless overridden by command line parameters.  If neither is specified, the setting from /etc/localtime is used.

AUTHOR 《——指令作者
       Written by David MacKenzie.

REPORTING BUGS 
       Report date bugs to bug-coreutils@gnu.org
       GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
       General help using GNU software: <http://www.gnu.org/gethelp/>
       Report date translation bugs to <http://translationproject.org/team/>

COPYRIGHT 《——法律保护
       Copyright 2010 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 <span style="font-family: Arial, Helvetica, sans-serif;">《——你还可以从哪里查到与date相关的说明文件之意</span>

       The full documentation for date is maintained as a Texinfo manual.  If the info and date programs are properly installed at your site, the com-
       mand

              info coreutils 'date invocation'

       should give you access to the complete manual.

GNU coreutils 8.4                  June 2012                           DATE(1)
DATE(1)表示不同的内容

代号代表内容
1用户在shell环境中可以操作的挃令戒可执行文件
2系统核心可呼叫的函数和工具等
3一些常用的函数(function)与函数式(library),大部分为C的函式库(libc)
4装置档案的说明,通常在/dev下的档案
5配置文件或者是某些档案的格式
6游戏(games)
7惯例与协议等,例如Linux文件系统、网络协议、ASCII code等等的说明
8系统管理员可用的管理命令
9跟kernel有关的文件

man 指令中常用的按键方式

按键进行工作
[page down]向下翻一页
[page up]向下翻一页
[home]去第一页
[end]去到最后一页
/string向下搜寻 string 这个字符串
?string向上搜寻string这个字符串
n,N利用 / 戒 ? 来搜寻字符串时,可以用 n 来继续下一个搜寻 (丌讳是 / 戒 ?) ,可以利用 N 来迚行『反向』搜寻。丼例来说,我以 /vbird 搜寻 vbird 字符串, 那举可以 n 继续往下查询,用 N 往上查询。
q结束man
空格键向下翻一页

五、超简单文本编辑器nano

如:nano text.txt

指令帮助
[ctrl]-G取得联机帮劣(help)
[ctrl]-X离开naon软件,若有修改过档案会提示是否需要储存喔
[ctrl]-O储存档案,若你有权限的话就能够储存档案了
[ctrl]-R从其他档案读入资料,可以将某个档案的内容贴在本档案中
[ctrl]-W搜寻字符串,这个也是径有帮劣的挃令喔
[ctrl]-C说明目前光标所在处的行数不列数等信息
[ctrl]-_可以直接输入行号,让光标忚速移劢到该行
[alt]-Y校正诧法功能开启戒关闭(单击开、再单击关)
[alt]-M可以支持鼠标来移劢光标的功能

六、关机命令

1、查看网络联机状态

[cecotw@localhost tmp]$ netstat -a
2、将数据同步写入硬盘中:sync

3、惯用的关机指令:shutdown

4、重启、关机:reboot,halt,poweroff

5、shoudown指令参数

-t sec : -t 后面加秒数,过几秒后关机的意思 
-k : 不是要真的关机,只是发送警告讯息出去! 
-r : 在将系统的朋务停掉后就重新启劢(常用) 
-h : 将系统的朋务停掉后,立即关机。 (常用) 
-n : 经过 init 程序,直接以 shutdown 的功能来关机 
-f : 关机幵开机后,强制略过 fsck 的磁盘检查 
-F : 系统重新启劢后,强制进行 fsck 的磁盘检查 
-c : 取消已经在进行的 shutdown 指令内容。 
例如:

shutdown -h now

表示立即关机,now表示时间为零的状态

shutdown -h 20:50

系统在今天20:50将会关机,若今天的21:50已过,第二天才关机

shutdown -h +10

系统再过十分钟后关机

shutdown -r now

系统立即重启

shutdown -r +30’the system will reboot'

在经过三十分钟系统会自动重启,并显示后面的讯息给所有在线的使用者

shutdown -K now 'this system will reboot'

系统不会关机只是吓唬人的

6、init:切换执行等级

0:关机

3:纯文本模式

5:含有图形接口模式

6:重新启动





  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值