Linux系统上命令的使用格式

说明Linux系统上命令的使用格式

  1. 发起-命令:请求内核将某个二进制程序运行为一个进程;
  2. 命令本身是一个可执行的程序文件:二进制格式文件,有可能会调用共享库文件;
  3. 命令必须遵守特定格式规范:exe,msi,elf(linux)
  4. 命令分为两类:
    • 由shell程序自带的命令:内置命令;
    • 独立的可执行的程序文件,文件名即命令名:外部命令;

ifconfig
ifconfig [-v] [-a] [-s] [interface]

-a 显示所有的接口信息
[root@qingcheng-app ~]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 103.239.206.218  netmask 255.255.255.192  broadcast 103.239.206.255
        inet6 fe80::6421:66ff:fe0e:78bf  prefixlen 64  scopeid 0x20<link>
        ether 66:21:66:0e:78:bf  txqueuelen 1000  (Ethernet)
        RX packets 104461574  bytes 5720009004 (5.3 GiB)
        RX errors 0  dropped 52139  overruns 0  frame 0
        TX packets 192538  bytes 8618349 (8.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.47.68  netmask 255.255.255.0  broadcast 172.19.47.255
        inet6 fe80::5497:e2ff:fe1a:897e  prefixlen 64  scopeid 0x20<link>
        ether 56:97:e2:1a:89:7e  txqueuelen 1000  (Ethernet)
        RX packets 47192619  bytes 3940411778 (3.6 GiB)
        RX errors 0  dropped 46770  overruns 0  frame 0

-s 显示简要的网卡信息
[root@qingcheng-app ~]# ifconfig -s
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0      1500 104464601      0  52139 0        192547      0      0      0 BMRU
eth1      1500 47194217      0  46771 0      10869491      0      0      0 BMRU
lo       65536    84019      0      0 0         84019      0      0      0 LRU

up 启动指定网卡
[root@qingcheng-app ~]# ifconfig eth1 up

down 关闭指定网卡
[root@qingcheng-app ~]# ifconfig eth1 down

-arp 设置指定网卡是否支持ARP协议
[root@qingcheng-app ~]# ifconfig eth1 arp
[root@qingcheng-app ~]# ifconfig eth1  -arp

给eth1设置静态IP地址
[root@qingcheng-app ~]# ifconfig eth0 192.168.1.56 netmask 255.255.255.0

mtu<字节数>设置网卡最大的传输单元
[root@qingcheng-app ~]# ifconfig eth0 mtu 1500 

echo:回显的命令
echo [short-option]...[siring]...

-n:输出行尾的换行符
-e:允许对喜爱按列出的反斜线转义的字符进行解释
-E:禁止对STRINGs中的那些序列进行解释
\n:换行
\t:制表符

[root@qingcheng-app ~]# echo '111'
111
您在 /var/spool/mail/root 中有邮件
[root@qingcheng-app ~]# echo -n '111'
111[root@qingcheng-app ~]# echo -e "a\nb\nc"
a
b
c
您在 /var/spool/mail/root 中有邮件
[root@qingcheng-app ~]# 

tty
tty [OPTION]...

-s,--silent,--quiet:什么也不显示,只返回退出状态值
--help:显示帮助信息并退出
--version:显示版本信息并退出
[root@qingcheng-app ~]# tty -s
[root@qingcheng-app ~]# tty
/dev/pts/1
[root@qingcheng-app ~]# tty --help
用法:tty [选项]...
显示出连接到当前标准输入的终端设备文件名。

  -s, --silent, --quiet    什么也不显示,只返回退出状态值
      --help        显示此帮助信息并退出
      --version        显示版本信息并退出

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告tty 的翻译错误
要获取完整文档,请运行:info coreutils 'tty invocation'
[root@qingcheng-app ~]# tty --version
tty (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
许可证:GPLv3+:GNU 通用公共许可证第3 版或更新版本<http://gnu.org/licenses/gpl.html>。
本软件是自由软件:您可以自由修改和重新发布它。
在法律范围内没有其他保证。

startx

startx:启动图形界面
[root@qingcheng-app ~]# startx

export:显示和设置环境变量值

-f:带边环境变量为函数名称
-n:删除指定的环境变量
-p:列出所有的环境变量

[root@qingcheng-app ~]# aaa=bbb
[root@qingcheng-app ~]# export aaa
[root@qingcheng-app ~]# env|grep aa
aaa=bbb
[root@qingcheng-app ~]# export -n aaa
[root@qingcheng-app ~]# env|grep aa
[root@qingcheng-app ~]# export PATH=$PATH:/usr/local/bin

pwd:显示工作目录
pwd [OPTION]...

-L,--logical :显示当前目录
-P,--physical:显示当前目录的实际物理地址
--help 帮助
--version 版本
[root@qingcheng-app ~]# pwd
/root
[root@qingcheng-app ~]# pwd -L
/root
[root@qingcheng-app ~]# pwd -P
/root

history:显示执行过的命令,也可以根据显示记录重新执行需要的命令

n 显示n个最近的记录
-a:添加记录
-r:读取记录,但不会添加内容记录
-w:覆盖原有的history文件
-c:清除记录
-d<编号>[n]:删除指定n条记录
-n<文件>:读取指定文件
-r<文件>:读取文件但不记录
-w<文件>:覆盖原有文件

[root@qingcheng-app ~]# history|more
    1  ls
    2  ifconfig
    3  ip addr show

[root@qingcheng-app ~]# history 2
  637  history|more
  638  history 2
[root@qingcheng-app ~]# !21
ping www.baidu.com
PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.
64 bytes from 180.97.33.108: icmp_seq=1 ttl=49 time=29.3 ms

[root@qingcheng-app ~]# history -c

shutdown
以一种安全的方式关闭系统。所有登陆用户都可以看到关系信息提示,并且login(1)将被阻塞。可以指定立刻关机,也可以指定系统在一定的延时后关机。

-k:并非真正关机,只向所有人显示警告信息
-r:重启
-h:停机
-f:重启跳过硬盘检测
-F:重启强制磁盘检测
-c:取消
[root@localhost ~]# shutdown -h now
[root@localhost ~]# shutdown -h 23:00
[root@localhost ~]# shutdown -r now
[root@localhost ~]# shutdown -r +30 'reboot now'
Shutdown scheduled for 三 2017-12-06 06:17:23 CST, use 'shutdown -c' to cancel.
[root@localhost ~]# shutdown -c
Broadcast message from root@localhost.localdomain (Wed 2017-12-06 05:47:44 CST):
The system shutdown has been cancelled at Wed 2017-12-06 05:48:44 CST!

poweroff:用来关机计算机操作系统并且切断系统电源
poweroff [OPTIONS...]

-n:关闭操作系统时不执行sync操作;
-w:不真正关闭操作系统,仅在日志文件“/var/log/wtmp"中
-d:关闭操作系统时,不将操作写入日志文件“/var/log/wtmp"
-f:强制关闭操作系统;
-i:关闭操作系统之前关闭所有的网络接口;
-h:关闭操作系统之前将系统中所有硬件设置为备用模式;
[root@localhost ~]# poweroff

reboot:重启

-d:重新开机时不把数据写入记录文件/var/tmp/wtmp
-f:强制重新开机,不调用shutdown指令的功能
-i:在重开机之前,先关闭所有的网络界面
-n:重卡机之前不检查是否有未结束的程序
-w:仅做测试,并不真的将系统重新卡机,数据会写入/var/tmp/wtmp

[root@localhost ~]# reboot

hwclock:硬件时钟

-s,--hctosys:以硬件为准,把系统调整为与硬件时间相同;
-w,--systoch:以系统为准,把硬件调整为系统时间相同;

[root@localhost ~]# hwclock -s
[root@localhost ~]# hwclock -m

date:系统时钟
date [OPTION]... [+FORMAT]

FORMAT:格式符
 %F
 %T
 %M
 %d
 %H
 %M
  %S
  %s:从1970年1月1号(unix元年)0点0分0秒命令执行的那一刻经过的秒数
-d, --date=STRING:显示由STRING指定的时间
-s, --set=STRING:根据STRING设置时间
[root@localhost ~]# date 
2017年 12月 06日 星期三 06:14:49 CST
[root@localhost ~]# date -s '22:22:10'
2017年 12月 06日 星期三 22:22:10 CST
[root@localhost ~]# date +%m%d%H$M$S
120622

[root@localhost ~]# date -s "22:22:22 2017-12-08"
posted on 2017-12-06 00:41  美丽de世界  阅读(122)  评论(0编辑  收藏  举报