linux常用命令

一:cpu

[root@srv /]# more /proc/cpuinfo | grep “model name”
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz

[root@srv /]# grep “model name” /proc/cpuinfo
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
model name      : Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz

[root@srv /]# grep “model name” /proc/cpuinfo | cut -f2 -d:
Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz
Intel(R) Xeon(R) CPU           X3220 @ 2.40GHz

二:内存

[root@srv /]# grep MemTotal /proc/meminfo
MemTotal:       614400 kB

[root@srv /]# free -m
                   total       used       free     shared    buffers     cached
Mem:           600         23        576          0          0          0
-/+ buffers/cache:         23        576
Swap:            0          0          0

[root@srv /]# free -m |grep “Mem” | awk ‘{print $2}’
600

三:查看CPU位数(32 or 64)

[root@srv /]# getconf LONG_BIT
32

四:查看linux版本

[root@srv /]# more /etc/redhat-release
CentOS release 5 (Final)

[root@srv /]# more /etc/issue
CentOS release 5 (Final)
Kernel \r on an \m
[root@srv /]# more /proc/version
Linux version 2.6.18-92.1.18.el5.028stab060.2PAE (root@rhel5-32-build-xemul ) (gc
c version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jan 13 12:31:30 MSK 2009

五:查看内核版本

[root@srv /]# uname -r
2.6.18-92.1.18.el5.028stab060.2PAE

[root@srv /]# uname -a
Linux srv.eddiechen.cn 2.6.18-92.1.18.el5.028stab060.2PAE #1 SMP Tue Jan 13 12:31:30 MSK 2009 i686 i686 i386 GNU/Linux

六:查看时区

[root@srv /]# date -R
Wed, 25 Feb 2009 02:20:50 +0000

[root@srv /]# mv /etc/localtime /etc/localtime.save
[root@srv /]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@srv /]# date -R
Wed, 25 Feb 2009 10:24:26 +0800

七:主机名

[root@srv /]# hostname
srv.eddiechen.cn

八:查看selinux情况

[root@srv /]# sestatus
SELinux status:                 disabled

九:网络

IP

[root@srv /]# ifconfig   | grep ‘inet addr:’| grep -v ’127.0.0.1′ | cut -d: -f2 | awk ‘{ print $1}’
207.154.202.216

网关

[root@srv /]# cat /etc/sysconfig/network
NETWORKING=”yes”
GATEWAY=”192.0.2.1″
HOSTNAME=”srv.eddiechen.cn”

dns

[root@srv /]# cat /etc/resolv.conf
nameserver 208.74.168.131
nameserver 208.74.168.132
nameserver 4.2.2.1

十:已经安装的软件包

[root@srv /]# rpm -qa | wc -l

197

[root@srv /]# yum list installed | wc -l
198

十一:磁盘和分区

[root@srv /]# df -h
Filesystem            Size      Used            Avail Use     %     Mounted on
/dev/simfs             10G    353M             9.7G         4%     /

[root@srv /]# du -sh
353M

[root@srv /]# du /etc -sh
4.6M    /etc

十二:系统启动的服务

[root@srv ~]# chkconfig –list | grep 3:on | cut -f1
crond         
httpd         
iptables      
mcstrans      
messagebus    
network       
restorecond   
sendmail      
sshd          
syslog        
xinetd        

十三:系统默认字符集

[root@srv sysconfig]# locale
LANG=
LC_CTYPE=”POSIX”
LC_NUMERIC=”POSIX”
LC_TIME=”POSIX”
LC_COLLATE=”POSIX”
LC_MONETARY=”POSIX”
LC_MESSAGES=”POSIX”
LC_PAPER=”POSIX”
LC_NAME=”POSIX”
LC_ADDRESS=”POSIX”
LC_TELEPHONE=”POSIX”
LC_MEASUREMENT=”POSIX”
LC_IDENTIFICATION=”POSIX”
LC_ALL=

十四:列出变量

[root@srv ~]# set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]=”3″ [1]=”1″ [2]=”17″ [3]=”1″ [4]=”release” [5]=”i686-redhat-linux-gnu”)
BASH_VERSION=’3.1.17(1)-release’
COLORS=/etc/DIR_COLORS
COLUMNS=80
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=srv.eddiechen.cn
HOSTTYPE=i686
IFS=$’ \t\n’
INPUTRC=/etc/inputrc
LESSOPEN=’|/usr/bin/lesspipe.sh %s’
LINES=24
LOGNAME=root
LS_COLORS=’no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:’
MACHTYPE=i686-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
PIPESTATUS=([0]=”0″)
PPID=3695
PS1=’[\u@\h \W]\$ ‘
PS2=’> ‘
PS4=’+ ‘
PWD=/root
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_AUTH_SOCK=/tmp/ssh-SfvoIj3695/agent.3695
SSH_CLIENT=’123.123.36.61 1263 22′
SSH_CONNECTION=’123.123.36.61 1263 207.154.202.216 22′
SSH_TTY=/dev/pts/0
TERM=linux
UID=0
USER=root
_=USERNAME

[root@srv ~]# env
HOSTNAME=srv.eddiechen.cn
TERM=linux
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=123.123.36.61 1263 22
SSH_TTY=/dev/pts/0
USER=root
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
SSH_AUTH_SOCK=/tmp/ssh-SfvoIj3695/agent.3695
MAIL=/var/spool/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
INPUTRC=/etc/inputrc
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=123.123.36.61 1263 207.154.202.216 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env

[root@srv ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[root@srv ~]# alias
alias cp=’cp -i’
alias l.=’ls -d .* –color=tty’
alias ll=’ls -l –color=tty’
alias ls=’ls –color=tty’
alias mv=’mv -i’
alias rm=’rm -i’

你可能感兴趣的:(linux,redhat,centos,ssh,bash)