Linux入門-命令練習 20210114幫助web
[root@localhost ~]# whatis
whatis what?
[root@localhost ~]# whatis rm (#查看功能)
rm (1) - remove files or directories
[root@localhost ~]# man -f rm (#查看功能)
rm (1) - remove files or directories
[root@localhost ~]# help history(內部命令查看幫助)shell
[root@centos8 ~]# date +%F_%T
2021-01-14_20:13:07centos
[root@centos8 ~]# date +%F-%T (#有個-)
2021-01-14-20:13:43
[root@centos8 ~]# date +"%F %T"(#沒有個-)
2021-01-14 20:13:55app
舉例:建立時間socket
[root@centos8 ~]# date +" %F %T" (#%前面多一個空格)
2021-01-14 20:16:20
[root@centos8 ~]# date +"%F %T"(#%前面多一個空格)
2021-01-14 20:16:24tcp
------------------------------oop
[root@centos8 ~]# date (#系統當前時間)
Thu Jan 14 20:36:28 CST 2021ui
[root@centos8 ~]# date 08082030.30 (#修改操做系統時間)
Sun Aug 8 20:30:30 CST 2021spa
-------------------------------操作系統
[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