Linux学习笔记(二)命令格式与简单命令

来源:互联网 发布:mac win10 黑屏 编辑:程序博客网 时间:2024/05/29 17:08

本文是我读《鸟哥的Linux私房菜》的学习笔记。


命令格式

命令格式:  command   [-options]   parameter1 parameter2...

例如:

gin@ubuntu :~$  ls -al ~

命令为ls;选项为-al;参数为~    该命令的功能为列出主文件夹下的所有文件(包括隐藏文件)与相关的文件属性。

其中,-a表示列出主文件夹下的包括隐藏文件在内的所有文件,-l表示列出相关的文件属性。






注意:

  • 在Linux系统中,命令区分大小写。
  • 命令太长,则用反斜杠(\)来转移[Enter]字符。([Enter]一般是代表一行命令的开始启动,这里以反斜杠来进行转义)
  • 命令中无论有多少个连续空格,则一定当做一个空格看。例如:gin@ubuntu :~$ ls -al ~等同于gin@ubuntu :~$ ls           -al          ~

更改支持语言

使用 echo $LANG命令可以显示当前的支持语言。
使用 LANG = en_US 命令可以更改当前支持语言。en_US 代表美国英语。
如下:


注意:这仅仅是在当前这次登陆更改了支持语言。


几个简单的命令

1.帮助命令:--help
2.显示日期与时间:date 
以下是使用date --help帮助命令调出的一些格式
  %%   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, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %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 time zone (e.g., -0400)
  %:z  +hh:mm numeric time zone (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)

简单例子:



显示日历命令:cal
命令格式:cal [ [month] year ]
如下:


计算器:bc


退出是quit命令。


注意:命令行模式有两种命令:
  • 一种是该命令会直接显示结果并返回到命令提示符,等待下一个命令。例如cal命令。
  • 一种是进入到该命令的环境,知道结束该命令才会回到命令提示符。例如bc命令。