linux常用命令

1.  每过一秒执行一次cmd命令          watch -n 1  cmd 
 
2.  shell中统计cmd执行时间            time  cmd
 
3.  kill匹配出的进程号               
     ps -ef | grep fireball | grep -v grep | awk '{print $2}' | xargs kill
     kill `lsof -t -i:12301`     # 按端口查找进程号kill
 
4.  crontab配置 (分 时 日 月 周0-6) 
     0 8 * * * (source ~/.bash_profile && cd ~/xubc && ./load_to_wapstat.sh >> log/wap_stat.log 2>&1)
                      
5.  查看系统当前最大文件夹  
     du -m /var/lib/mysql/ | sort -n -r | head -n 20
 
6.  查看去重后的结果列 
     cat t.log | awk '{print  $2 $4 $5}' | uniq -c | wc -l
 
7.  vim编辑器    set nu   查看行号   set list 查看特殊字符
 
8.  curl发送http请求   
     curl  -A "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0"  -x  10.3.4.35:18080 -e "www.baidu.com"  -i "http://10.3.4.34/hello.html"
 
9.  root以某个用户身份执行命令
      su - zookeeper -c '/data0/zookeeper/app/zookeeper-3.4.6/bin/zkServer.sh status'
 
10. ssh远程执行shell命令
      ssh root@$hostname -nq "ps -ef | grep -w $topic | grep -v grep | wc -l"
 
11. 文件编码转换
      iconv -f utf-8 -t gb18030 /tmp/v_st_union_userinfoutf8.txt -o /tmp/v_st_union_userinfo.txt;
 
12.  scp传输文件,并限制带宽
      scp -r -l 4000 dw_dim_event_weight/  hive@10.0.4.54:~
 
13. 按时间和文件名删除文件
     find /tmp/hive -mtime +30 -name '*.pipeout' | xargs rm -f '*.pipeout'
 
14. 获取当前日期时间(天)
     dt=`date -d "now  1 days ago "  "+%Y%m%d"`
 
15. 运行脚本,重定向1>stdout, 2>stderr日志输出
     cd recommend && sh recommend-als-i2i-loupan.sh > logs/recommend-als-i2i-loupan.log 2>&1
 
16. 复制文件目录,不改变文件的privilege, owner, time属性拷贝
      cp -p /usr/local/hue/apps/oozie/src/oozie/templates/editor2/common_workflow.mako ~/templates
 
17. window文件转unix文件,并创建新的shell_unix.sh文件
     dos2unix -n shell_windows.sh shell_unix.sh
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值