linux centos基本命令

来源:互联网 发布:奶牛场优化养殖 编辑:程序博客网 时间:2024/06/11 07:58


Ø 本机设置


1、查询当前本机IPifconfig、ip addr(centos7)

2、清屏:clear

3、查看当前主机名:hostname; 修改当前主机名称:hostname  xxxx(只在当前有效,退出后无效)

4、进入root用户: su

5、退出:exit

6、配置主机名的地方: more /etc/sysconfig/network

7、IP地址的配置:more /etc/sysconfig/network-scripts/ifcfg-eth0

Ø 文件查看

1、第一种: more /etc/sysconfig/network 分页查看

2、第二种: tail -f  /etc/sysconfig/network tail -100f  /etc/sysconfig/network 文件最后几行内容,一般用来查看日志,滚动式的; ctrl+c结束

3、第三者: cat  /etc/sysconfig/network 查看所有

Ø 基本命令

1、显示当前目录: pwd

2、显示子目录: ls

3、显示子目录详细:ls -l 缩写 ll

4、显示所有目录,包括隐藏文件:ls -al

5、xxxcd  ./xx或者 cd xx

6、返回上一层: cd ..

7、进入用户当前主目录: cd

8、新建文件夹: mkdir xxx

9、新建多级文件夹:mkdir -p test01/test02/test03

10、新建文件: touch xxx

11、移动文件:  mv hello2.txt ./test

12、修改文件名称: mv hello.txt hello2.txt

13、拷贝文件:cp hello.txt world.txt

14、删除文件rm xxx 或者 xxx/ 或者-rf xxx/  

15、修改文件的组和用户: chown root world.txt   chown ydh:ydh world.txt

16、编辑文件: vim xxx   按【i】进入编辑,先【Esc】再【:wq】保存再【:q!】不保存


17、修改文件权限:

1.文法修改:u表示拥有者用户,g表示同组用户,o表示其他  chmod g-x world.txt

2.数字修改:chmod 777 hello.txt  777 指的是 可读(4+可写(2+可执行(1

3.chmod -R  777 /opt 加上 -R子文件夹都修改

4.修改所属用户:chown/chgrp root xxx.txt 或者 chown hadoop:hadoop xxx.txt

18、解压缩tar -zxvf hadoop-1.2.1-bin.tar.gz

Ø 单机设置环境变量

1、用户sudo无密码 权限 u+w=740  u-w=040

2、id  sudo service iptables status  测试

3、重启服务 service network restart

4、关于启动和关闭防火墙的命令:
1) 重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop

centos7 防火墙 

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

5、卸载系统自带的jdk版本:

查看自带的jdk

#rpm -qa|grep gcj 或者 rpm -qa|grep java

看到如下信息:

libgcj-4.1.2-44.el5

java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

使用rpm -e --nodeps 命令删除上面查找的内容:

#rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

卸载rpm安装的jdk版本

查看安装的jdk

#rpm -qa|grep jdk

看到如下信息:

java-1.6.0-openjdk-1.6.0.0-0.25.b09.el5

jdk-1.6.0_16-fcs

卸载:#rpm -e --nodeps jdk-1.6.0_16-fcs

6、指定解压缩./jdk-6u45-linux-x64.bin

7、环境变量  vi /etc/profile加入

export JAVA_HOME=/opt/modules/jdk1.6.0_45

export PATH=$PATH:$JAVA_HOME/bin

8、使环境变量 生效 source /etc/profile

 

--------------------------------------------------------------------------------------------------------------

查看系统版本:lsb_release -a
[root@localhost /]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.1 (Final)
Release:        6.1

Codename:       Final

 

查看内核版本:uname -a

Linux localhost.localdomain 2.6.32-131.0.15.el6.x86_64 #1 SMP Sat Nov 12 15:11:58 CST 2011 x86_64 x86_64 x86_64 GNU/Linux

 

查看cpu型号:cat /proc/cpuinfo
[root@localhost /]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5506  @ 2.13GHz
......

 

查看硬盘空间情况df -lm
[root@localhost /]# df -l
文件系统                 1K-     已用     可用 已用%挂载点
/dev/sda3            604758736  20379244 553659492   4% /
tmpfs                  8160484         0   8160484   0% /dev/shm
/dev/sda1               495844     35901    434343   8% /boot
/dev/sda5            302379456   4760128 282259328   2% /opt

 

查看内存:free -m 
[root@localhost /]# free -mt
             total       used       free     shared    buffers     cached
Mem:         15938      14204       1734          0        356      10597
-/+ buffers/cache:       3250      12688
Swap:        19997          0      19997
Total:       35936      14204      21732

Swap为虚拟内存,当物理内存不够时,系统就会使用到swap,swap速度比真实内存的速度要慢的多,当你电脑用到swap的时候,说明你内存不够了,需要加内存

 

free
   明:显示内存状态。
语  法: free [-bkmotV][-s <间隔秒数>]
补充说明:free指令会显示内存的使用情况,包括实体内存,虚拟的交换文件内存,共享内存区段,以及系统核心使用的缓冲区等。
参  数:
-b  以Byte为单位显示内存使用情况。 
-k  以KB为单位显示内存使用情况。 
-m  以MB为单位显示内存使用情况。 
-o  不显示缓冲区调节列。 
-s<间隔秒数> 持续观察内存使用状况。 
-t  显示内存总和列。 
-V  显示版本信息。

9、

 

原创粉丝点击