一、
解释:
[root@localhost Desktop]#
root:代表当前登录用户
localhost:代表当前系统的主机名称
Desktop:代表当前所在的位置
#:这个#代表当前登录用户是管理员用户
root:管理员 administractor
$:代表当前登录用户为普通用户
ex:[student@localhost ~]
二、用户切换
[root@localhost ~]# su xuxu
[xuxu@localhost root]$ su root
Password:
[root@localhost ~]# su - xuxu
Last login: Wed Nov 20 21:00:32 EST 2019 on pts/1
[xuxu@localhost ~]$ su - root
Password:
Last login: Wed Nov 20 21:05:52 EST 2019 on pts/1
[root@localhost ~]# exit
logout
[xuxu@localhost ~]$ exit
解释:
[root@localhost ~]# su - student
su [-] username 切换当前登录
有 - :代表切换bash
无 - :代表不切换bash环境
由root用户到普通用户不需要密码
由普通用户到root用户需要密码
exit 退出
三、查看当前主机名
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostnamectl set-hostname LEARNLINUX
[root@localhost ~]# hostname
learnlinux
解释:
#查看系统当前主机名 hostname
[root@localhost Desktop]# hostname
localhost.localdomain
#修改主机名并让他生效 hostnamectl set-hostname hostname
[root@localhost Desktop]# hostnamectl set-hostname BJTLXY
[root@localhost Desktop]# hostname
bjtlxy
[root@localhost Desktop]# su -
Last login: Fri Jun 29 08:07:42 EDT 2018 on pts/0
[root@bjtlxy ~]#
四、常用命令
1.关机命令
poweroff
init 0
shutdown -h now
halt
2.重启命令
reboot
shutdown -r now #现在重启
shutdown -r +15 #15min后重启
3.查看系统当前时间
[root@localhost ~]# date
Wed Nov 20 21:18:20 EST 2019
4.查看日历
[root@localhost ~]# cal
November 2019
Su Mo Tu We Th Fr Sa
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
[root@localhost ~]# cal 2018
2018
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 1 2 3 1 2 3
7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10
14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17
21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24
28 29 30 31 25 26 27 28 25 26 27 28 29 30 31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7 1 2 3 4 5 1 2
8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9
15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16
22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23
29 30 27 28 29 30 31 24 25 26 27 28 29 30
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7 1 2 3 4 1
8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8
15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15
22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22
29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29
30
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 1 2 3 1
7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8
14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15
21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22
28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29
30 31
[root@localhost ~]# cal 7 2018
July 2018
Su Mo Tu We Th Fr Sa
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
解释:
cal 年份 #查看全年日历
cal 月份 年份 #查看某年某月的日历
五、网络通信的三种方法
1.查看系统当前IP地址
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.200 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::bfc:b8b7:ec4e:5df7 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:22:b9:37 txqueuelen 1000 (Ethernet)
RX packets 740 bytes 57694 (56.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 411 bytes 51100 (49.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 880 bytes 75648 (73.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 880 bytes 75648 (73.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8c:d5:93 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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 group default qlen 1000
link/ether 00:0c:29:22:b9:37 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.200/24 brd 192.168.0.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::bfc:b8b7:ec4e:5df7/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:8c:d5:93 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:8c:d5:93 brd ff:ff:ff:ff:ff:ff
六、常用快捷键
CTRL + c 中断当前操作
CTRL + l(aile) = clear #清屏
‘’ #换行
CTRL + A #光标跳到行首
CTRL + E #光标跳到行尾
CTRL + U #清空光标所在位置的前面所有内容
CTRL + K #清空光标所在位置的后面所有内容
history #查看历史命令,默认保留1000行
[root@localhost ~]# history
1 su xuxu
2 exit
3 su -xuxu
4 su - xuxu
5 su root
6 su xuxu
7 hostname
!n #调用历史命令 !8
[root@localhost ~]# !8
cal
November 2019
Su Mo Tu We Th Fr Sa
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
[root@bjtlxy ~]# history -c #清除历史命令
[root@localhost ~]# history -c
[root@localhost ~]# history
1 history
#放大字体
CTRL + SHIFT + “+”
#缩小字体
CTRL + “-”