`

常用linux命令_2

    博客分类:
  • OS
 
阅读更多

30.memcached版本
[root@Server213 bin]# ./memcached -h
memcached 1.4.10


31.apache
service httpd start|stop|restart

/usr/local/apache/bin/apachectl -k start



32.visulVM
jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=192.168.1.211 &



33.文件操作
cp test.txt test1.txt

echo "" > test.txt


34.当前访问系统的用户数
who | wc -l


|在两个程序之间建立管道
who的输出成了wc的输入


35.生成脚本(普通)文件
1.cat > test
who | wc -l
(ctrl+D)

2.chmod +x test

3. ./test

#清空文件内容
cat /dev/null > errlog.log


测试连接
java -classpath .:mysql-connector-java-5.1.18-bin.jar TestConnections 119.254.104.243:4045 100



36.查看文件内容

36-1全部显示
cat foo.txt

36-2 箭头下移滚动查看
view foo.txt (vim)

36-1 分页查看或滚屏(*)
more foo.txt
空格(看下一屏)

36-2
cat foo.txt|more  分页查看或滚屏
cat foo.txt|less

36-2 分页查看目录下文件
ls | more

36-3查找字符串

36-1 less
less gp4-passport.log

# find
/ERROR

# continue
N或者n


**********************************************************************
 或者
**********************************************************************
less -p ERROR gp4-passport.log


36-2 vi
vi gp4-passport.log

# find
/ERROR

# continue
n


退出:
ESC
:q!



# 位数
getconf LONG_BIT



#查找文件
find / -type d -name apache(查找apache目录名称)


#查询某个目录下,文件名中包含20110614的文件个数
#20110629
ls -1 > lstfile

grep _20110614 lstfile |wc -l



$#表示包括$0在内的命令行参数的个数。
在Shell中,脚本名称本身是$0,剩下的依次是$0、$1、$2…、${10}、${11},等等。
$*表示整个参数列表,不包括$0,也就是说不包括文件名的参数列表。


#查看进程内存
top

可以直接使用top命令后,查看%MEM的内容。可以选择按进程查看或者按用户查看,
如想查看oracle用户的进程内存使用情况的话可以使用如下的命令:
top -u oracle

pmap
pmap -d 14596

可以根据进程查看进程相关信息占用的内存情况,(进程号可以通过ps查看)如下所示:

ps
ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid'
其中rsz是是实际内存
ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep Agent |  sort -nrk5
其中rsz为实际内存,上例实现按内存排序,由大到小


#windows远程重启
shutdown -r -t 0



37.centos卸载默认jdk
37-1 首先查询JDK版本
#rpm -qa |grep gcj

显示
java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

37-2 删除掉jdk
#yum -y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115


38.网卡
service network restart


39.启动ssh服务
service sshd start

40.查看网关等网络配置
route



shell
1.有时候等于是用eq表示,有时候用=标准?
eq数值
=字符串


java编译
参数:(-cp -classpath)
-cp 和 -classpath 一样,是指定类运行所依赖其他类的路径,通常是类库,jar包之类,需要全路径到jar包,window上分号“;”

javac -cp .:/usr/test/src/BaseException.class:/usr/test/lib/log4j-1.2.15.jar LoggerManager.java

javac -classpath .:/usr/test/src/BaseException.class:/usr/test/lib/log4j-1.2.15.jar LoggerManager.java


41.ssh中文乱码
export LC_ALL=zh_CN.GBK
export LANG=zh_CN.GBK



42.安装gdb
yum install gdb

43.gcc
yum -y install gcc
yum -y install gcc-c++


44.查看linux cpu型号及内核信息
uname -a

# for kernel.
uname -r

#for distro (on any distro)
cat /etc/issue

Linux ylin-ThinkPad 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux
查看当前操作系统内核信息。如有i386或i686字样,则操作系统内核为32位,如有x686或x86_64,则操作系统内核为64位。


45.查看os的最大线程数
cat /proc/sys/kernel/threads-max

46.查看某进程下包含的线程信息、数量
ps -Lf pid
ps -Lf pid | wc -l


47.
cat /proc/sys/kernel/pid_max

48.查看环境变量
echo $JAVA_HOME


49.wget
 wget http://192.168.1.189:5988


50.查看linux上目前的用户
cat /etc/passwd

51.
find / -name cimserver_current.conf


52.查看文件时,添加行号
vi test.sh
shift+: set nu(或set number)

取消行号
shift+: set nonu(或set nonumber)

53.史浩然
环境变量资源: env
内核/操作系统/CPU信息: uname -a
内存: cat /proc/meminfo
cpu:  cat /proc/cpuinfo
硬盘:df -m
网卡: ethtool th0(或者ethtool th0/1)
查看oracle版本:select * from v$version
或者:sqlplus /nolog链接时会显示版本号


54.mysql版本
mysql -V

55.linux启动/关闭
#关闭
shutdown -h now

#重启
reboot

#关机
init 0

#重启
init 1

56.linux启动关闭mysql
/etc/init.d/mysql(d)  start|stop|restart|reload|force-reload

57.linux启动/关闭/重启apache
/usr/local/apache/bin/apachectl start|stop|restart

/home/iconshare/apache/bin/apachectl start

#不中断当前连接
/usr/local/sbin/apachectl graceful


#如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start | stop | restart

#如果你不知道apachectl的位置.可以使用
find / -name apachectl


58.查看目录及文件大小

[root@localhost home]# du -sh cms
150M    cms

[root@localhost home]# du -sh cms.tar.gz
14M     cms.tar.gz

59.移动文件夹

#移动shop目录到/data下
mv shop /data


60.查看目录下文件个数
find . -type f|wc -l


61.资源监视命令
vmstat 1 >> /usr/monitor/vmstat/vmstat-172.16.2.2-5-20130628.txt


62.查看syslog存放的位置
软件:
syslogd 1.4.1


/etc/syslog.conf

/var/log/lastlog :记录最后一次用户成功登陆的时间、登陆IP等信息
/var/log/messages :记录Linux操作系统常见的系统和服务错误信息
/var/log/secure :Linux系统安全日志,记录用户和工作组变坏情况、用户登陆认证情况
/var/log/btmp :记录Linux登陆失败的用户、时间以及远程IP地址
/var/log/cron :记录crond计划任务服务执行情况


63.ulimit
#
cat /proc/self/limits |grep 'Max open files'


#查看文件打开数目
ulimit -n

#查看文件打开数目
cat /proc/{pid}/limits |grep 'Max open files'

#ulimit -a
-a 显示当前所有的资源限制
-H 硬件资源限制,一但设置不能增加
-S 软件资源限制,可以增加,但不能超过 -H
-u 用户可使用的最大进程
-c core 文件的最大值
-d 数据段的最大值
-n 内核可以同时打开的文件描述符的最大值
-s 堆栈的最大值
-v 虚拟内存的最大值
-m 最大内存使用


#查看当前进程打开的文件句柄数
ps -ef|grep java
lsof -p {pid} | wc -l


#修改文件句柄
1.cat /proc/sys/fs/file-max
2.echo "655360" >/proc/sys/fs/file-max
3.reboot
4.验证
ulimit -a | grep 'open files'

 

0
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics