common commands on Linux

本文提供了一系列常用命令的快速查阅指南,包括Tibco EMS管理命令、系统资源监控工具sar、Java类版本检查、文件操作命令如tar和jar、以及文件搜索命令grep等,适用于日常运维及开发工作。

#### Tibco ems admin commands

show consumers topic=topic.sample
show consumers queue="queuname"
show connections user="username"

 

#### sar

sar -W 1 100 : check swap in/out statistics

 

#### check java class version

$ file ./org/apache/log4j/Appender.class
./org/apache/log4j/Appender.class: compiled Java class data, version 45.3
Or alternatively, using javap from the JDK as @jikes.thunderbolt aptly points out:

$ javap -v ./org/apache/log4j/Appender.class | grep major
major version: 45
And if you are relegated to a Windows environment without either file or grep

> javap -v ./org/apache/log4j/Appender.class | findstr major
major version: 45

 

#### java

## to check if a 64 bit java

java -d64

java -d32

 

#### jar

## Create jar file
jar cvf test.jar 1.txt 2.txt

or put 1.txt and 2.txt into test folder, then:

jar cvf test.jar test/*

## extract jar file

jar xf test.jar

It will extract all the files from test.jar and keep all the current directory structure.

so you will see:
test/1.txt
test/2.txt


Suppose you want to extract the TicTacToe class file and the cross.gif image file. To do so, you can use this command:

jar xf test.jar 1.txt

then it will just extract 1.txt from test.jar and put it under test/1.txt.


e.g. you have below jar and it's class file included in the jar:

[lofutpd1@lonlx1060b01:~/release/UTP7.1.0/lib]$ /local/0/sw/java/jdk1.6.0_30/bin/jar tf reconciliation-common-UTP7.1.0.jar | grep DateTime
com/nomura/fitp/reconciliation/DateTimeFormatFilter.class
[lofutpd1@lonlx1060b01:~/release/UTP7.1.0/lib]$

SOmetimes you want to replace that class file in order to test your new fix, you want to replace the class file with newly build class file, so you can do:

/local/0/sw/java/jdk1.6.0_30/bin/jar uf reconciliation-common-UTP7.1.0.jar com/nomura/fitp/reconciliation/FloatValueFormatFilter.class com/nomura/fitp/reconciliation/DateTimeFormatFilter.class


#### grep

1. Only show the matched part
ps -ef | grep service | grep [processUser] | grep -oh "\processname=\w*"

2. Exclude pattern

grep -v 'pattern'

3. Case insensitive

grep -i

4. include the file name in the grep commands

grep -n 'pattern' file /dev/null


#### tar

tar -cvjf a.tar a.html
tar -xvjf a.tar

-z : gzip(quicker but larger)
-j : bzip2(slower but smaller)


#### ls

ls -lh : human readable size

ls -sSl --block-size=M : sort by size and displayed in mega bytes

ls -sSr --block-size=M : sort by size but displayed in the reverse order, and displayed in mega bytes

use top together with free command:

#### free
free -g
free -m


#### du

du -ah --max-depth=1 : not just directories but also files
du -h --max-depth=1 : just directories

 

#### wget

wget to get the content of some web page

e.g. wget http://hostname:/directory/filename.txt

转载于:https://www.cnblogs.com/glf2046/p/6510470.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值