Linux系统类常用命令
一、Linux如何查看版本是32位还是64位
A:[root
localhost~]#uname-aLinuxlocalhost.localdomain2.6.32-.el6.i#1SMPTueDec:15:40GMTiiiGNU/Linuxi表示该版本是32位的版本而x64表示版本号是64位的版本二、Linux如何查看操作系统版本信息
A:可以通过cat/etc/issue命令来查看,效果如下[root
localhost~]#cat/etc/issueCentOSlease6.2(Final)Kernel\ronan\m三、Linux下如何查看cpu、内存利用率
A:Linux可以通过top命令来查看cpu及内存的实时使用情况。举例说明:[root
localhost/]#topop-19:35:41up47min,2users,loadaverage:0.05,0.01,0.00Tasks:total,1running,sleeping,4stopped,0zombieCpu(s):1.9%us,0.8%sy,0.0%ni,97.1%id,0.0%wa,0.2%hi,0.0%si,0.0%stMem:ktotal,kused,kfe,kbuffersSwap:ktotal,0kused,kfe,kcachedus表示用户空间占用cpu百分比sy表示内核空间占用cpu百分比id表示cpu空间空间所占的百分比Mem表示内存的情况total表示内存总共有多少kbused表示已经使用的内存Fe表示现在空闲的内存大小四、Linux如何关闭selinux
A:按以下步骤操作1.输入vi/ect/selinux/config2.按I进入编辑界面#ThisfilecontrolsthestateofSELinuxonthesystem.#SELINUX=cantakeoneofthesethevalues:#enforcing-SELinuxsecuritypolicyisdisable.#permissive-SELinuxprintswarningsinsteadofenforcing.#disabled-NoSELinuxpolicyisloaded.SELINUX=enforcing#SELINUXTYPE=cantakeoneofthesetwovalues:#targeted-Targetedprocessesaprotected,#mls-MultiLevelSecurityprotection.SELINUXTYPE=targeted~/etc/selinux/config13L,C3.将SELINUX=enforcing改为SELINUX=disable4.按esc退出编辑输入shift+:,然后输入wq保存修出5.输入boot重启linux
五、Linux如何修改服务器主机名称?
A:进入Linux后使用如下命令进行主机名称的修改。1、可使用hostname暂时修改主机名称,但这种修改是暂时的,当服务器重启后,主机名将恢复原样。[root
localhost~]#hostnameXXXXXX(新的主机名称)2、通过vi命令修改配置文件方式,修改/etc/sysconfig/network文件中的HOSTNAME项“HOSTNAME=主机名”,重启后主机名为指定的名称。如下:[rootlocalhost~]#vi/etc/sysconfig/networkNETWORKING=yesHOSTNAME=XXXXXX(新的主机名称)GATEWAY=..0.1六、Linux如何修改系统时间
A:可以通过date命令修改系统时间,然后需要用hwclock命令将系统时间同步到硬件时间。命令如下:[root
localhost~]#date-s-7-:59:00(修改时钟为年7月30日16点59分)ThuJul:59:00CST[rootlocalhost~]#hwclock-w--systohc(同步到硬件时钟)七、Linux如何修改时区为东8区
A:按以下步骤执行1.使用vi命令修改/etc/sysconfig/clock[root
localhostAsia]#vi/etc/sysconfig/clock2.修改内容:ZONE=Asia/Shanghai3.保存退出4.拷贝shanghai时区到/etc/localtime#cp/usr/sha/zoneinfo/Asia/Shanghai/etc/localtimecp:overwrite`/etc/localtime?y八、Linux如何抓取报文
A:Linux通过tcpdump命令可以获取报文,举例说明如下:要获取eth1接口上或者的报文,并将报文保存为1.cap的文件,命令为tcpdump-s0-ieth1portor-w1.cap要获取eth1接口上IP为..0.发送的所有报文,并将报文保存为1.cap的文件,命令为tcpdump-s0-ieth1host..0.-w1.cap要获取eth1接口上IP为..0.的主机发出的端口的报文,并将报文保存为1.cap的文件,命令为tcpdump-s0-ieth1host..0.andport-w1.cap
九、Linux如何关闭防火墙服务
A:可以用serviceiptablesstop表示临时关闭防火墙,可以用chkconfig命令永久关闭防火墙服务。临时关闭防火墙命令:[root
localhost/]#serviceiptablesstopiptables:Flushingfiwallrules:[OK]iptables:SettingchainstopolicyACCEPT:filter[OK]iptables:Unloadingmodules:[OK]永久关闭防火墙命令:[rootlocalhost~]#chkconfig--level3iptablesoff[rootlocalhost~]#chkconfig--level5iptablesoff检查结果:输入/etc/intit.d/iptablesstaus查看防火墙状态,确认防火墙关闭[rootlocalhost~]#/etc/init.d/iptablesstatusiptables:Fiwallisnotrunning.十、Linux如何关机或重启。
A:Linux重启命令为boot或者init6;Linux关机命令为halt或init0
十一、Linux如何查看哪个端口被哪个进程使用
A:在日常工作中,有时需要查看端口被哪个进程使用,最典型的问题是因为数据库有连接存在导致无法恢复数据库,这就需要通过命令来查看到底哪个进程占用了该端口。Linux下可以通过netstat命令来实现这次操作。举例说明:需要查询哪些进程连接了的数据库,命令如下[root
localhostAsia]#netstat-anpgptcp.1.0.19:172.1.0.19:ESTABLISHED/postgstcp.1.0.19:172.1.0.19:ESTABLISHED/postgstcp.1.0.19:.1.0.19:ESTABLISHED/mcservertcp.1.0.19:.1.0.19:ESTABLISHED/mcserver输出说明:注意看最后一列,比如/mcserver,表明进程mcserver连接了端口,其进程号(PID)为。
十二、Linux如何杀掉一个进程
A:步骤如下。首先通过ps-ef命令查找到该进程的PID号,命令如下:[root
localhostAsia]#ps-feUIDPIDPPIDCSTIMETTYTIMECMDroot17:21?00:00:01/sbin/initroot:21?00:00:00[kthadd]root:21?00:00:00[migration/0]root:21?00:00:00[ksoftirqd/0]root:21?00:00:00[migration/0]root:21?00:00:00[watchdog/0]root:21?00:00:00[migration/1]root:21?00:00:00[migration/1]root:21?00:00:00[ksoftirqd/1]然后通过kill命令,将进程杀掉,比如要把watchdog进程杀掉,则输入[rootlocalhostAsia]#kill-96(6为watchdog的PID号)边听音乐边学习我们每天等你来长按北京医院哪家治疗白癜风技术好北京治疗白癜风去哪里