yy复制,dd删除,p粘贴
options-> session Options -> Terminal -> audio bell (删除勾选)
ssh登陆
ssh-keygen -t rsa -C "xxx@hotmail.com"
ssh-copy-id user@hostip
ssh-copy-id -i .ssh/Identity.pub root@xxx.xxx.xxx.xxx
修改SSH 端口
yum install policycoreutils-python
vi /etc/ssh/sshd_config => 22->xxxx
semanage port -l | grep ssh
semanage port -a -t ssh_port_t -p tcp xxxx
systemctl restart sshd.service
测试登录
ssh -p xxx root@hostip
清空密码
passwd -d git
改密码
passwd root
systemctl
启动一个服务:systemctl start postfix.service
关闭一个服务:systemctl stop postfix.service
重启一个服务:systemctl restart postfix.service
显示一个服务的状态:systemctl status postfix.service
在开机时启用一个服务:systemctl enable postfix.service
在开机时禁用一个服务:systemctl disable postfix.service
查看服务是否开机启动:systemctl is-enabled postfix.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
图形模式切换
查看默认的target: systemctl get-default
开机以命令模式启动: systemctl set-default multi-user.target
开机以图形界面启动: systemctl set-default graphical.target
压缩
tar -zcvf xxx.tar.gz /xxx
tar -zxvf xxx
zip -r mydata.zip mydata
unzip mydata.zip -d mydatabak
查询当前服务
ps -aux | grep xxx
关机
shutdown -h now
强杀
kill -s 9 xxx
文件末尾
tail -n 100 xxx
网络相关工具
yum install net-tools
yum installiptraf-ng
查看打开端口
netstat -tln
根据端口号查询进程
netstat -tunlp|grep port
查看当前登陆用户
w
yum安装软件包错误
HTTP Error 404 - Not Found Trying other mirror.
# yum clean all
# yum update
环境变量
直接在命令行中设置
#PATH=$PATH:/usr/local/apache/bin
使用这种方法,只对当前会话有效,也就是说每当登出或注销系统以后,PATH设置就会失效
在profile中设置
# vi /etc/profile
找到export行,在下面新增加一行
#export PATH=$PATH:/usr/local/apache/bin。
【注】= 等号两边不能有任何空格
编辑/etc/profile后PATH的修改不会立马生效
可以执行#source profile命令
/etc/profile:每次login都会被执行一次,修改后,下次用户登录就会生效,不需要重启
/etc/rc.local:每次OS启动执行
#vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/apache/bin
#source ~/.bash_profile
这种方法只对当前用户起作用的,其他用户该修改无效。
配置网卡
方法一:把以下命令放在/etc/rc.d/init.d/rc.local文件中
[root@local root]# ifconfig eth0 down <==关闭 eth0 网卡
[root@local root]# ifconfig eth0 up <==启动 eth0 网卡
[root@local root]# ifconfig eth0 192.168.0.2 netmask 255.255.255.0
[root@local root]# route add default gw 192.168.1.2
方法二:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=219.136.241.211
NETMASK=255.255.255.128
GATEWAY=192.168.1.1
vi /etc/resolv.conf
nameserver 8.8.8.8
/etc/init.d/network restart
#设置IP和掩码
ifconfig eth0 192.168.5.40 netmask 255.255.255.0
#设置网关
route add default gw 192.168.5.1
IP, 子网掩码:
/etc/sysconfig/network-script/ifcfg-eth0
IPADDR=192.168.0.1
NETMASK=255.255.255.0
网关:
/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=xx
GATEWAY=192.168.0.100
DNS:
/etc/resolv.conf
NAMESERVER=202.96.209.5
centos 7默认网卡名称问ens33,想要回到eth0的名称需要修改配置
1.编辑文件
vi /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
以上红色字体为添加内容
3.执行命令
grub2-mkconfig -o /boot/grub2/grub.cfg
4.重启系统
reboot
5.修改 网卡配置
vi /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
UUID="60ba7a17-ff38-44bc-ae5c-077ae468bf60"
ONBOOT="yes"
HWADDR="00:0C:29:5F:45:3E"
PEERDNS="yes"
PEERROUTES="yes"
防火墙
1. Disable Firewalld Service.
systemctl mask firewalld
2. Stop Firewalld Service.
systemctl stop firewalld
3. Install iptables service related packages.
yum -y install iptables-services
4. Make sure service starts at boot:
systemctl enable iptables
# If you do not want ip6tables, You can skip following command.
systemctl enable ip6tables
5. Now, Finally Let’s start the iptables services.
systemctl start iptables
# If you do not want ip6tables, You can skip following command.
systemctl start ip6tables
Firewalld Service is now disabled and stop, You can use iptables.
vi /etc/sysconfig/iptables
systemctl restart iptables