常用命令归纳:Linux/Oracle/JVM/Git

经常用到一些命令,还总是忘掉的,就简单列在这里。总是现查也挺麻烦的。

Linux:

  • top mem consumer: sudo ps -aux | sort -k4nr | head -5 or top, then press M
  • connection number: netstat -an | grep ESTABLISHED | wc –l
  • process number: ps -ef | wc -l
  • threads of a process: ps uH p <pid> | wc -l
  • .tar: tar -xvf archive.tar and tar -cvf archive.tar file1
  • .tar.gz: tar -cvfz archive.tar.gz dir1 and tar -xvfz archive.tar.gz
  • .zip: zip -r archive.zip ./folder and unzip archive.zip -d ./
  • empty a file: sudo cat /dev/null
  • capture all the output and run in the background: bb > /tmp/a.txt 2>&1 &
  • list the latest changed files: ls -lht | head (log文件一大堆的时候用来找最新的)
  • check folder size: du -h –max-depth=1 ./ (磁盘空间不够的时候经常用来看谁是罪魁祸首)
  • search for 10M+ files: find . -size +10M
  • ssh -qTfnN -D 9999 username@hostname
  • ssh tunnel_host_name -L 60553:target_host_name:60553

Oracle:

  • SELECT CONVERT(DESCRIPTION, 'WE8ISO8859P1', 'UTF8') FROM TABLE_NAME;
  • TAB, ALL_TABLES, USER_TABLES
  • SELECT SEGMENT_NAME, BYTES FROM USER_SEGMENTS WHERE SEGMENT_TYPE = 'TABLE';
  • USER_USERS, USER_ROLE_PRIVS, SESSION_PRIVS;
  • ALL_INDEXES, USER_INDEXES
  • V$SESSION
  • 最大连接数:SELECT VALUE FROM V$PARAMETER WHERE NAME = 'PROCESSES';
  • 当前连接数:SELECT COUNT(1) FROM V$PROCESS;
  • 表空间:SELECT T.TABLESPACE_NAME, ROUND(SUM(BYTES/(1024*1024)),0) TS_SIZE FROM DBA_TABLESPACES T, DBA_DATA_FILES D WHERE T.TABLESPACE_NAME = D.TABLESPACE_NAME GROUP BY T.TABLESPACE_NAME;
  • 文件大小:SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, ROUND(BYTES/(1024*1024),0) TOTAL_SPACE FROM DBA_DATA_FILES ORDER BY TABLESPACE_NAME;
  • V$ROLLNAME, V$ROLLSTAT, V$UNDOSTAT, V$TRANSACTION

JVM:

  • Tomcat debug: -agentlib:jdwp=transport=dt_socket,address=8088,server=y,suspend=n
  • JProfiler: -agentpath:/opt/jprofiler7/bin/linux-x64/libjprofilerti.so=port=8080,nowait
  • JConsole: -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=3306 -Dcom.sun.management.jmxremote
  • Print default parameters: java -XX:+PrintFlagsFinal -version
  • jmap -histo <pid>
  • jmap -heap <pid>
  • jmap -permstat <pid>
  • jmap -dump:format=b,file=/xxx.hprof <pid>
  • jhat -baseline 1.hprof 2.hprof
  • jstack -l <pid>
  • jstat -gc <pid>
  • jstat -gccapacity <pid>
  • jstat -compiler <pid>
  • jstat -class <pid>
  • 另外,有一些JVM问题定位的工具,总结在这里
Git:
  • git clone <repo>
  • git config –list
  • git diff –staged
  • add后,commit前的撤销:git rm –cached
  • commit后的回滚:git reset –hard commit-id,比如:git reset –hard HEAD

 

文章未经特殊标明皆为本人原创,未经许可不得用于任何商业用途,转载请保持完整性并注明来源链接《四火的唠叨》

分享到:

2 comments

  1. 匿名 说道:

    error: did you mean `–list` (with two dashes ?)

发表评论

电子邮件地址不会被公开。

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Preview on Feedage: