zoukankan      html  css  js  c++  java
  • 经常用到的一些命令行

    一、查找特定文件并对其执行指令
    find -name ".svn" -exec rm -rf {} ;
    find -type file -exec chmod -x {} ;

    find忽略 Permission Denied信息
    find / -name source 2>/dev/null

    二、清除所有文件名里的空格
    ls|while read i;do mv "$i" $(echo $i|tr -d ' ') 2>/dev/null;done

    三、临时http服务器
    python -m SimpleHTTPServer

    四、ps列表中排除grep进程
    ps -ef|grep java|grep -v grep

    五、后台执行
    nohup command>file.out 2>&1 &
    nohup /opt/jre1.6.0_43/bin/java -jar ~/myjavapackage.jar > ~/myjavapackage.out 2>&1 &

    六、把别人踢出去:
    #pkill -kill -t tty
    #pkill -kill -t pts/1
    另外也可以使用skill命令。如
    #skill -KILL -t pts/1  能达到同样的效果。
    #skill -STOP -u user1
    #skill -KILL -u user1  杀死并注销user1。

    七、CentOS visudo, 允许users组用户关机、重启、管理mysqld服务
    ## Allows members of the users group to shutdown this system
    # %users  localhost=/sbin/shutdown -h now
    %users ALL=NOPASSWD: /sbin/shutdown, /sbin/service mysqld restart, /sbin/service mysqld start, /sbin/service mysqld status, /sbin/service mysqld stop


    八、进程管理程序包procps包含的指令:
    free, kill, pkill, pgrep, pmap, ps, pwdx, skill, slabtop, snice, sysctl, tload, top, uptime, vmstat, w, and watch


    九、文件压缩/解压缩:

    1、查找rar文件并用7z解压缩
    find -type f -iname "*.rar" -exec 7z x -y {} ;

    2、解压缩中文rar,转换文件名编码
    unrar file.rar
    convmv */*.* -f gb2312 -t utf8 --notest

    3、解压缩中文ZIP
    unzip -O GBK 文件.zip

    4、用7z建立带密码的zip文件
    $ 7z a -p12345678 afolder.zip afolder/

    5、归档tomcat log文件
    #!/bin/bash
    thedate=`date --rfc-3339=date`
    /opt/tomcat/bin/shutdown.sh
    killall -9 java
    mv /opt/tomcat/logs/catalina.out /opt/tomcat/logs/catalina.out.${thedate}
    /opt/tomcat/bin/startup.sh
    tar -zcf /opt/tomcat6/logs/catalina.out.${thedate}.tar /opt/tomcat6/logs/catalina.out.${thedate} --remove-files


    十、Ubuntu指令历史记录设置,忽略重复的和空格开头的指令,history命令结果里增加日期时间。
    ~/.bashrc

    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    HISTCONTROL=ignoreboth

    # append to the history file, don't overwrite it
    shopt -s histappend

    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=100
    HISTFILESIZE=2000
    HISTTIMEFORMAT="%F %T "
    .....
    # some more ls aliases(用2013-11-24 11:28格式显示日期时间,  =full-iso =long-iso =iso =locale)
    alias ll='ls -alF --time-style=long-iso'


    手工清除历史记录
    rm -rf ~/.config/smplayer/file_settings/*
    rm -rf ~/.thumbnails/*
    rm -rf ~/.local/share/Trash/files/*
    rm -rf ~/.local/share/Trash/info/*
    rm -f ~/.local/share/zeitgeist/activity*
    rm -f ~/.local/share/recently-used.xbel
    rm -f ~/.bash_history


    十一、rdesktop
    快速打开Windows远程桌面(启用压缩、颜色深度15位、Console会话)
    r.sh
    #!/bin/bash
    rdesktop -z -a 15 -0 -u administrator -p Your_Password $1 $2 &

    例,全屏模式打开 192.168.1.10 (Ctrl+Alt+Enter跳出全屏)
    $ sh r.sh 192.168.1.10 -f

    快速打开若干Windows远程桌面
    rdps.sh
    #!/bin/bash
    rdesktop -z -a 15 -0 -u administrator -p Your_Password1 192.168.1.1 &
    rdesktop -z -a 15 -0 -u administrator -p Your_Password2 192.168.1.2 &
    rdesktop -z -a 15 -0 -u administrator -p Your_Password3 192.168.1.3 &


    十二、获取文本中某一行,显示一行中的某一列,例如:
    $ ifconfig|grep eth0
    eth0      Link encap:以太网  硬件地址 90:c1:3c:91:b1:30

    $ ifconfig|awk '/^eth0/ {print $5}'
    90:c1:3c:91:b1:30




  • 相关阅读:
    how to pass a Javabean to server In Model2 architecture.
    What is the Web Appliation Archive, abbreviation is "WAR"
    Understaning Javascript OO
    Genetic Fraud
    poj 3211 Washing Clothes
    poj 2385 Apple Catching
    Magic Star
    关于memset的用法几点
    c++ 函数
    zoj 2972 Hurdles of 110m
  • 原文地址:https://www.cnblogs.com/panblack/p/everyday_commandline_tips.html
Copyright © 2011-2022 走看看