Linux常用命令(上)

19 篇文章 0 订阅
4 篇文章 1 订阅

简单命令

显示linux系统的当前时间

date

以2012/03/23的方式显示日期

date +%y/%m/%d

** 列出当前月份的月历**

cal

显示整年的月历

cal 2018

显示2018年3月的月历

cal 3 2018

使用计算器计算

bc

这里写图片描述

使用计算器计算1/3,结果保留2位小数

scale = 2 1/3

显示当前目录下所有文件(包括隐藏文件)

ls -a

以长格式显示目录/etc下所有文件

ls -al /etc

使用help命令查看date命令

date --help

使用man命令查看ls命令

man ls

使用ls命令查看当前目录下以i开头的所有文件

ls i*

使用showdown命令在10分钟后关闭计算机:

shutdown -h +10

取消计划关机

shutdown -c

Linux文件与目录管理

根目录下有哪些内容

ls /

进入/tmp目录 创建并进入

cd /tmp
mkdir 111
cd 111

在当前目录下,建立权限为741的目录test1,查看是否创建成功。

mdkir -m 741 test1

在目录test1下建立目录test2/teat3/test4

cd test1
mkdir -p test2/test3/test4

进入test2,删除目录test3/test4

cd test2
rmdir -p test3/test4

将root用户家目录下的.bashrc复制到/tmp下,并更名为bashrc

cp /root/.bashrc /tmp/bashrc

重复步骤 要求在覆盖钱询问

cp -i /root/.bashrc /tmp/bashrc

复制目录/etc/下的内容到/tmp下

cp -r /etc/ /tmp

在当前目录下建立文件aaa

touch aaa

查看该文件的权限、大小及时间

ls -l

强制删除该文件

rm -f aaa

将/tmp下的bashrc移到/tmp/111/test1/test2

mv /tmp/bashrc /tmp/111/test1/test2

将test1目录及其下面包含的所有文件删除

rm -r /tmp/111/test1

文件内容查阅及属性修改

** 使用cat命令加行号显示文件/etc/issue的内容。**

cat -n /etc/lissue

反向显示/etc/issue中的内容

tac /etc/issue

用nl列出/etc/issue中的内容

nl /etc/issue

more命令查看文件

more /etc/man.config

使用less命令前后翻看文件/etc/man.config中的内容

less /etc/man.comfig

使用head命令查看文件/etc/man.config前20行

head -n 20 /etc/man.config

将/usr/bin/passwd中的内容使用ASCII方式输出

od -t c /usr/bin/passwd

进入/tmp目录,将/root/.bashrc复制成bashrc,复制完全的属性,检查其日期

cd /tmp
sudo cp -a /root/.bashrc bashrc
ls bashrc
ls --time=atime bashrc
ls time=ctime bashrc

修改文件bashrc的时间为当前时间

touch bashrc
ls bashrc
ls --time=atime bashrc
ls --time=ctime bashrc


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

oifengo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值