Linux常用命令2

显示日期的指令:date

[root@localhost ~]# date
2019年 01月 21日 星期一 09:17:09 CST

[root@localhost ~]# date +%y/%m/%d
19/01/21

显示日历的指令:cal

[root@localhost ~]# cal    //显示当前日历
     一月 2019      
日  一  二  三  四  五  六
            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 31

[root@localhost ~]# cal 1 2019   //显示2019年1月的日历
     一月 2019      
日  一  二  三  四  五  六
            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 31

计算器指令:bc

[root@localhost ~]# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
3/4
0      //此时无小数显示
scale=3   //显示3位小数
3/4
.750
quit    //退出计算器

惯用的关机指令:shutdown

[root@localhost ~]# /sbin/shutdown -参数 时间 '警告讯息‘

-k : 不要真的关机,只是发送警告讯息出去!
-r : 在将系统的服务停掉之后就重新启动
-h : 将系统的服务停掉后,立即关机。
-n : 不经过 init 程序,直接以 shutdown的功能来关机
-f : 关机并开机之后,强制略过 fsck 的磁盘检查
-F : 系统重新启动之后,强制进行 fsck 的磁盘检查
-c : 取消已经在进行的 shutdown 指令内容

例:[root@linux ~]#shutdown -h now
       立刻关机,其中 now 相当于时间为 0 的状态
       [root@linux ~]# shutdown -h 20:25
       系统在今天的 20:25 分会关机
       [root@linux ~]# shutdown -h +10
       系统再过十分钟后自动关机
       [root@linux ~]# shutdown -r now
       系统立刻重新启动
       [root@linux ~]# shutdown -r +30 'The system will reboot'
       再过三十分钟系统会重新启动,并显示后面的讯息。
       [root@linux ~]# shutdown -k now 'This system will reboot'
       仅发出警告信件的参数!

改变文件拥有者:chown

rwxrw--wx   1   root    root        0            01-20   15:14   aa
文件权限           属主   属组   文件大小
    将aa拥有者改为test这个用户
    [root@localhost test]# chown test aa
    [root@localhost test]# ls -l
    -rwxrw--wx 1 test root 0 01-20 15:14 aa

由第一行开始显示档案内容:cat

例1:检阅 /home/1.c的内容

[root@localhost test]# cat /home/1.c
#include<stdio.h>
int main()
{
while(1);

}

例2:在例1基础上加上行号

[root@localhost test]# cat -n /home/1.c
     1  #include<stdio.h>
     2  int main()
     3  {
     4  while(1);
     5
     6  }

从最后一行开始显示:tac

[root@localhost test]# tac /home/1.c
}

while(1);
{
int main()
#include<stdio.h>

一页一页的显示档案内容:more

[root@localhost ~]# more /etc/man.config

一页一页显示根目录下etc中man.config内容
空格键:代表下翻一页
回车键:代表下翻一行
:f:显示文件名及目前所在行数
q:离开more

一页一页的显示档案内容可向前翻页:less

[root@localhost ~]# less /etc/man.config

空格键:代表下翻一页
pagedown:向下翻一页
pageup:向上翻页
q:离开less

档案搜寻指令:whereis

[root@localhost /]# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

创建文件并进入:vim

编辑文件:i
保存文件:esc+:
退出文件:q+w+回车

编译运行指令

例:编译运行1.c

[root@localhost share]# gcc 1.c
[root@localhost share]# ./a.out

清除命令:clear

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值