Linux常用命令

linux 常用命令

查看linux服务器信息

cat /etc/redhat-release```

### Linux 查询根目录下哪些文件中包含某个字符串

`````bash
shell
find / -type f -name "*.sh" | xargs grep "kyjkappprd"

Linux 给普通用户赋予root权限

修改 /etc/sudoers 文件,在文件中添加

shell
## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL
wuhm   ALL=(ALL)     ALL

根据运用名称查看端口号

ps -aux | grep redis```

### 删除 `/usr/local` 目录下`30`天之前的后缀名是`log`的文件
`````bash
shell
find /usr/local -mtime +30 -name *.log -exec rm -rf {} \;

==注意有些时候*.log需要转义–> \*.log==

远程复制文件

shell
scp -r /home/wuhm/test/ root@192.168.1.100:/root/

查看当前目录及其子目录磁盘大小

du -ah --max-depth=1```

### 查看目录下有多少个文件
```shell
ls result/ -l | grep "^-" | wc -l```