常用Linux Command



1. 查找大于指定大小的文件

使用find命令找到大于指定大小的文件:

[root@localhost data]# find / -type f -size +10G

将输出:

/usr/local/apache2/logs/access_log

马上可以通过du命令查看此文件的大小:

[root@localhost data]# du -h /usr/local/apache2/logs/access_log
24G     /usr/local/apache2/logs/access_log

我们可以重复执行find命令来查找大文件,例如:find / -type f -size +5G 找到大于5G的文件。 find / -type f -size +1G 找到大于1G的文件

2. 在Linux下如何让文件夹下的文件让文件按大小排序?

有两种方法。

  • 方法一:# ls -lhSl 长格式显示,h human readable模式,大小单位为M,G等易读格式,S size按大小排序。
  • 方法二:# du -h * | sort -n

当然您也可以结合管道查看文件夹内最大的几个文件或最小的几个文件, 再加上管道符号和head或者tail命令即可du -h * | sort -n|head du -h * | sort -n|tail


1.    Kill process

ps -fu rcastdev |grep '/home/rcastdev/test-target' | grep -v grep | awk '{print $2}' | xargskill -9

2.    Find content

grep -rnw '/path/to/somewhere/' -e'pattern'

·        -r or -R is recursive,

·        -n is linenumber, and

·        -w stands formatch the whole word.

·        -l (lower-caseL) can be added to just give the file name of matching files.

 

3.    Find file in jar package

jar tf  ccar-reporting-server-1.0_A2.jar | grep"excel-sec-prod-xml.xml"

4.  压缩命令:

  命令格式:tar -zcvf   压缩文件名.tar.gz   被压缩文件名

      可先切换到当前目录下。压缩文件名和被压缩文件名都可加入路径。

5.  解压缩命令:

  命令格式:tar -zxvf   压缩文件名.tar.gz

解压缩后的文件只能放在当前的目录。

6.    Sftp upload file from local to linux server

Set PATH= C:\Program Files (x86)\SSHCommunications Security\SSH Tectia\SSH Tectia Client

sftp2 --password=pwd// username@hostName

cd /tmp

rm -r ccar.war

lcd C:\Users\sx\Downloads

put ccar-reporting-ui.war

cd/home/rcastdev/software/apache-tomcat-7.0.41/webapps

ps -fu rcastdev | grep tomcat | grep -v grep |awk '{print $2}' | xargs

kill -9

7.    find soft links

find  /home/cvaqa/  -type  l |  xargs  ls -ltr  | grep  /rcast/cvaqa

8.    copy file between two linux server

Linux scp命令

==================

scp 可以在 2个 linux 主机间复制文件;

命令基本格式:

scp [可选参数] file_sourcefile_target

======

从本地 复制到远程

======

* 复制文件:

* 命令格式:

scplocal_file remote_username@remote_ip:remote_folder

或者

scplocal_file remote_username@remote_ip:remote_file

或者

scplocal_file remote_ip:remote_folder

或者

scplocal_file remote_ip:remote_file

第1,2个指定了用户名,命令执行后需要再输入密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名;

第3,4个没有指定用户名,命令执行后需要输入用户名和密码,第3个仅指定了远程的目录,文件名字不变,第4个指定了文件名;

* 例子:

scp/home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music

scp/home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music/001.mp3

scp/home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/music

scp/home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/music/001.mp3

* 复制目录:

* 命令格式:

scp -rlocal_folder remote_username@remote_ip:remote_folder

或者

scp -rlocal_folder remote_ip:remote_folder

第1个指定了用户名,命令执行后需要再输入密码;

第2个没有指定用户名,命令执行后需要输入用户名和密码;

* 例子:

scp -r/home/space/music/ root@www.cumt.edu.cn:/home/root/others/

scp -r/home/space/music/ www.cumt.edu.cn:/home/root/others/

上面命令将本地 music 目录复制到远程 others 目录下,即复制后有远程有../others/music/ 目录

======

从远程 复制到本地

======

从远程复制到本地,只要将从本地复制到远程的命令的后2个参数调换顺序即可;

例如:

scproot@www.cumt.edu.cn:/home/root/others/music /home/space/music/1.mp3

scp -rwww.cumt.edu.cn:/home/root/others/ /home/space/music/

最简单的应用如下 :

scp 本地用户名 @IP 地址 : 文件名 1 远程用户名 @IP 地址 : 文件名 2

[ 本地用户名 @IP 地址 :] 可以不输入 , 可能需要输入远程用户名所对应的密码 .

可能有用的几个参数 :

-v 和大多数 linux 命令中的 -v 意思一样 , 用来显示进度 . 可以用来查看连接 , 认证 , 或是配置错误 .

-C 使能压缩选项 .

-P 选择端口 . 注意 -p 已经被 rcp 使用 .

-4 强行使用 IPV4 地址 .

-6 强行使用 IPV6 地址 .

9.   Look cpu num

         grep -c processor /proc/cpuinfo

10. Debug run jar file on linux

a.     Eclipse export jar

Config Java Application

Export -> RunnableJAR file ->select configed Java Application

b.     Run command:

java-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8087 -jartest.jar

11. 查看进程信息

top-M -u cvaqa


12.  Montior

export EDITOR=vi

crontab–e


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值