Linux基础命令注释(一)
cat 查看文件
[ root@localhost ~]
auth --enableshadow --passalgo= sha512
repo --name= "Server-HighAvailability" --baseurl= file:///run/install/repo/addons/HighAvailability
repo --name= "Server-ResilientStorage" --baseurl= file:///run/install/repo/addons/ResilientStorage
cdrom
graphical
firstboot --enable
ignoredisk --only-use= sda
keyboard --vckeymap= cn --xlayouts= 'cn'
lang zh_CN.UTF-8
.. .
ls 列出目录
ls 列出目录下所有文件(不包括以’ . '开头的隐藏文件)
[ root@localhost ~]
anaconda-ks.cfg
ls -a 列出文件下所有文件(包括以’ . '开头的隐藏文件)
[ root@localhost ~]
. anaconda-ks.cfg .bash_logout .bashrc .tcshrc
.. .bash_history .bash_profile .cshrc
ls -l 列出文件详细信息 创建者,创建时间,文件读写权限
[ root@localhost ~]
总用量 4
-rw-------. 1 root root 1451 9 月 6 22 :57 anaconda-ks.cfg
// 1 目录下只有一个文件 1451 文件大小
basht@localhost ~]# ls .
anaconda-ks.cfg
root@localhost ~]
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[ root@localhost ~]
anaconda-ks.cfg
a:
ls /tmp/ /root/ 查看两个文件的目录
[ root@localhost ~]
/root/:
a abc acd anaconda-ks.cfg bbb c cc qwq vbn wqw
/tmp/:
ks-script-bCAQaW
systemd-private-11747351e8364d83b070d6be17400cce-chronyd.service-lGLDlY
systemd-private-11747351e8364d83b070d6be17400cce-vgauthd.service-g3JiUd
systemd-private-11747351e8364d83b070d6be17400cce-vmtoolsd.service-wE4Eut
yum.log
mkdir 创建目录
[ root@localhost ~]
[ root@localhost ~]
a anaconda-ks.cfg
mkdir -p 创建目录,若父目录不在则自动创建
[ root@localhost ~]
[ root@localhost ~]
b
[ root@localhost ~]
c d
[ root@localhost ~]
e f
[ root@localhost ~]
mkdir: 已创建目录 "a"
mkdir: 已创建目录 "a/b"
mkdir: 已创建目录 "a/b/c"
mkdir: 已创建目录 "a/b/d"
mkdir: 已创建目录 "a/b/d/e"
mkdir: 已创建目录 "a/b/d/f"
mkdir: 已创建目录 "a/b/d/f/g"
mv 移动文件(也可用于重命名)
[ root@localhost ~]
a anaconda-ks.cfg
[ root@localhost ~]
[ root@localhost ~]
aa anaconda-ks.cfg
history 历史命令
[ root@localhost ~]
1 ls
2 file anaconda-ks.cfg
3 vi anaconda-ks.cfg
4 shutdown -h now
5 cd /etc/sysconfig/network-scripts/
6 vi ifcfg-ens33
7 systemctl restrat network
8 systemctl restart network
9 ip a
10 cdnte
11 cdnet
12 cdnte
13 `
14 cdnte
15 .
16 cdnte
17 cdnet
18 ls /tmp
19 ls
20 cd
[ root@localhost ~]
ip a
1 : lo: < LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0 .0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2 : ens33: < BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3a:87:11 brd ff:ff:ff:ff:ff:ff
inet 192.168 .213.128/24 brd 192.168 .213.255 scope global dynamic ens33
valid_lft 1309sec preferred_lft 1309sec
inet6 fe80::c862:f7d8:eac7:83ae/64 scope link
valid_lft forever preferred_lft forever
[ root@localhost ~]
/etc
[ root@localhost etc]
cd -
/root
history -d[n] 删除历史命令 -c删除所有
[ root@localhost ~]
1 history
2 pwd
3 cd
4 ls
5 ll
6 history
7 history -n1
8 history -n 1
9 history
[ root@localhost ~]
[ root@localhost ~]
1 pwd
2 cd
3 ls
4 ll
5 history
6 history -n1
7 history -n 1
8 history
9 history -d1
10 history
cd 切换目录
[ root@localhost ~]
[ root@localhost etc]
/etc
[ root@localhost ~]
[ root@localhost tom]
/home/tom
[ root@localhost etc]
[ root@localhost ~]
[ root@localhost etc]
[ root@localhost ~]
/root
//直接输入cd 也可返回当前用户目录
[ root@localhost ~]
[ root@localhost tom]
[ root@localhost ~]
[ root@localhost etc]
/root
[ root@localhost ~]
/etc
[ root@localhost /]
[ root@localhost sysconfig]
[ root@localhost etc]
管道符过滤文件
管道符的作用是将前一个命令的结果给作为后面命令的参数 cat anaconda-ks.cfg |grep rootpw过滤文件anaconda-ks.cfg中有关rootpw行
[ root@localhost ~]
rootpw --iscrypted $6 $15KaJSMJ1CnXnZP6 $i .4EoTpZwTUTcZhK0oYRIjgyP9UTYbXsq//IV4xIiaB.2RfwtJP7SzhiAN4KcrAZP1ABjRIPx9pdl7vXdHoJk.
[root@localhost ~]# cat anaconda-ks.cfg |grep rootpw > qwq 过滤文件并打印大qwq文件中
[ root@localhost ~]
[ root@localhost ~]
anaconda-ks.cfg qwq
[ root@localhost ~]
rootpw --iscrypted $6 $15KaJSMJ1CnXnZP6 $i .4EoTpZwTUTcZhK0oYRIjgyP9UTYbXsq//IV4xIiaB.2RfwtJP7SzhiAN4KcrAZP1ABjRIPx9pdl7vXdHoJk.
rm 删除文件
[ root@localhost ~]
aa anaconda-ks.cfg qwq
[ root@localhost ~]
rm:是否删除普通文件 "qwq" ?y
[ root@localhost ~]
aa anaconda-ks.cfg
[ root@localhost ~]
aa anaconda-ks.cfg
[ root@localhost ~]
rm:是否进入目录"aa" ? y
rm:是否进入目录"aa/b" ? y
rm:是否删除目录 "aa/b/c" ?y
rm:是否进入目录"aa/b/d" ? y
rm:是否删除目录 "aa/b/d/e" ?y
rm:是否进入目录"aa/b/d/f" ? y
rm:是否删除目录 "aa/b/d/f/g" ?y
rm:是否删除目录 "aa/b/d/f" ?y
rm:是否删除目录 "aa/b/d" ?y
rm:是否删除目录 "aa/b" ?y
rm:是否删除目录 "aa" ?y
[ root@localhost ~]
[ root@localhost ~]
a anaconda-ks.cfg
[ root@localhost ~]
[ root@localhost ~]
anaconda-ks.cfg
stat : 显示文件或文件系统的状态
[ root@localhost ~]
文件:"qwq"
大小:126 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:100663379 硬链接:1
权限:( 0644/-rw-r--r--) Uid:( 0 / root) Gid:( 0 / root)
环境:unconfined_u:object_r:admin_home_t:s0
最近访问:2019-09-07 14 :41:58.769032865 +0800
最近更改:2019-09-07 14 :41:58.769032865 +0800
最近改动:2019-09-07 14 :41:58.769032865 +0800
创建时间:-
touch 创建空文件或者更新时间戳
[ root@localhost ~]
[ root@localhost ~]
文件:"qwq"
大小:126 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:100663379 硬链接:1
权限:( 0644/-rw-r--r--) Uid:( 0 / root) Gid:( 0 / root)
环境:unconfined_u:object_r:admin_home_t:s0
最近访问:2019-09-07 14 :41:58.769032865 +0800
最近更改:2019-09-07 14 :41:58.769032865 +0800
最近改动:2019-09-07 14 :41:58.769032865 +0800
创建时间:-
alias 命令别名
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost network-scripts]
/etc/sysconfig/network-scripts
[ root@localhost ~]
alias cdnet = 'cd /etc/sysconfig/network-scripts'
alias rm = 'rm -i'
alias cp = 'cp -i'
alias mv = 'mv -i'
if [ -f /etc/bashrc ] ; then
. /etc/bashrc
fi
~
~
".bashrc" 12L, 223C