操作前准备:安装WindTerm软件、安装好CentOS7系统
一、用WindTerm打开CentOS7系统
让CentOS7系统在WindTerm运行,操作比较流畅,没有那么卡
1、使用CentOS7系统的root用户:连接有线网络,打开终端(鼠标右键)
2,在终端输入"ip a"查找自己的ip(记住)→点击系统右边的“×”→在后台
运行

3打开WindTerm软件→点击会话→新建会话→SSH→主机和标签都输入自己的ip→连接→Account→输入用户root→下次自动登录→输入密码(自己设置的密码)→回车键
二、命令行基础
1.type命令
查看命令是内嵌命令还是外置命令,内置命令是不可以卸载掉的(自带的命令),外置命令(ls)是可以卸载掉的
[root@bogon ~]# type cd cd 是 shell 内嵌 [root@bogon ~]# type pwd pwd 是 shell 内嵌 [root@bogon ~]# type ls ls 是 `ls --color=auto' 的别名
2.命令补齐(Tab键)
任意输入字母,按两下Tab键,会出现补齐带输入字母的命令,可以快速输入指令
[root@bogon ~]# sys sysctl systemd-coredumpctl systemd-nspawn system-config-abrt systemd-delta systemd-path system-config-printer systemd-detect-virt systemd-run system-config-printer-applet systemd-escape systemd-stdio-bridge systemctl systemd-firstboot systemd-sysv-convert systemd-analyze systemd-hwdb systemd-tmpfiles systemd-ask-password systemd-inhibit systemd-tty-ask-password-agent systemd-cat systemd-loginctl sys-unconfig systemd-cgls systemd-machine-id-setup systemd-cgtop systemd-notify
3.命令帮助
man最为常用
[root@bogon ~]# man ls LS(1) General Commands Manual LS(1) NAME ls, dir, vdir - 列目录内容 提要 ls [选项] [文件名...] POSIX 标准选项: [-CFRacdilqrtu1] GNU 选项 (短格式): [-1abcdfgiklmnopqrstuxABCDFGLNQRSUX] [-w cols] [-T cols] [-I pattern] [--full-time] [--format={long,verbose,commas,across,vertical,single-column}] [--sort={none,time,size,extension}] [--time={atime,access,use,ctime,status}] [--color[={none,auto,always}]] [--help] [--version] [--] 描述( DESCRIPTION ) 程序ls先列出非目录的文件项,然后是每一个目录中的“可显示”文件。如果 没有选项之外的参数【译注:即文件名部分为空】出现,缺省为 "." (当前目录)。 选项“ -d ”使得目录与非目录项同样对待。除非“ -a ” 选项出现,文 件名以“.”开始的文件不属“可显示”文件。 …… 退出按Q键
help
help 后面不能接外置指令,可以接内嵌指令,但可以后面接help(ls --help)
[root@bogon ~]# help ls -bash: help: 没有与 `ls' 匹配的帮助主题。尝试 `help help' 或者 `man -k ls' 或者 `info ls'。 [root@bogon ~]# help cd cd: cd [-L|[-P [-e]]] [dir] Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable. The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. If the directory is not found, and the shell option `cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR.
[root@bogon ~]# ls --help 用法:ls [选项]... [文件]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all 不隐藏任何以. 开始的项目 -A, --almost-all 列出除. 及.. 以外的任何项目 --author 与-l 同时使用时列出每个文件的作者 -b, --escape 以八进制溢出序列表示不可打印的字符 --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first
三、系统基本操作命令
1.cd
切换目录
..:上一级目录
cd ..:返回当前目录的上一级目录
[root@bogon ~]# cd ..
2.hostname
查看主机名
hostname:查看主机名
hostname huang:把主机名更改为huang,但因为终端打开了,所以主机名没变
[root@bogon etc]# hostname bogon [root@bogon etc]# hostname huang [root@bogon etc]# hostname huang
bash:刷新新的输入终端(但旧的输入终端没有消失,只是被新的终端覆盖住了)
exit:退出
这种方法是临时的,重启失效
[root@bogon etc]# bash [root@huang etc]# [root@huang etc]# [root@huang etc]# exit exit [root@bogon etc]# [root@bogon etc]# [root@bogon etc]# bash [root@huang etc]#
hostnamectl set-hostname:永久更改
hostnamectl set-hostname huang:主机名永久更改为huang
[root@huang etc]# hostnamectl set-hostname huang [root@huang etc]# [root@huang etc]#
3.ifconfig
网卡名称
查看自己的网卡参数,默认网卡名称:ens33
[root@huang etc]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.58.134 netmask 255.255.255.0 broadcast 192.168.58.255 inet6 fe80::8fd6:2e37:77aa:b5a7 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:45:91:19 txqueuelen 1000 (Ethernet) RX packets 11227 bytes 939497 (917.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 24314 bytes 33096752 (31.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifconfig 网卡名称
ifconfig ens33:查看指定名ens33用户的网卡信息
[root@huang etc]# ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.58.134 netmask 255.255.255.0 broadcast 192.168.58.255 inet6 fe80::8fd6:2e37:77aa:b5a7 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:45:91:19 txqueuelen 1000 (Ethernet) RX packets 11894 bytes 997763 (974.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 25898 bytes 35229558 (33.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ip a:也是查看自己的网卡参数,包括未启用的
[root@huang etc]# 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 pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:45:91:19 brd ff:ff:ff:ff:ff:ff inet 192.168.58.134/24 brd 192.168.58.255 scope global noprefixroute dynamic ens33 valid_lft 1482sec preferred_lft 1482sec inet6 fe80::8fd6:2e37:77aa:b5a7/64 scope link noprefixroute
4.cat
打印所处目录的绝对路径
cat /proc/cpuinfo:查看CPU信息
lscpu:查看CPU信息
[root@huang ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 186 model name : 13th Gen Intel(R) Core(TM) i5-13500H stepping : 2 microcode : 0x4114 cpu MHz : 3187.205 cache size : 18432 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 32 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 rep_good 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 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 arat umip pku ospke gfni vaes vpclmulqdq movdiri movdir64b md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities bogomips : 6374.41 clflush size : 64 cache_alignment : 64 address sizes : 45 bits physical, 48 bits virtual power management:
[root@huang ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 座: 1 NUMA 节点: 1 厂商 ID: GenuineIntel CPU 系列: 6 型号: 186 型号名称: 13th Gen Intel(R) Core(TM) i5-13500H 步进: 2 CPU MHz: 3187.205 BogoMIPS: 6374.41 超管理器厂商: VMware 虚拟化类型: 完全 L1d 缓存: 48K L1i 缓存: 32K L2 缓存: 1280K L3 缓存: 18432K NUMA 节点0 CPU: 0 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 rep_good 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 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 arat umip pku ospke gfni vaes vpclmulqdq movdiri movdir64b md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
cat /proc/meminfo:查看内存信息
lsmem:查看内存信息
[root@huang ~]# cat /proc/meminfo MemTotal: 1863000 kB MemFree: 350460 kB MemAvailable: 854684 kB Buffers: 1084 kB Cached: 628592 kB SwapCached: 0 kB Active: 549504 kB Inactive: 530352 kB Active(anon): 451052 kB Inactive(anon): 13076 kB Active(file): 98452 kB Inactive(file): 517276 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Dirty: 4 kB Writeback: 0 kB AnonPages: 450200 kB Mapped: 138968 kB Shmem: 13948 kB Slab: 103196 kB SReclaimable: 39164 kB SUnreclaim: 64032 kB KernelStack: 10816 kB PageTables: 35956 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3028648 kB Committed_AS: 3923300 kB VmallocTotal: 34359738367 kB VmallocUsed: 221756 kB VmallocChunk: 34359277564 kB Percpu: 56320 kB HardwareCorrupted: 0 kB AnonHugePages: 124928 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 114560 kB DirectMap2M: 1982464 kB DirectMap1G: 0 kB
[root@huang ~]# lsmem RANGE SIZE STATE REMOVABLE BLOCK 0x0000000000000000-0x0000000007ffffff 128M online 否 0 0x0000000008000000-0x000000000fffffff 128M online 是 1 0x0000000010000000-0x0000000067ffffff 1.4G online 否 2-12 0x0000000068000000-0x000000006fffffff 128M online 是 13 0x0000000070000000-0x000000007fffffff 256M online 否 14-15 Memory block size: 128M Total online memory: 2G Total offline memory: 0B
free -m:查看内存使用情况
[root@huang ~]# free -m total used free shared buff/cache available Mem: 1819 824 341 13 653 834 Swap: 2047 0 2047
5.df
查看磁盘使用情况
df -Th:查看磁盘使用情况
[root@huang ~]# df -Th 文件系统 类型 容量 已用 可用 已用% 挂载点 devtmpfs devtmpfs 894M 0 894M 0% /dev tmpfs tmpfs 910M 0 910M 0% /dev/shm tmpfs tmpfs 910M 11M 900M 2% /run tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root xfs 50G 4.2G 46G 9% / /dev/mapper/centos-home xfs 147G 33M 147G 1% /home /dev/sda1 xfs 1014M 185M 830M 19% /boot tmpfs tmpfs 182M 24K 182M 1% /run/user/0
6.关机命令
poweroff(有60s缓冲期,poweroff --now马上关机)
shutdown --now(shutdown -r重启)
init 0(init 6重启)
7.重启命令
reboot
shutdown -r
init 6
8.查看目录内容
dir(常用于wondows)
ls(常用于Linux)
9.打印所处目录的绝对路径
pwd
看过感觉有帮助的,麻烦动动发财的小手,给博主点个赞