-
补充
/etc/hostname :CenOS7主机名配置文件
[root@oldboyedu ~]# cat /etc/hostname oldboyedu
/etc/sysconfig/network C6主机名配置文件
[root@oldboy ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=oldboy
-
修改主机名
-
永久生效
[root@oldboyedu ~]# hostnamectl set-hostname oldboy [root@oldboyedu ~]# hostname oldboy
-
临时改一下
[root@oldboyedu ~]# hostname sun [root@oldboyedu ~]# hostname sun
-
/etc/sysctl.conf Linux内核参数信息文件※※※※※
调整Linux系统、优化需要配置这个文件
sysctl -p 让修改后的文件生效
-
一、/usr目录 用户相关
1、 /usr/local:源码编译安装软件默认的位置路径
- 软件安装(了解):
- rpm安装
- rpm -ivh 软件包的包名.rpm(几乎不用)
- yum安装,rpm包管理器,智能帮我们找一个软件包需要的依赖包(推荐)
- 本质就是rpm安装。自动解决依赖,自动使用rpm命令实现安装。
- 源代码安装。
- rpm安装
2./usr/src:存放源码文件的目录
二、/var/目录 Linux记录各种日志目录
1./var/log:记录系统及软件运行信息文件所在的目录
log日志信息====计算机运行行为
2./var/log/messages:Linux系统级别日志文件*****
记录Linux系统运行行为的文件,正常行为 非正常行为。
[root@oldboyedu ~]# tail /var/log/messages
Apr 7 19:22:12 oldboyedu NetworkManager[1134]: <info> [1586258532.0068] policy: set-hostname: set hostname to 'oldboy' (from system configuration)
Apr 7 19:22:12 oldboyedu dbus[887]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Apr 7 19:22:12 oldboyedu systemd: Starting Network Manager Script Dispatcher Service...
Apr 7 19:22:12 oldboyedu systemd-hostnamed: Changed host name to 'oldboy'
Apr 7 19:22:12 oldboyedu dbus[887]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr 7 19:22:12 oldboyedu systemd: Started Network Manager Script Dispatcher Service.
Apr 7 19:22:12 oldboyedu nm-dispatcher: req:1 'hostname': new request (2 scripts)
Apr 7 19:22:12 oldboyedu nm-dispatcher: req:1 'hostname': start running ordered scripts...
Apr 7 19:22:12 oldboyedu nm-dispatcher: req:2 'hostname': new request (2 scripts)
Apr 7 19:22:12 oldboyedu nm-dispatcher: req:2 'hostname': start running ordered scripts...
3./var/log/secure:用户登录信息日志文件(安全日志文件)
[root@oldboyedu ~]# tail /var/log/secure
Apr 7 19:19:55 oldboyedu polkitd[880]: Loading rules from directory /usr/share/polkit-1/rules.d
Apr 7 19:19:55 oldboyedu polkitd[880]: Finished loading, compiling and executing 2 rules
Apr 7 19:19:55 oldboyedu polkitd[880]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Apr 7 19:19:58 oldboyedu sshd[1489]: Server listening on 0.0.0.0 port 22.
Apr 7 19:19:58 oldboyedu sshd[1489]: Server listening on :: port 22.
Apr 7 19:20:05 oldboyedu sshd[3398]: reverse mapping checking getaddrinfo for bogon [10.0.0.1] failed - POSSIBLE BREAK-IN ATTEMPT!
Apr 7 19:20:05 oldboyedu sshd[3398]: Accepted password for root from 10.0.0.1 port 53921 ssh2
Apr 7 19:20:05 oldboyedu sshd[3398]: pam_unix(sshd:session): session opened for user root by (uid=0)
Apr 7 19:22:11 oldboyedu polkitd[880]: Registered Authentication Agent for unix-process:9178:14338 (system bus name :1.23 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Apr 7 19:22:12 oldboyedu polkitd[880]: Unregistered Authentication Agent for unix-process:9178:14338 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
4./var/log/dmesg:记录硬件信息加载情况的日志文件
[root@oldboyedu ~]# tail /var/log/dmesg
[ 5.706282] cryptd: max_cpu_qlen set to 1000
[ 5.811659] AVX2 version of gcm_enc/dec engaged.
[ 5.811662] AES CTR mode by8 optimization enabled
[ 5.850428] Adding 786428k swap on /dev/sda2. Priority:-2 extents:1 across:786428k FS
[ 5.869213] XFS (sda1): Mounting V5 Filesystem
[ 6.104993] alg: No test for __gcm-aes-aesni (__driver-gcm-aes-aesni)
[ 6.110197] alg: No test for __generic-gcm-aes-aesni (__driver-generic-gcm-aes-aesni)
[ 6.122383] XFS (sda1): Ending clean mount
[ 6.336590] ppdev: user-space parallel port driver
[ 6.642353] type=1305 audit(1586258394.437:4): audit_pid=792 old=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
- 对应命令dmesg
三、/proc下的重要路径知识
1./proc/meminfo 查系统内存
[root@oldboyedu ~]# cat /proc/meminfo
MemTotal: 3861320 kB
MemFree: 3484452 kB
MemAvailable: 3449064 kB
Buffers: 2076 kB
Cached: 151372 kB
SwapCached: 0 kB
Active: 113984 kB
Inactive: 108704 kB
Active(anon): 69920 kB
Inactive(anon): 11140 kB
Active(file): 44064 kB
Inactive(file): 97564 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 786428 kB
SwapFree: 786428 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 69264 kB
Mapped: 27244 kB
Shmem: 11820 kB
Slab: 68860 kB
SReclaimable: 27848 kB
SUnreclaim: 41012 kB
KernelStack: 3776 kB
PageTables: 4372 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2717088 kB
Committed_AS: 269960 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 185700 kB
VmallocChunk: 34359310332 kB
HardwareCorrupted: 0 kB
AnonHugePages: 8192 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 89920 kB
DirectMap2M: 3055616 kB
DirectMap1G: 3145728 kB
-
对应命令:free
[root@oldboyedu ~]# free total used free shared buff/cache available Mem: 3861320 195676 3484348 11820 181296 3448960 Swap: 786428 0 786428 [root@oldboyedu ~]# free -m #以兆显示 total used free shared buff/cache available Mem: 3770 191 3402 11 177 3368 Swap: 767 0 767
2./proc/cpuinfo 查看CPU
[root@oldboyedu ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
stepping : 3
microcode : 0x25
cpu MHz : 3199.073
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 6398.14
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management:
3./proc/loadavg 查看负载(系统繁忙程度的一个综合指标)
[root@oldboyedu ~]# cat /proc/loadavg
0.00 0.02 0.05 2/110 9288
-
对应命令:uptime
[root@oldboyedu ~]# uptime 19:35:30 up 15 min, 1 user, load average: 0.00, 0.02, 0.05 系统时间 启动状态 开机时间 登入用户 平均负载 1分钟 5分钟 15分钟
4、/proc/mounts 当前设备挂载列表信息文件
[root@oldboyedu ~]# tail /proc/mounts
cgroup /sys/fs/cgroup/cpuset cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpuset 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/sda3 / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=31,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13527 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
/dev/sda1 /boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=386132k,mode=700 0 0
四、CentOS6启动流程
五、CentOS7启动流程
六、vi/vim编辑器
普通模式:
:set nu 显示行号
普通模式:移动光标:
行尾 $
行首 0
文件尾部 G
文件开头 gg
到指定行 阿拉伯数字gg
普通模式:搜索与替换操作
向下搜索 /3306 继续搜 按n,反向搜N
向上搜索 ?80 继续搜 按n,反向搜N
普通模式:替换
:%s/A/B/g
:%s#world#oldgirl#g
/#还可以用@等特殊字符替换,实际就是分隔符。
s是替换 g表示全局(所有)
指定行号替换:
:4,6s/oldboy/oldgirl/g
普通模式:复制、粘贴、删除等操作
删除单行 dd(剪切)
删除多行 ndd n用任意数字替换
撤销 u
单行复制 yy
多行复制 nyy n用任意数字替换
粘贴 p
进入编辑模式命令
i 插入*****
A 追加 行尾插入
o 下一行开头插入
O 上一行开头插入
a 光标下一个字符插入
命令行模式
:wq 退出并保存
:wq! 退出并强制保存,“!”为强制的意思
:q! 强制退出,不保存
:set nu 显示行号
:set nonu 与set nu相反,取消行号
七、命令
1、cat 查看文件内容
[root@oldboyedu ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
stepping : 3
microcode : 0x25
cpu MHz : 3199.073
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
2.head查看文件开头(默认前10行)
- -n查看多少行
[root@oldboyedu ~]# seq 30 >test.txt
[root@oldboyedu ~]# cat test.txt
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@oldboyedu ~]# head -n 5 test.txt
1
2
3
4
5
3.tail 查看文件尾部(默认最后10行)
- -n查看多少行
[root@oldboyedu ~]# tail test.txt
21
22
23
24
25
26
27
28
29
30
[root@oldboyedu ~]# tail -n 5 test.txt
26
27
28
29
30
- -f 动态查看(用于查看Linux日志文件)
[root@oldboyedu ~]# tail -f test.txt
21
22
23
24
25
26
27
28
29
30
4.tac按行翻转文件内容(和cat相反)
5.rev左右按字符翻转行的内容
来源:oschina
链接:https://my.oschina.net/u/4360442/blog/3224978