Linux 常用命令与设置 (CentOS7)

CentOS7 最小化安装.也有近1个 G...830M

ifconfig 已经过时了。
改用“ip addr”和“ip link”命令来查找网卡详情。
要知道统计数据,可以使用“ip -s link”。

network is not running after installation ...

vi /etc/sysconfig/network-scripts/ifcfg-eth0s3
### edit=> ONBOOT="yes" 
systemctl restart network
bash:Bourne Again Shell(/bin/bash)
默认 Shell

```# 注释```
单行注释的写法

```echo $SHELL ```
当前 SHELL 的名称,例如:/bin/bash

```find / -name hell*```
从根目录开始,递归子目录,查找文件 hell*.*

软件包管理:
apt-get:Ubuntu.软件包管理工具
brew:macOS.apt-get...
yum:RedHat.apt-get...

yum -y install net-tools
yum -y install docker
yum -y install go

systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

任务  旧指令 新指令
使某服务自动启动    chkconfig –level 3 httpd on systemctl enable httpd.service
使某服务不自动启动   chkconfig –level 3 httpd off    systemctl disable httpd.service
检查服务状态  service httpd status    systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务  chkconfig –list systemctl list-units –type=service
启动某服务   service httpd start systemctl start httpd.service
停止某服务   service httpd stop  systemctl stop httpd.service
重启某服务   service httpd restart   systemctl restart httpd.service

//centos 查看所有运行中的服务的详细信息命令:
netstat -tunpl
ps -aux | grep YourKeyWordToSearch


Q:how to know OS Name?

lsb_release -a
cat /etc/os-release
cat /etc/redhat-release


Q:How to show disk space?
A:```df``` NOT ```dd```.

Q:df only show one disk. how to show another bigger disk?
A:```fdisk -l```

Q:如何限制一个命令执行的时间?
```timeout 1s ls```

SSH.DSA
---
Your identification has been saved in /root/.ssh/id_rsa.   
Your public key has been saved in /root/.ssh/id_rsa.pub.

dsa is not supported by default.

To compatible dsa, you need to add below line:
```PubkeyAcceptedKeyTypes +ssh-dss```
into your ~/.ssh/config

cat ~/.ssh/config
PubkeyAcceptedKeyTypes +ssh-dss

DNS:
---

//to set dns:
sudo su -
nmcli con mod enp4s0 ipv4.dns "202.99.192.66 202.99.192.68 8.8.4.4 8.8.8.8"
nmcli con up enp4s0

nmcli dev show enp4s0

# 在shell 中,将某个文件复制成一百个文件
for (( i=1; i<=100; i++ ))  
do
    cp bg.jpg bg$i.jpg
done

你可能感兴趣的:(Linux 常用命令与设置 (CentOS7))