Kevin_306

02Linux入门-帮助、时间、时区、修改登录界面 20210114

Linux入门-命令练习 帮助、时间、时区、修改登录界面 20210114

1.whatis

使用数据库来显示命令的简短描述 此工具在系统刚安装后,不可立即使用,需要生成数据库后才可使用

#CentOS 7 版本以后 mandb 
#CentOS 6 版本之前 makewhatis

[root@localhost ~]# whatis

whatis what?

[root@centos8 ~]# whatis rm
rm (1)               - remove files or directories
rm (1p)              - remove directory entries

 

2.man

man 提供命令帮助的文件,手册页存放在/usr/share/man ,

几乎每个命令都有man的“页面”

中文man需安装包:

man-pages
man-pages-zh-CN

 

 

 

man命令的配置文件:

#CentOS 6 之前版 man 的配置文件 /etc/man.config 
#CentOS 7 之后版 man 的配置文件 /etc/man_db.conf 
#ubuntu  man 的配置文件 /etc/manpath.config

[root@localhost ~]# man -f rm (#man查看功能)
rm (1) - remove files or directories
[root@localhost ~]# help history(#内部命令查看帮助help cmd)

帮助命令简单小结:

内部命令,查看帮助 help cmd

外部命令:cmd --help|-h 、 man cmd或者配置文件、 whatis

[root@centos8 ~]# date +%F_%T
2021-01-14_20:13:07

[root@centos8 ~]# date +%F-%T (#有个-)
2021-01-14-20:13:43
[root@centos8 ~]# date +"%F %T"(#没有个-)
2021-01-14 20:13:55

举例:创建时间

[root@centos8 ~]# date +" %F %T" (#%前面多一个空格)
2021-01-14 20:16:20
[root@centos8 ~]# date +"%F %T"(#%前面多一个空格)
2021-01-14 20:16:24

cal 是Linux里的一个简单命令,用来查看日历的,日历 calendar    使用cal  -m  可以从周一开始显示日历。默认是周日开始显示。

故事:

[root@centos7-kevin306 ~]# cal 9 1752

 ------------------------------

[root@centos8 ~]# date (#系统当前时间)
Tue Mar 16 22:19:07 CST 2021

[root@centos8 ~]# clock (#获取系统当前的时间)

Tue 16 Mar 2021 10:19:27 PM CST -0.489815 seconds

 -------------------------------

[root@centos8 ~]# ip --help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
vrf | sr | nexthop | mptcp }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec | -j[son] | -p[retty] |
-f[amily] { inet | inet6 | mpls | bridge | link } |
-4 | -6 | -I | -D | -M | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
-rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |
-c[olor]}
[root@centos8 ~]#

-----------------------------

[root@centos8 ~]# ip a
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 fq_codel state UP group default qlen 1000
link/ether 00:0c:29:71:ad:da brd ff:ff:ff:ff:ff:ff
inet 192.168.0.115/24 brd 192.168.0.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::b69e:8c71:392a:1d68/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:2f:bf:e4 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 fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:2f:bf:e4 brd ff:ff:ff:ff:ff:ff
[root@centos8 ~]# ifconfig --help
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...

<HW>=Hardware Type.
List of possible hardware types:
loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP)
slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP)
ash (Ash) ether (Ethernet) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel)
ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB)
arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device)
sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI)
irda (IrLAP) x25 (generic X.25) infiniband (InfiniBand)
eui64 (Generic EUI-64)
<AF>=Address family. Default: inet
List of possible address families:
unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6)
ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE)
ipx (Novell IPX) ddp (Appletalk DDP) ash (Ash)
x25 (CCITT X.25)
[root@centos8 ~]#

 

-----------------------

kevin@kevin:~$ ss -ntl

State Recv-Q Send-Q Local Address:Port Peer Address:Port Process 
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* 
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* 
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:* 
LISTEN 0 128 [::]:22 [::]:* 
LISTEN 0 128 [::1]:6010 [::]:*

-----------------------------------

修改登录界面的访问提示!!! 

