Linux基础命令复习-集群常用命令详解

1.ifconfig/ip a
[root@controller ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C3:C5:49  
          inet addr:192.168.48.10  Bcast:192.168.48.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec3:c549/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5484354 errors:0 dropped:0 overruns:0 frame:0
          TX packets:768709 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7696445437 (7.1 GiB)  TX bytes:214070030 (204.1 MiB)


2.yum install -y openssh-clients


3.ssh免密钥登陆
[root@controller httpd]# ssh-keygen -t rsa
一路回车
[root@controller ~]# ssh-copy-id -i .ssh/id_rsa.pub root@compute
如果报错:-bash: ssh-copy-id: command not found,执行yum安装命令。
[root@controller ~]# yum install -y openssh-clients


4.hostname
[root@controller httpd]# hostname
controller


5.crontab
crontab任务配置基本格式:
*   *  *  *  *  command
分钟(0-59) 小时(0-23) 日期(1-31) 月份(1-12) 星期(0-6,0代表星期天)  命令
列子:

0 1 * * * /home/testuser/test.sh
每天晚上1点调用/home/testuser/test.sh

*/10 * * * * /home/testuser/test.sh
每10钟调用一次/home/testuser/test.sh

30 21 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每晚的21:30重启apache。

45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每月1、10、22日的4 : 45重启apache。

10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每周六、周日的1 : 10重启apache。

0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示在每天18 : 00至23 : 00之间每隔30分钟重启apache。

0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每星期六的11 : 00 pm重启apache。

* */1 * * * /usr/local/etc/rc.d/lighttpd restart
每一小时重启apache

* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart
晚上11点到早上7点之间,每隔一小时重启apache

0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart
每月的4号与每周一到周三的11点重启apache

0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart
一月一号的4点重启apache

*/30 * * * * /usr/sbin/ntpdate 210.72.145.44
每半小时同步一下时间


6.scp
[root@controller ~]# scp scptest root@compute:$PWD
scptest                                                      100%    4     0.0KB/s   00:00    
[root@controller ~]# 


7.fdisk
[root@compute ~]# fdisk

Usage:
 fdisk [options] <disk>    change partition table
 fdisk [options] -l <disk> list partition table(s)
 fdisk -s <partition>      give partition size(s) in blocks

Options:
 -b <size>                 sector size (512, 1024, 2048 or 4096)
 -c                        switch off DOS-compatible mode
 -h                        print help
 -u <size>                 give sizes in sectors instead of cylinders
 -v                        print version
 -C <number>               specify the number of cylinders
 -H <number>               specify the number of heads
 -S <number>               specify the number of sectors per track

8.shell
#!/bin/bash
# 上面中的 #! 是一种约定标记, 它可以告诉系统这个脚本需要什么样的解释器来执行;

echo "Hello, world!"

[root@controller ~]# ./hello.sh
-bash: ./hello.sh: Permission denied
[root@controller ~]# chmod +x hello.sh 
[root@controller ~]# ls
anaconda-ks.cfg                hello.sh     install.log.syslog  XianDian-IaaS-v1.4.iso
CentOS-6.5-x86_64-bin_DVD.iso  install.log  scptest


9.iptables
service iptables stop/start/restart/status
chkconfig iptables off


10.selinux
selinux三种状态介绍:
enforcing-是强制模式系统,它受selinux保护。就是违反了策略你就无法继续操作下去。
permissive-是提示模式系统不会受到selinux保护,只是收到警告信息。permissive就是selinux有效,但disabled-禁用selinux是即使你违反了策略的话它让你继续操作,但是把你违反的内容记录下来(警告信息)
disabled-禁用selinux

selinux的全称是Security Enhance Linux,就是安全加强的Linux。
Selinux会对我们后续使用的httpd服务进行保护,导致无法访问到页面,因此需要将selinux设置为permissive或者disabled。
[root@controller ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive

11.添加主机名与IP映射
[root@controller ~]# vi /etc/hosts
192.168.48.10   controller
192.168.48.20   compute

12.常用系统关机命令:
halt ,init 0 ,poweroff ,shutdown -h now ,shutdown -h 10

13.常用系统重启命令:
reboot , shutdown -r now , init 1

猜你喜欢

转载自blog.csdn.net/weixin_42325841/article/details/83894274