Hello World!
Toggle navigation
Home
开发
运维部署
旧博客搬家
About Me
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Archives
Tags
Linux常用命令集
2018-08-09 03:47:16
57
0
0
lion
#挂载硬盘 blkid #显示分区格式 #/dev/sdb1: UUID="0417cff3-d6d5-433a-87f2-c4596143762a" TYPE="ext4" #/dev/sda1: UUID="34f79a00-9e0e-4010-9d60-3718240cca6c" TYPE="xfs" #/dev/sda2: UUID="P6xf6f-NPgl-s3Dm-123h-B5e3-NJBh-GbNM1n" TYPE="LVM2_member" #/dev/mapper/centos-root: UUID="f65437ea-e2e7-4ecd-a451-915233311ab3" TYPE="xfs" #/dev/mapper/centos-swap: UUID="bb86b211-c24a-4212-9501-d349111c24aa" TYPE="swap" vi /etc/fstab #加上 UUID=0417cff3-d6d5-433a-87f2-c4596143762a /data ext4 defaults 0 0 #测试 mount -a #目录绑定挂载 #原目录:/data/var.. 挂载到/var/snap... /data/var-lib-docker /var/snap/docker/common/var-lib-docker none defaults,bind 0 0 同:mount --bind #Ubuntu添加静态路由 修改interfaces文件了,写在文件的末尾,基本格式如下: up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 可以看到这个格式和route命令的唯一区别在于,在前面多了一个up 下面列出我的interface文件仅供参考,由于安全因素,这里的ip我都用xx替代了: # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gateway xxx.xxx.xxx.xxx auto eth0:0 iface eth0:0 inet static address xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx #dns-nameservers 202.102.224.68 202.102.227.68 up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0 up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0 up route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth0 #ZFS相关 创建动态卷: zfs create -s -V 200GB pool/diskname 创建raid1镜像: zpool create -f zfspoola mirror /dev/sdb /dev/sdc 创建zfs文件系统: zfs create zfspoola/data -o mountpoint=/data 创建动态卷: zfs create -s -V 200GB pool/diskname 修改zfs文件系统blocksize zfs set recordsize=64k zfspoola/data 创建快照 zfs snapshot yyqtfilepool/data@20221230 查看快照 zfs list -t snapshot 发送快照到远程文件 zfs send zfspool/data@20221230 | ssh user@172.16.0.112 dd of=/data/backup2/zfs/data.20221230.zfs.full.snapshot 用split分割远程文件 zfs send zfspool/data@20221230 | ssh user@172.16.0.112 split -b 1000000 --verbose - /data/backup2/zfs/data.20221230.zfs.full.snapshot 发送增量快照到远程文件 zfs send -i zfspool/data@20221230 | ssh user@172.16.0.112 split -b 1000000 --verbose - /data/backup2/zfs/data.20221230.zfs.full.snapshot 从远程文件恢复 ssh yyqt@172.16.0.112 cat test.zfs | zfs receive zfspool/data3 ## zfs快照备份 #/bin/sh snapshotname="`date +%Y%m%d`" ssh user@172.16.0.100 sudo zfs snapshot zfspool/file@$snapshotname ssh user@172.16.0.100 sudo zfs send zfspool/file@$snapshotname | split -b 4000000000 --verbose - ./zfs/file.$snapshotname.snapshot #Ubuntu安装Java mkdir /mnt/ushare mount //172.16.0.40/temp /mnt/ushare -o username=Administrator,password=~ever20101 mkdir /usr/sbin/jre/ cp /mnt/ushare/临时共享/server-jre-8u102-linux-x64.tar.gz /usr/sbin/jre/ tar -xvzf /usr/sbin/jre/server-jre-8u102-linux-x64.tar.gz mv jdk1.8.0_102 /usr/sbin/jre/jdk1.8.0_102 vi /etc/envirenment JAVA_HOME="/usr/sbin/jre/jdk1.8.0_102" /usr/sbin/jre/jdk1.8.0_102/bin" centos 改/etc/profile 加入 PATH=$PATH:/usr/sbin/jre/jdk1.8.0_102/bin export PATH #Ubuntu安装Mysql和Phpmyadmin 1.安装之前先更新系统 sudo apt update 2.安装Apache2 sudo apt install apache2 3.安装PHP sudo apt install php sudo apt-get install libapache2-mod-php 4.安装MySQL sudo apt install mysql-server php7.0-mysql sudo apt-get install mysql-client mysql_secure_installation 5.安装phpmyadmin sudo apt-get install phpmyadmin sudo apt-get install php-mbstring sudo apt-get install php-gettext sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin 配置phpmyadmin nano /etc/php/7.0/apache2/php.ini display_errors = On(显示错误日志,出现两次,都要改,不然无效) extension=php_mbstring.dll (开启mbstring) #CentOS SUDO设置 --修改/etc/sudoers chmod u+w /etc/sudoers vi /etc/sudoers 在 root ALL=(ALL) ALL 后加入 username ALL=(ALL) ALL #CentOS安装Java mount //172.16.0.6/filecenter /mnt/ushare -o username=yyqtshare,password=yyqtshare mkdir /usr/sbin/jre/ cp /mnt/ushare/临时共享/server-jre-8u102-linux-x64.tar.gz /usr/sbin/jre/ tar -xvzf /usr/sbin/jre/server-jre-8u102-linux-x64.tar.gz mv jdk1.8.0_102 /usr/sbin/jre/jdk1.8.0_102 centos 改/etc/profile 加入 PATH=$PATH:/usr/sbin/jre/jdk1.8.0_102/bin export PATH 改/etc/envirenment JAVA_HOME="/usr/sbin/jre/jdk1.8.0_102" #CentOS改机器名 改机器名 hostnamectl set-hostname ### #CentOS firewalld防火墙 #开放端口 firewall-cmd --zone=public --add-port=6400/tcp --permanent #启动防火墙 systemctl start firewalld CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。 1、关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2、安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/iptables #编辑防火墙配置文件 # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT :wq! #保存退出 systemctl restart iptables.service #最后重启防火墙使配置生效 systemctl enable iptables.service #设置防火墙开机启动 #TrueCrypt挂载 truecrypt -t --filesystem=none /dev/zvol/yyqtfilepool/vwork /filecenter/临时共享/Working #tun虚拟网卡操作 1. Create the repository config file /etc/yum.repos.d/nux-misc.repo [nux-misc] name=Nux Misc baseurl=http://li.nux.ro/download/nux/misc/el7/x86_64/ enabled=0 gpgcheck=1 gpgkey=http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro 2。# yum --enablerepo=nux-misc install tunctl 3。tunctl -t tap0 -u root #centos启用nfs yum install nfs-utils rpcbind #设置开机启动 chkconfig nfs on chkconfig rpcbind on #启动服务 service rpcbind start service nfs start #挂载目录 mount -t nfs server_ip:/export/primary /mnt/primary mount -t nfs server_ip:/export/secondary /mnt/secondary #开机挂载 vi /etc/fstab mkdir /filecenter 172.16.1.1:/filecenter /filecenter nfs rw mount -a测试 #ubuntu连接windows远程桌面 #安装 sudo apt install freerdp2-x11 #使用 xfreerdp /v:172.16.1.1:3389 /u:administrator #windows2012测试成功 #安装leanote客户端 sudo apt-get install libgconf-2-4 wget https://excellmedia.dl.sourceforge.net/project/leanote-desktop-app/2.6.1/leanote-desktop-linux-x64-v2.6.1.zip #解决Linux与Windows时差 方法1,修改Linux,禁止Linux把CMOS时间当作UTC时间 #方法①:修改/etc/default/rcS文件 vi /etc/default/rcS 将UTC=yes改成UTC=no #这是以前的方法,新版本的Ubuntu使用systemd启动之后,时间也改成了由timedatectl来管理,此方法就不适用了 方法②:执行下面命令 timedatectl set-local-rtc 1 --adjust-system-clock 重启完成将硬件时间UTC改为CST,双系统时间保持一致 方法2,修改Windows,让Windows也把CMOS时间当作UTC时间 在 注册表项:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\下中添加一项数据类型为REG_DWORD,名称为RealTimeIsUniversal,值设为1 的键值。 或者直接使用下如下批处理进行修改: ------------------------------------------------------------------------ @echo off color 0a Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1 echo. echo 已让Windows识别存贮在主板CMOS内的时间为格林威治标准时间(GMT),即系统根据CMOS时间和设置的时区来确定当前系统的时间。 echo. pause ## 启用停用ntp timedatectl set-ntp true #ubuntu启用root用户 #先设置root用户密码 sudo passwd root #然后设置sshd允许root远程登录 vi /etc/ssh/sshd_config 修改 PermitRootLogin without-password 为 PermitRootLogin yes 重启SSH: service ssh reload # 导入ca证书 $sudo cp 证书路径.crt /usr/local/share/ca-certificates $sudo update-ca-certificates # ubuntu 18 时区修改 timedatectl list-timezones timedatectl set-timezones Asia/Shanghai # 批量杀进程 ps -ef | grep generate_data | grep -v grep | awk '{print "kill "$2}' | sh # 建用户 mkdir /home/yyqt && useradd -d /home/yyqt yyqt -s /bin/bash && chown yyqt /home/yyqt && cp ~/.bashrc /home/yyqt && cp /root/.profile /home/yyqt/ && chown yyqt:yyqt /home/yyqt/.profile # sed命令 批量替换 grep -rl 'SearchString' ./ | xargs sed -i 's/REPLACESTRING/WITHTHIS/g' 或 sed -i “s/oldstring/newstring/g” grep oldstring -rl path (grep oldstring -rl path用于查找文件路径) # 关闭自动更新 sudo dpkg-reconfigure unattended-upgrades
Pre:
IdentityServer4_OIDC/OAuth认证体系
Next:
7ghost安装
0
likes
57
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
目录