kevin@kevin:~$ sudo -i(#需要在管理员的下面)
[sudo] password for kevin:
root@kevin:~# nano /etc/issu
root@kevin:~# nano /etc/issue (#编辑内容)

 root@kevin:~# cat /etc/issue (#查看修改好的内容)

Welcome kevin306.cn

Ubuntu 20.04.1 LTS \n \l

root@kevin:~# reboot (#重启之后就可以看到下面的画面,中间多了一句话Welcome kevin306.cn

 ---------------------------------------

Connecting to 192.168.0.115:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

[root@centos8 ~]# 
[root@centos8 ~]# cd /etc/issue.d/
[root@centos8 issue.d]# ls
cockpit.issue
[root@centos8 issue.d]# cat cockpit.issue 
Activate the web console with: systemctl enable --now cockpit.socket

[root@centos8 issue.d]# 

-----------------
查看filter表所有规则: iptables -L(没加 -t 默认查看的是filter表)

[root@centos8 ~]# iptables -vnL(#iptables -vnL  等价于iptables -t filter -vnL)

Chain INPUT (policy ACCEPT 20538 packets, 9170K bytes)
pkts bytes target prot opt in out source destination
20528 9169K LIBVIRT_INP all -- * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 LIBVIRT_FWX all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LIBVIRT_FWI all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LIBVIRT_FWO all -- * * 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT 11316 packets, 1079K bytes)
pkts bytes target prot opt in out source destination
11304 1078K LIBVIRT_OUT all -- * * 0.0.0.0/0 0.0.0.0/0

Chain LIBVIRT_INP (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67
0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67

Chain LIBVIRT_OUT (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT udp -- * virbr0 0.0.0.0/0 0.0.0.0/0 udp dpt:53
0 0 ACCEPT tcp -- * virbr0 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
0 0 ACCEPT udp -- * virbr0 0.0.0.0/0 0.0.0.0/0 udp dpt:68
0 0 ACCEPT tcp -- * virbr0 0.0.0.0/0 0.0.0.0/0 tcp dpt:68

Chain LIBVIRT_FWO (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- virbr0 * 192.168.122.0/24 0.0.0.0/0
0 0 REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

Chain LIBVIRT_FWI (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
0 0 REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

Chain LIBVIRT_FWX (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- virbr0 virbr0 0.0.0.0/0 0.0.0.0/0

[root@centos8 ~]# systemctl stop firewalld(#关闭防火墙)
[root@centos8 ~]# iptables -vnL(#再来看一下差别)
Chain INPUT (policy ACCEPT 10 packets, 644 bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 5 packets, 524 bytes)
pkts bytes target prot opt in out source destination
[root@centos8 ~]#

-----------------------------

加上此条命令,下次开机不会自动启动防火墙

[root@centos8 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@centos8 ~]#

init 3关闭centSO8的图形化界面,运行内存也减小了

[root@centos8 ~]# init 3

 系统登录前的“欢迎”Welcome to kevin306.cn!“”提示

[root@centos8 ~]# cd /etc/issue.d/
[root@centos8 issue.d]# ls
cockpit.issue
[root@centos8 issue.d]# touch a.issue
[root@centos8 issue.d]# nano a.issue(#此处编辑内容Welcome to kevin306.cn!

[root@centos8 issue.d]# cat a.issue
Welcome to kevin306.cn!
[root@centos8 issue.d]#

系统登录后的“”祝福“Happy Every Day~.~”提示

[root@centos8 ~]# ls /etc/motd
/etc/motd
[root@centos8 ~]# cat /etc/motd
[root@centos8 ~]# ll /etc/motd
-rw-r--r--. 1 root root 0 Sep 10 2018 /etc/motd (#查看一下文件,发现是0大小,说明里面没有内容)
[root@centos8 ~]# cat /etc/motd(#查看此文件)
[root@centos8 ~]# nano /etc/motd(#编辑此文件键入Happy Every Day~.~
[root@centos8 ~]# cat /etc/motd
Happy Every Day~.~
[root@centos8 ~]# exit
logout

 

 20210701Renew

posted on 2021-01-14 20:42  熊猫小虾  阅读(320)  评论(0编辑  收藏  举报

导航