1.关机常用命令
Centos7之前:
shutdown - r now 立刻重启
shutdown -h now 立刻关机
reboot 重启
halt 关机 //这个关机只是停止了cpu工作,没有切断电源,关机不完全
poweroff 关机
Centos7之后保留了上面的关机命令,同时新增了新的关机命令,如下:
systemctl reboot 立刻重启
systemctl poweroff 立刻关机
systemctl halt 关闭系统cpu停止工作
2.pwd
[root@madongdong ~]# pwd //打印出当前所在的目录
/root
3.cd
[root@madongdong ~]# pwd
/root
[root@madongdong ~]# cd .. //返回上一级目录
[root@madongdong /]# pwd
/
[root@madongdong /]# cd ~ //切换到家目录
[root@madongdong ~]# pwd
/root
[root@madongdong ~]# cd - //切换到上一次的目录
/
[root@madongdong /]# pwd
/
[root@madongdong /]# cd -
/root
[root@madongdong ~]# cd . //切换到当前目录
[root@madongdong ~]# pwd
/root
4.tree
系统默认没有,需要安装
yum install tree -y
1.tree 目录
[root@madongdong ~]# tree /root/
/root/
└── anaconda-ks.cfg
--------------------------------------------------------------------
2.tree -L 层数 目录 //显示几层
[root@madongdong ~]# tree -L 1 /
/
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var
--------------------------------------------------------------------
3.tree -d 目录 //只显示目录
[root@madongdong ~]# tree -d /boot/
/boot/
├── efi
│ └── EFI
│ └── centos
├── grub
└── grub2
├── fonts
├── i386-pc
└── locale
5.mkdir-创建目录
1.mkdir +路径
[root@madongdong ~]# mkdir text //相对路径
[root@madongdong ~]# ls
anaconda-ks.cfg text
[root@madongdong ~]# mkdir /root/text2 //绝对路径
[root@madongdong ~]# ls
anaconda-ks.cfg text text2
[root@madongdong ~]#
---------------------------------------------------------------------
2.mkdir -p 目录1/目录2 //当目录1和目录2不存在的时候,递归创建目录
[root@madongdong ~]# mkdir -p mulu1/mulu2
[root@madongdong ~]# ls
anaconda-ks.cfg mulu1
[root@madongdong ~]# cd mulu1/
[root@madongdong mulu1]# ls
mulu2
[root@madongdong mulu1]#
---------------------------------------------------------------------
3.mkdir a b c d 同时创建多个目录
[root@madongdong ~]# mkdir a b c d
[root@madongdong ~]# ls
a anaconda-ks.cfg b c d
6.touch-创建文件
1.touch 路径
[root@madongdong ~]# touch /home/a
[root@madongdong ~]# cd /home/
[root@madongdong home]# ls
a madongdong
--------------------------------------------------------------
2.touch {n1..n2}文件剩余的名字或者后缀
[root@madongdong ~]# touch {1..5}.txt
[root@madongdong ~]# ls
1.txt 2.txt 3.txt 4.txt 5.txt anaconda-ks.cfg
[root@madongdong ~]# touch {1..5}
[root@madongdong ~]# ls
1 1.txt 2 2.txt 3 3.txt 4 4.txt 5 5.txt anaconda-ks.cfg