自用Linux常用命令

做个备份,以备不时之需 :D


//found all files end with bak and remove all these files
find -iname "*.bak" | xargs --no-run-if-empty rm

//check core file path
cat /proc/sys/kernel/core_pattern #//sysctl kernel.core_pattern

//retrieve content of keyword before & after 5 line
grep -A5 -B5 'keyword.*' $log | less


//diff file in linux
for file in $(ls $direcotry); do
str="$file"
#echo $str
#echo "===========$file";
diff <(sort $directory1) <(sort directory2) > out
done

cat a b | sort | uniq -u

//vi
crtl+f next page
crtl+b pre page
?word search word up
/word search word down
n: continue search the key
u: page up
gg:go to top
shift+g:go to end
#replace content -- replace abc with 123
%s#abc#123#g

//count file under specific path
ls -lR $directory | grep "^-" | wc -l
//count folder under specific path
ls -lR /$directory | grep "^d" | wc -l

//the 4th field splited by '|' in traget file and then count how many time this value appeared.
cut -d\| -f4 $fileName | uniq -c


//windows terminate hanging process
netstat -noa #find particular process id
taskkill /F /pid 8404

//grant particular user permission to tagret folder
setfacl -m u:username:rwx /temp

//add user
useradd -d /directory -g group chroot -s /bin/false username

//change password
echo username | passwd --stdin passwd


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值