记录一些linux命令

1 查询某个yum源安装了哪些包
yum install yum-utils
yumdb search from_repo bar

2 查看哪些包依赖krb5-libs
repoquery --requires krb5-libs

3 利用xargs -n 1,解压多个tar文件
echo *.tgz | xargs -n 1 tar xf

4 利用tee和exec,将一个脚本中所有的输出额外添加到文件中
exec &> >(tee -a "bar.log")
echo "This will be logged to the file and to the screen"
这里利用进程替换创建了pipe,利用exec将输出重定向到了pipe

5 特定yum源不使用代理
设置proxy=_none_

6 mount smb文件系统时使用特定uid和gid
sudo mount -t cifs //10.4.130.10/smarket /mnt/smb -o user=ci,passwd=ttylnbz,uid=500,gid=500

7 用top命令看所有mongod的状态
top -p $(pidof mongod | tr ' ' ',')

8 设置系统时间
date -s "20070414 13:58:00"

9 修改hostname
hostname $(cat /etc/sysconfig/network | grep HOSTNAME | cut -d '=' -f 2)

10 kafka查看offset
./bin/kafka-run-class.sh kafka.tools.GetOffsetShell

11 为用户添加sudo权限
echo "ci ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ci

猜你喜欢

转载自kabike.iteye.com/blog/2296409