Centos entry to master command collection

Centos commonly used command collection

1. Commonly used basic commands

command effect
ifconfig View IP address
ping 主机地址/域名 Check if the network is open
init 3 Enter command line mode (close graphical interface)
init 5 Enter the graphical interface
pwd View the current path (/root is the home directory)
touch a.c Create ac file
rm a.c Delete ac file/directory
rm a.c -rf Force deletion of ac files/directories
mkdir abc Create abc directory
cp 文件名.后缀 /tmp 新文件 Copy files to the tmp directory
cd /tmp Switch to the tmp directory ( cd /switch to the root directory)
mv a.c b.c Modify file name
cat 文件/目录 View file/directory
vi(vim) 文件 Edit file (:q to exit, :wq to save and exit)

2. Explanation of files in the root directory

Directory (file) Explanation
bin / sbin application
boot Organizational directory related to system booting and system
dev Equipment name
etc Files related to configuration
home User's home directory
lib / lib64 Repository files
root Super Administrator Home Directory
run Files related to program operation
tmp Temporary data
usr Installer
where Variable length file (log)

3. Common commands for text editors

command effect
cp 文件 /路径 新文件 Copy the file to that location and name it
vi / vim 文件 Edit file
cat 文件/目录 View file/directory

Commonly used commands under ESC not editable:

command effect
/查找的字符 Find characters
n Look down
N Look up
i Switch mode
del两下 Delete the current cursor line
yy Copy current line
d Paste the current line
x Delete the character under the cursor
:ser number/nonumber The line number of the text is listed/closed
:行号 Cursor to line number
:%s/旧/新 Replace old characters with new
:w Write
:q drop out
:wq Save and exit
:q! Force exit (do not save)
D Switch to tail
gg First line
u restore

4. Commands related to users, groups, and permissions

user:

command effect
useradd xxx Add xxx user
vipw View users (Z switches to the end)
userdel xxx Delete xxx user

group:

command effect
groupadd xxx Add xxx group
vigr View group (Z switches to the end)
group xxx Delete group xxx

User and group interaction:

command effect
gpasswd -a 用户名 xxx Add user to xxx group
groups 用户名 Check which group the user is in
whoami View current users
su - xxx Switch to xxx user
exit Exit the current user (only those who have actively switched)
id xxx View the xxx user ID (the smaller the id, the greater the authority)

Permissions:

command effect
chmod 777 xxx The permission to modify xxx is the highest permission 777 (4 readable, 2 writable, 1 executable. 6 read and write, 3 writable and executable, 5 readable and executable)
chmod 764 文件名 Give file permissions 764 (7 gives users all permissions, 6 permissions for their group, only 4 permissions)
ll View detailed information (r is readable; w is writable; x is executable; )[Note: -re-r—wx means that you have 1.rw permission, group 2 has r permission; 3 other users have wx permission]
chown root a.c Change the ac file belongs to the root user
chgrp 组名 文件名 Change the group name the file belongs to
chown abc.ccnp a.c -RF At the same time change the user and group names to which ac belongs (-RF mandatory)

5. 进程相关命令

命令 作用
ps -ef 查看进程
ps -ef |grep firewlld 查看跟firewlld相关的进程
which firewalld 查看firewalld涉及到的可执行程序
kill -cont 进程号 程序继续运行
kill - stop 进程号 暂停运行
kill 进程号 删除该进程号的程序
kill -9 进程号 强制删除
pkill 进程名称 中断命令
chmod +x 文件名 为文件添加可执行权限(绿色为可执行)
文件名 & 后台执行
jobs 查看当前有那些进程(不包括系统进程)
fg %进程号 将后台切换为前台

tips: .sh的文件为脚本文件
进程中的栏目释义:

  • UID:运行进程的用户
  • PID:进程ID号
  • PPID:父进程
  • STIME:进程开始运行的时间
  • TTY那个终端上运行的
  • TIME:进程占用CPU的时间
  • CMD:进程的名称

6. 网络操作相关命令

命令 作用
ifconfig 查看网络相关信息
ifconfig 网卡的名称:1 地址 添加网卡配置(重启无效)
/etc/sysconfig/net-scr/ ifcfg 网卡配置相关信息
nmtui 配置网卡
netstat -tlunp 系统打开的那些端口
etc/services 端口对应的服务(:端口号查找)
route 查看路由相关信息
wget url地址 下载文件
scp 文件名 用户@地址:/路径 将本地文件上传到对方
hostname 查看当前主机名
hostname 主机名 修改主机名(当前生效,永久见配置)
ping 域名 获得该域名的IP地址
nslookup 域名 查询域名所对应的IP地址
/etc/host 可以修改IP地址对应的域名
ssh ip地址 登录地址(exit退出登录)
/etc/resolv.conf 修改ip地址

7. 常用系统管理与本地YUM软件仓库搭建:

命令 作用
shutdown -r 重启
init 重启(0 关闭)
shutdown -h 时间 指定关机时间
mount /dev/cdrom xxx /目录 挂载光盘
umount /路径 卸载光盘
df -h 查看光盘挂载情况
free 查看内存情况(total:总量,used:使用的,free:空闲。Swap:虚拟内存,Mem:物理内存)
top 查看CPU利用率(退出q)
cal 查看当前日历
cal 年份 查看指定年份的日历
date 月份日期时间年份(03061700年份) 查看指定时间日历
rpm -aq 列出系统中所有安装的程序
rpm -aq |grep xxx 查看指定XXX是否安装
rpm -ivh 软件包名称 安装文件(比较麻烦)
rpm -e 软件包名称 删除软件包
rpm -p 软件包 查找软件包
rpm -Uvh 软件包 升级软件包

创建自己的YUM源:

tips: /etc/yum.repos.d/ 安装好存在该目录

  1. 进入到/etc/yum.repos.d/
  2. 创建一个文件夹备份(bak)
  3. 拷贝所有的文件到bak(cp *.repo bak/)
  4. 确保基础的yum已安装(rpm -aq |grep yum (确保安装))
  5. 生成自己的xxx.repo文件
  6. 文件模板模板
  7. 保存退出

yum常用命令:

命令 作用
yum clean all 清除yum缓存信息
yum list 查看软件仓库可以安装的软件包
yum list |grep zip 查看yum仓库与zip相关的软件包
yum remove 软件包名称 删除软件
yum install 软件包名称 -y -y忽略提示安装
yum update 软件包名称 升级软件包
yum list updates 列出可升级的软件包

Guess you like

Origin blog.csdn.net/weixin_45550881/article/details/105309236
Recommended