如何用tar压缩文件夹到指定目录,tar -zxvf /usr/local/jmeter.tar.gz -C /usr/local/ && rm -rf /usr/local/jmeter.tar.gz && chmod -R 755 /usr/local/jmeter
Unix/LinuxC技术 jackxiang 2018-8-21 14:17
如何用tar压缩文件夹到指定目录:
tar -zxvf /usr/local/jmeter.tar.gz -C /usr/local/ && rm -rf /usr/local/jmeter.tar.gz && chmod -R 755 /usr/local/jmeter
压缩:
tar -cvzf /test/tmp/abc.tar.gz /test/tcp/abc
实例,将魔方MYSIM数据库给压缩到根目录下:
tar -cvzf /mofang.08.21.tar.gz mofang/
解压
tar -cvxf abc.tar.gz -C /test/tmp
tar -zxvf /usr/local/jmeter.tar.gz -C /usr/local/ && rm -rf /usr/local/jmeter.tar.gz && chmod -R 755 /usr/local/jmeter
压缩:
tar -cvzf /test/tmp/abc.tar.gz /test/tcp/abc
实例,将魔方MYSIM数据库给压缩到根目录下:
tar -cvzf /mofang.08.21.tar.gz mofang/
解压
tar -cvxf abc.tar.gz -C /test/tmp
[实践OK]ssh太慢,CentOS6.X下编译并升级安装OpenSSH7.4p1,一台CentOS6.X机器连接SSH太慢,重新编译最新的openssh后连接正常的编译过程。
Unix/LinuxC技术 jackxiang 2018-8-17 11:05
导语
Redhat企业级系统的6.7版自带SSH版本为OpenSSH_5.3p1, 基于审计和安全性需求,建议将其升级到最新的OpenSSH版本,当前官网最新版本为7.4p1. 本文档将详细介绍OpenSSH升级的完整步骤。需要说明的是,升级过程中虽然涉及zlib、openssl和openssh的卸载,但是并不会导致当前的ssh远程连接会话断开,因此是可以将整个升级过程写成自动化脚本以进行自动批量部署的。后面咱准备逐步过度到CentOS7了,新版在SSH底层上优化了TCP连接传输功能。在譬如拷贝时会用同一个TCP的FD,而旧版本的是没有这个功能的。再就是刚连接过了在超时设置范围内,再次发起连接时也会复用之前的一个Socket的FD句柄,提高连接效率。
编译安装OpenSSH7.4p1一共分二步,
第一步:安装编译需要的RPM包:
第二步:编译并安装到和原来一样的目录,如下步骤:
tar zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1
ll
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-kerberos5=/usr/lib64/libkrb5.so
make && make install
cp -rf /usr/local/src/openssh-7.4p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp -rf contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
vim /etc/init.d/sshd
sed -i '/sbin/restorecon /etc/ssh/ssh_host_key.pub/s/^/#/' /etc/init.d/sshd
sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
ssh -V
service sshd restart
vim /etc/ssh/sshd_config
ll
vim /etc/ssh/sshd_config
ps -ef|grep ssh
service sshd start
history
附录:
反查一些OpenSSH需要的动态库,RPM包的安装路径辅助上面参数配置:
rpm -ql openssh-server-5.3p1-122.el6.x86_64
/etc/pam.d/ssh-keycat
/etc/pam.d/sshd
/etc/rc.d/init.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/usr/libexec/openssh/sftp-server
/usr/libexec/openssh/ssh-keycat
/usr/sbin/.sshd.hmac
/usr/sbin/sshd
/usr/share/doc/openssh-server-5.3p1
/usr/share/doc/openssh-server-5.3p1/HOWTO.ssh-keycat
/usr/share/man/man5/moduli.5.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sftp-server.8.gz
/usr/share/man/man8/sshd.8.gz
/var/empty/sshd
ldd /usr/sbin/sshd
linux-vdso.so.1 => (0x00007fffbc5ff000)
libpam.so.0 => /lib64/libpam.so.0 (0x00007f2d19bf3000)
libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f2d1980e000)
librt.so.1 => /lib64/librt.so.1 (0x00007f2d19605000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2d19401000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f2d191fe000)
libz.so.1 => /lib64/libz.so.1 (0x00007f2d18fe7000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f2d18db0000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f2d18b96000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f2d18951000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f2d1866a000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f2d1843e000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f2d18239000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2d17ea5000)
libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f2d17c89000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2d17a6b000)
/lib64/ld-linux-x86-64.so.2 (0x0000003c0e400000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f2d177f4000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f2d175e9000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f2d173e5000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2d171c6000)
rpm -qf /lib64/libpam.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /usr/lib64/libcrypto.so.10 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/librt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libdl.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libutil.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libz.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcrypt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libresolv.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libgssapi_krb5.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libk5crypto.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcom_err.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libc.so.6 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libaudit.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libpthread.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/ld-linux-x86-64.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libfreebl3.so >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5support.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkeyutils.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libselinux.so.1 >> /tmp/jackRpmResult.txt
需要这些包:
rpm -qa|grep audit-libs-2.2-2
rpm -qa|grep glibc-2.12-1.192
rpm -qa|grep keyutils-libs-1.4-5
rpm -qa|grep krb5-libs-1.10.3-65
rpm -qa|grep libcom_err-1.41.12-23
rpm -qa|grep libselinux-2.0.94-7
rpm -qa|grep nss-softokn-freebl-3.14.3-9
rpm -qa|grep openssl-1.0.1e-57
rpm -qa|grep pam-1.1.1-24
rpm -qa|grep zlib-1.2.3-29
yum 安装软件包:
audit-libs-2.2-2 glibc-2.12-1.192 keyutils-libs-1.4-5 krb5-libs-1.10.3-65 libcom_err-1.41.12-23 libselinux-2.0.94-7 nss-softokn-freebl-3.14.3-9 openssl-1.0.1e-57 pam-1.1.1-24 zlib-1.2.3-29
去掉版本号直接安装:
yum install audit-libs glibc keyutils-libs krb5-libs libcom_err libselinux nss-softokn-freebl openssl pam zlib
参考编译来源:
(1)http://blog.chinaunix.net/uid-28266791-id-5759478.html
(2)https://www.cnblogs.com/xshrim/p/6472679.html
Redhat企业级系统的6.7版自带SSH版本为OpenSSH_5.3p1, 基于审计和安全性需求,建议将其升级到最新的OpenSSH版本,当前官网最新版本为7.4p1. 本文档将详细介绍OpenSSH升级的完整步骤。需要说明的是,升级过程中虽然涉及zlib、openssl和openssh的卸载,但是并不会导致当前的ssh远程连接会话断开,因此是可以将整个升级过程写成自动化脚本以进行自动批量部署的。后面咱准备逐步过度到CentOS7了,新版在SSH底层上优化了TCP连接传输功能。在譬如拷贝时会用同一个TCP的FD,而旧版本的是没有这个功能的。再就是刚连接过了在超时设置范围内,再次发起连接时也会复用之前的一个Socket的FD句柄,提高连接效率。
编译安装OpenSSH7.4p1一共分二步,
第一步:安装编译需要的RPM包:
第二步:编译并安装到和原来一样的目录,如下步骤:
tar zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1
ll
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-kerberos5=/usr/lib64/libkrb5.so
make && make install
cp -rf /usr/local/src/openssh-7.4p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp -rf contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
vim /etc/init.d/sshd
sed -i '/sbin/restorecon /etc/ssh/ssh_host_key.pub/s/^/#/' /etc/init.d/sshd
sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
ssh -V
service sshd restart
vim /etc/ssh/sshd_config
ll
vim /etc/ssh/sshd_config
ps -ef|grep ssh
service sshd start
history
附录:
反查一些OpenSSH需要的动态库,RPM包的安装路径辅助上面参数配置:
rpm -ql openssh-server-5.3p1-122.el6.x86_64
/etc/pam.d/ssh-keycat
/etc/pam.d/sshd
/etc/rc.d/init.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/usr/libexec/openssh/sftp-server
/usr/libexec/openssh/ssh-keycat
/usr/sbin/.sshd.hmac
/usr/sbin/sshd
/usr/share/doc/openssh-server-5.3p1
/usr/share/doc/openssh-server-5.3p1/HOWTO.ssh-keycat
/usr/share/man/man5/moduli.5.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sftp-server.8.gz
/usr/share/man/man8/sshd.8.gz
/var/empty/sshd
ldd /usr/sbin/sshd
linux-vdso.so.1 => (0x00007fffbc5ff000)
libpam.so.0 => /lib64/libpam.so.0 (0x00007f2d19bf3000)
libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f2d1980e000)
librt.so.1 => /lib64/librt.so.1 (0x00007f2d19605000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2d19401000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f2d191fe000)
libz.so.1 => /lib64/libz.so.1 (0x00007f2d18fe7000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f2d18db0000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f2d18b96000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f2d18951000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f2d1866a000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f2d1843e000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f2d18239000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2d17ea5000)
libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f2d17c89000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2d17a6b000)
/lib64/ld-linux-x86-64.so.2 (0x0000003c0e400000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f2d177f4000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f2d175e9000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f2d173e5000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2d171c6000)
rpm -qf /lib64/libpam.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /usr/lib64/libcrypto.so.10 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/librt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libdl.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libutil.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libz.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcrypt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libresolv.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libgssapi_krb5.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libk5crypto.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcom_err.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libc.so.6 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libaudit.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libpthread.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/ld-linux-x86-64.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libfreebl3.so >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5support.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkeyutils.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libselinux.so.1 >> /tmp/jackRpmResult.txt
需要这些包:
rpm -qa|grep audit-libs-2.2-2
rpm -qa|grep glibc-2.12-1.192
rpm -qa|grep keyutils-libs-1.4-5
rpm -qa|grep krb5-libs-1.10.3-65
rpm -qa|grep libcom_err-1.41.12-23
rpm -qa|grep libselinux-2.0.94-7
rpm -qa|grep nss-softokn-freebl-3.14.3-9
rpm -qa|grep openssl-1.0.1e-57
rpm -qa|grep pam-1.1.1-24
rpm -qa|grep zlib-1.2.3-29
yum 安装软件包:
audit-libs-2.2-2 glibc-2.12-1.192 keyutils-libs-1.4-5 krb5-libs-1.10.3-65 libcom_err-1.41.12-23 libselinux-2.0.94-7 nss-softokn-freebl-3.14.3-9 openssl-1.0.1e-57 pam-1.1.1-24 zlib-1.2.3-29
去掉版本号直接安装:
yum install audit-libs glibc keyutils-libs krb5-libs libcom_err libselinux nss-softokn-freebl openssl pam zlib
参考编译来源:
(1)http://blog.chinaunix.net/uid-28266791-id-5759478.html
(2)https://www.cnblogs.com/xshrim/p/6472679.html
[实践OK]grep 去除注释行和空行,实现过滤配置文件里面的注释和空行。
Unix/LinuxC技术 jackxiang 2018-8-16 17:34
cat php.ini |grep -v "^;"|grep -v ^$
grep -v ^# /etc/vsftpd/vsftpd.conf |grep -v ^$ >> /etc/vsftpd/vsftpd
来自:http://blog.51cto.com/mange888/806342
grep -v ^# /etc/vsftpd/vsftpd.conf |grep -v ^$ >> /etc/vsftpd/vsftpd
来自:http://blog.51cto.com/mange888/806342
[实践OK]awk自定义函数求平方和实例。
Unix/LinuxC技术 jackxiang 2018-7-30 22:22
$cat pingfang.awk
$cat xy.txt
1 2
3 3
4 3
2 3
$./pingfang.awk xy.txt
sum = 5
sum = 18
sum = 25
sum = 13
这些文章{print 'sum =',SquareSum($1,$2)} 都是单引号,估计都没实践过吧?
参考:https://tieba.baidu.com/f?kz=4897365011&mo_device=1&ssid=0&from=844b&uid=0&pu=usm@0,sz@1320_2001,ta@iphone_1_11.4_3_605&bd_page_type=1&baiduid=F7F621D935F5435074FCC25A0863FC2F&tj=www_normal_5_0_10_title&referer=m.baidu.com?pn=0&
http://blog.sina.cn/dpool/blog/s/blog_4cab1a3701007ya9.html
$cat xy.txt
1 2
3 3
4 3
2 3
$./pingfang.awk xy.txt
sum = 5
sum = 18
sum = 25
sum = 13
这些文章{print 'sum =',SquareSum($1,$2)} 都是单引号,估计都没实践过吧?
参考:https://tieba.baidu.com/f?kz=4897365011&mo_device=1&ssid=0&from=844b&uid=0&pu=usm@0,sz@1320_2001,ta@iphone_1_11.4_3_605&bd_page_type=1&baiduid=F7F621D935F5435074FCC25A0863FC2F&tj=www_normal_5_0_10_title&referer=m.baidu.com?pn=0&
http://blog.sina.cn/dpool/blog/s/blog_4cab1a3701007ya9.html
[实践OK]注释斜杠或井号在粘贴到vim时,VIM里的格式会乱掉的解决办法
Unix/LinuxC技术 jackxiang 2018-7-30 14:30
实践成功如下:
vim中 输入 :set
:set
--- Options ---
comments=:# filetype=yaml pastetoggle=<F9> ttymouse=xterm2
cscopetag helplang=en ruler viminfo='20,"50
cscopeverbose history=50 syntax=yaml t_Sb=^[[4%dm
expandtab hlsearch ttyfast t_Sf=^[[3%dm
backspace=indent,eol,start
commentstring=# %s
cscopeprg=/usr/bin/cscope
fileencodings=ucs-bom,utf-8,latin1
formatoptions=croql
guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
ormatoptions=croql
这个选项,希望在~/.vimrc中禁止,比如设置为
set formatoptions=tcpmM
但是vim不识别此行,报错.无法禁止这个选项....
经过百度搜索,发现解决方案.[比较恶心 开源软件的就是配置文件 不人性化]
在粘贴前先设置进入粘贴插入模式,即不会自动缩进和连续注释
set paste
然后再进入插入模式粘贴,啥注释的#号或双斜杠都不影响。AddTime:2018-07-30
在粘贴插入模式下代码是不会自动按格式缩进的,需要使用nopaste设置回来
set nopaste
也可以在.vimrc中设置切换的快捷键,比如设置F9,则可以在.vimrc中加入:
set pastetoggle=<F9>
这样直接在插入模式按F9就会在“-- 插入 --”模式和“-- 插入(粘贴) --”模式中切换
说的就是这个设置:
================================================================================
ecureCRT会将你原来的文本原封不动的按照字符串的样式发送给服务器。所以当你的服务器上的vim设置为autoindent的话,在i模式下,那么它会将secureCRT传输而来的这些字符串再进行一下缩进。若你拷贝的文本中已经有表示缩进的空格或者制表符的话,它们也会被当成字符串,而被缩进。
解决办法:
1. 在拷贝前输入:set paste (这样的话,vim就不会启动自动缩进,而只是纯拷贝粘贴)
2. 拷贝完成之后,输入:set nopaste (关闭paste)
来自:
https://blog.csdn.net/kwame211/article/details/77964106
https://blog.csdn.net/chenghai37/article/details/80698322
vim复制代码包含注释时格式会乱掉的解决办法:
每次复制代码时,如果代码里有 // 这样的注释就容易让格式乱掉,通过下面的设置就可以避免这种情况。
粘贴代码时取消自动缩进
VIM在粘贴代码时会自动缩进,把代码搞得一团糟糕,甚至可能因为某行的一个注释造成后面的代码全部被注释掉,我知道有同学这个时候会用vi去打开文件再粘贴上去(鄙人以前就是这样),其实需要先设置一下
set paste
然后再进入插入模式粘贴,代码就不会被自动缩进。可是敲代码的时候需要自动缩进,又得改回来:
set nopaste
最方便的方法就是在.vimrc中加一句:
set pastetoggle=<F9>
以后在插入模式下,只要按F9键就可以切换自动缩进。
来自:https://blog.csdn.net/tao_627/article/details/18764539
vim中 输入 :set
:set
--- Options ---
comments=:# filetype=yaml pastetoggle=<F9> ttymouse=xterm2
cscopetag helplang=en ruler viminfo='20,"50
cscopeverbose history=50 syntax=yaml t_Sb=^[[4%dm
expandtab hlsearch ttyfast t_Sf=^[[3%dm
backspace=indent,eol,start
commentstring=# %s
cscopeprg=/usr/bin/cscope
fileencodings=ucs-bom,utf-8,latin1
formatoptions=croql
guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
ormatoptions=croql
这个选项,希望在~/.vimrc中禁止,比如设置为
set formatoptions=tcpmM
但是vim不识别此行,报错.无法禁止这个选项....
经过百度搜索,发现解决方案.[比较恶心 开源软件的就是配置文件 不人性化]
在粘贴前先设置进入粘贴插入模式,即不会自动缩进和连续注释
set paste
然后再进入插入模式粘贴,啥注释的#号或双斜杠都不影响。AddTime:2018-07-30
在粘贴插入模式下代码是不会自动按格式缩进的,需要使用nopaste设置回来
set nopaste
也可以在.vimrc中设置切换的快捷键,比如设置F9,则可以在.vimrc中加入:
set pastetoggle=<F9>
这样直接在插入模式按F9就会在“-- 插入 --”模式和“-- 插入(粘贴) --”模式中切换
说的就是这个设置:
================================================================================
ecureCRT会将你原来的文本原封不动的按照字符串的样式发送给服务器。所以当你的服务器上的vim设置为autoindent的话,在i模式下,那么它会将secureCRT传输而来的这些字符串再进行一下缩进。若你拷贝的文本中已经有表示缩进的空格或者制表符的话,它们也会被当成字符串,而被缩进。
解决办法:
1. 在拷贝前输入:set paste (这样的话,vim就不会启动自动缩进,而只是纯拷贝粘贴)
2. 拷贝完成之后,输入:set nopaste (关闭paste)
来自:
https://blog.csdn.net/kwame211/article/details/77964106
https://blog.csdn.net/chenghai37/article/details/80698322
vim复制代码包含注释时格式会乱掉的解决办法:
每次复制代码时,如果代码里有 // 这样的注释就容易让格式乱掉,通过下面的设置就可以避免这种情况。
粘贴代码时取消自动缩进
VIM在粘贴代码时会自动缩进,把代码搞得一团糟糕,甚至可能因为某行的一个注释造成后面的代码全部被注释掉,我知道有同学这个时候会用vi去打开文件再粘贴上去(鄙人以前就是这样),其实需要先设置一下
set paste
然后再进入插入模式粘贴,代码就不会被自动缩进。可是敲代码的时候需要自动缩进,又得改回来:
set nopaste
最方便的方法就是在.vimrc中加一句:
set pastetoggle=<F9>
以后在插入模式下,只要按F9键就可以切换自动缩进。
来自:https://blog.csdn.net/tao_627/article/details/18764539
[实践OK]阿里云授时服务器之公共NTP服务器
Unix/LinuxC技术 jackxiang 2018-7-30 13:28
来自:https://eallion.com/aliyun-ntp
公共NTP服务器
Unix类系统:time1-7.aliyun.com 8台:
我也不知道是怎么想的,
随手就去搜索了“阿里云 NTP”,
结果还真有!
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
Windows: time.pool.aliyun.com
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
#/usr/sbin/ntpdate ntp1.aliyun.com
30 Jul 13:27:42 ntpdate[32557]: step time server 120.25.115.20 offset 486.889850 sec
#sed -n 's#ntp.ksyun.cn#ntp1.aliyun.com#p' /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
正式替换:
sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#' /var/spool/cron/root
成功替换:
cat /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
Ansbile批量替换:
ansible applet -a"sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#' /var/spool/cron/root"
公共NTP服务器
Unix类系统:time1-7.aliyun.com 8台:
我也不知道是怎么想的,
随手就去搜索了“阿里云 NTP”,
结果还真有!
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
Windows: time.pool.aliyun.com
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
#/usr/sbin/ntpdate ntp1.aliyun.com
30 Jul 13:27:42 ntpdate[32557]: step time server 120.25.115.20 offset 486.889850 sec
#sed -n 's#ntp.ksyun.cn#ntp1.aliyun.com#p' /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
正式替换:
sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#' /var/spool/cron/root
成功替换:
cat /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
Ansbile批量替换:
ansible applet -a"sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#' /var/spool/cron/root"
[实践Ok]#deprecation_warnings = True允许在ansible-playbook输出结果中禁用“不建议使用”警告
Unix/LinuxC技术 jackxiang 2018-7-26 11:40
ansible applet -m ping
[DEPRECATION WARNING]: DEFAULT_SUDO_EXE option, In favor of Ansible Become, which is a generic framework. See become_exe. ,
use become instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: DEFAULT_MODULE_LANG option, Modules are coded to set their own locale if needed for screenscraping .
This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
#deprecation_warnings = True 允许在ansible-playbook输出结果中禁用“不建议使用”警告
vi /etc/ansible/ansible.cfg
解决办法:
#deprecation_warnings = True
deprecation_warnings = false
[DEPRECATION WARNING]: DEFAULT_SUDO_EXE option, In favor of Ansible Become, which is a generic framework. See become_exe. ,
use become instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: DEFAULT_MODULE_LANG option, Modules are coded to set their own locale if needed for screenscraping .
This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
#deprecation_warnings = True 允许在ansible-playbook输出结果中禁用“不建议使用”警告
vi /etc/ansible/ansible.cfg
解决办法:
#deprecation_warnings = True
deprecation_warnings = false
[实践OK]如何调试Systemctl查看开机启动列表systemctl list-unit-files | grep enable,以memcached为例。查看开机启动:ls /etc/systemd/system/multi-user.target.wants/
Unix/LinuxC技术 jackxiang 2018-7-21 14:31
CentOS7.X下如何查看并将一个应用设置为开机启动?systemctl start slapd 只是启动,并不是开机启动。
背景:有时候我们使用systemctl命令,如简单点的systemctl start memcached来讲,出现错时,会有一些提示,但是提示的内容是变量,其并没有将参数给编译后的值放入,于是出现如下所示,但是要失败了怎么排查这些参数呢?此文就讲这个问题,如果不是为了linux开机启动提速而并行启动外,这个systemctl其本质是想接管很多东西,但也带来了很多麻烦,难怪linus对此有一定的意见,系统要保持简单,好用。像开机慢可以少开机或不关机嘛,学学人家苹果升级在半夜,你慢就慢,谁管你,从策略上就规避了,把技术搞复杂还是简单是一门哲学,而创始人的价值就在于坚守设计艺术,而不光是技术。
● memcached.service - Memcached
Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2018-07-20 18:48:50 CST; 19h ago
Process: 15266 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 15266 (code=exited, status=0/SUCCESS)
失败:
systemctl start memcached
Job for memcached.service failed because the control process exited with error code. See "systemctl status memcached.service" and "journalctl -xe" for details.
/etc/sysconfig/memcached
systemctl daemon-reload
systemctl start memcached
systemctl status memcached.service
Active: failed (Result: exit-code) since Sat 2018-07-21 14:35:22 CST; 5s ago
Process: 11417 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=71)
Process: 11399 ExecStartPre=/bin/bash -l -c echo "/usr/local/memcached/bin/memcached" -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS > /tmp/systemctl.debug (code=exited, status=0/SUCCESS)
Main PID: 11417 (code=exited, status=71)
如果有错,需要挑食的参数查看 /tmp/systemctl.debug:
cat /tmp/systemctl.debug
/usr/local/memcached/bin/memcached -u root -p 11211 -m 64 -c 1024 -vv >> /data/logs/memcached/11211/memcached.log 2>&1
背景:有时候我们使用systemctl命令,如简单点的systemctl start memcached来讲,出现错时,会有一些提示,但是提示的内容是变量,其并没有将参数给编译后的值放入,于是出现如下所示,但是要失败了怎么排查这些参数呢?此文就讲这个问题,如果不是为了linux开机启动提速而并行启动外,这个systemctl其本质是想接管很多东西,但也带来了很多麻烦,难怪linus对此有一定的意见,系统要保持简单,好用。像开机慢可以少开机或不关机嘛,学学人家苹果升级在半夜,你慢就慢,谁管你,从策略上就规避了,把技术搞复杂还是简单是一门哲学,而创始人的价值就在于坚守设计艺术,而不光是技术。
● memcached.service - Memcached
Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2018-07-20 18:48:50 CST; 19h ago
Process: 15266 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 15266 (code=exited, status=0/SUCCESS)
失败:
systemctl start memcached
Job for memcached.service failed because the control process exited with error code. See "systemctl status memcached.service" and "journalctl -xe" for details.
/etc/sysconfig/memcached
systemctl daemon-reload
systemctl start memcached
systemctl status memcached.service
Active: failed (Result: exit-code) since Sat 2018-07-21 14:35:22 CST; 5s ago
Process: 11417 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=71)
Process: 11399 ExecStartPre=/bin/bash -l -c echo "/usr/local/memcached/bin/memcached" -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS > /tmp/systemctl.debug (code=exited, status=0/SUCCESS)
Main PID: 11417 (code=exited, status=71)
如果有错,需要挑食的参数查看 /tmp/systemctl.debug:
cat /tmp/systemctl.debug
/usr/local/memcached/bin/memcached -u root -p 11211 -m 64 -c 1024 -vv >> /data/logs/memcached/11211/memcached.log 2>&1
[实践OK]Linux下的netstat查看所有端口/TCP/UDP端口常用参数总结。
Unix/LinuxC技术 jackxiang 2018-7-15 09:28
netstat -lntp #常用命令参数及解释如下:主要是看IP和TCP,以及程序的PID。
-l, --listening display listening server sockets
-n, --numeric don't resolve names
-t, tcp
-p, --program
Show the PID and name of the program to which each socket belongs.
一)netstat常用查看端口参数之查看所有tcp/udp端口:
netstat -atlunp|grep 80
二)netstat常用查看端口参数之单独查看tcp/udp端口命令:
netstat -uln
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:808 0.0.0.0:*
udp 0 0 127.0.0.1:837 0.0.0.0:*
udp 0 0 0.0.0.0:17617 0.0.0.0:*
udp 0 0 0.0.0.0:2392 0.0.0.0:*
假如没有n,直接用netstat -tl,显示的是一些端口的程序名,如下:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:5646 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:7824 *:* LISTEN
tcp 0 0 *:webcache *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:5881 *:* LISTEN
三)netstat常用查看端口参数之单独查看tcp端口命令:
netstat -tln
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:34945 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:32740 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:15770 0.0.0.0:* LISTEN
四)netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的
netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的。我们只要依样画葫芦对此文件进行 解析(主要是合并ipv4和ipv6的内容,然后从16进制转换成字符串形式的ip,端口),然后再比对一下,只要发现此socket的远程ip和端口和 php中的$_SERVER['REMOTE_ADDR'],$_SERVER['REMOTE_PORT']相匹配即可。具体实现如下:
摘录:http://www.4shell.org/archives/2064.html
参考:http://www.80sec.com/security-issue-on-linux-fd-inheritance.html
-l, --listening display listening server sockets
-n, --numeric don't resolve names
-t, tcp
-p, --program
Show the PID and name of the program to which each socket belongs.
一)netstat常用查看端口参数之查看所有tcp/udp端口:
netstat -atlunp|grep 80
二)netstat常用查看端口参数之单独查看tcp/udp端口命令:
netstat -uln
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:808 0.0.0.0:*
udp 0 0 127.0.0.1:837 0.0.0.0:*
udp 0 0 0.0.0.0:17617 0.0.0.0:*
udp 0 0 0.0.0.0:2392 0.0.0.0:*
假如没有n,直接用netstat -tl,显示的是一些端口的程序名,如下:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:5646 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:7824 *:* LISTEN
tcp 0 0 *:webcache *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:5881 *:* LISTEN
三)netstat常用查看端口参数之单独查看tcp端口命令:
netstat -tln
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:34945 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:32740 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:15770 0.0.0.0:* LISTEN
四)netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的
netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的。我们只要依样画葫芦对此文件进行 解析(主要是合并ipv4和ipv6的内容,然后从16进制转换成字符串形式的ip,端口),然后再比对一下,只要发现此socket的远程ip和端口和 php中的$_SERVER['REMOTE_ADDR'],$_SERVER['REMOTE_PORT']相匹配即可。具体实现如下:
摘录:http://www.4shell.org/archives/2064.html
参考:http://www.80sec.com/security-issue-on-linux-fd-inheritance.html
SecureCrt 设置在同一窗口下打开会话
Unix/LinuxC技术 jackxiang 2018-7-7 15:54
SecureCrt某个设置不合朕的心意,在打开一个新的连接时不是在同一个窗口下,它又新开了一个工作窗口,像下面这样,操作起来让人很不爽:
一个SSH打一一个SecureCRT,
解决方案:点击 File -> Connect In Tab/Tile 连接新的会话
来自:https://blog.csdn.net/u012135425/article/details/79487575
一个SSH打一一个SecureCRT,
解决方案:点击 File -> Connect In Tab/Tile 连接新的会话
来自:https://blog.csdn.net/u012135425/article/details/79487575
背景:在Linux下习惯使用ll、la、l等ls别名的童鞋到mac os可就郁闷了,
whichi ll
-bash: whichi: command not found
[xiangdong@jenkins_server_bj_sjs_10_71_182_25 .ssh]$ which ll
alias ll='ls -l --color=auto'
/bin/ls
其实只要在用户目录下建立一个脚本“.bash_profile”,并输入以下内容即可:
ls -l --color=auto
1 2014-461deMacBook-Pro:~ root# cd ~
2 2014-461deMacBook-Pro:~ root#vim .bash_profile
加入:
保存后,执行
3 2014-461deMacBook-Pro:~ root#source .bash_profile
=============================================
.bash_profile
alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'
alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'
然后在终端窗口中输入下列命令后,别名即可立即生效:
source ~/.bash_profile
source ~/.bash_profile
如果不知道如何创建,可以直接在“终端”窗口中依次执行如下命令:
.bash_profile完整创建命令Shell
cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile
cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile
来自:https://clang.cn/blog/749.html
https://www.cnblogs.com/daly2008/p/4160066.html
whichi ll
-bash: whichi: command not found
[xiangdong@jenkins_server_bj_sjs_10_71_182_25 .ssh]$ which ll
alias ll='ls -l --color=auto'
/bin/ls
其实只要在用户目录下建立一个脚本“.bash_profile”,并输入以下内容即可:
ls -l --color=auto
1 2014-461deMacBook-Pro:~ root# cd ~
2 2014-461deMacBook-Pro:~ root#vim .bash_profile
加入:
保存后,执行
3 2014-461deMacBook-Pro:~ root#source .bash_profile
=============================================
.bash_profile
alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'
alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'
然后在终端窗口中输入下列命令后,别名即可立即生效:
source ~/.bash_profile
source ~/.bash_profile
如果不知道如何创建,可以直接在“终端”窗口中依次执行如下命令:
.bash_profile完整创建命令Shell
cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile
cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile
来自:https://clang.cn/blog/749.html
https://www.cnblogs.com/daly2008/p/4160066.html
[实践OK]在CentOS7上安装并配置Python3.8.1环境,新版本Python3.6.2支持Ansible的,和pip3 pip 安装 pdb调试程序如 python -m pdb mail.py,涉及到yum里的python本维持旧版本也需要修改其指向旧版本。
Unix/LinuxC技术 jackxiang 2018-6-21 10:20
背景:Python很火,且连一些如ESP8266的硬件都支持Python了。
目前Python存在两个版本Python2和Python3系列,且这两个版本同时在更新与维护。到底是选择Python2还是选择Python3,取决于当前要使用的库、框架支持哪个版本。因此一台电脑上可能需要同时安装Python2和Python3两个版本。本文主要讲述的是如何在centos7系统中存在python2系列的同时安装python3.8.1(目前python3系列的最新版本)
1.安装升级相应的软件包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
2.下载python 3.8.1 的源码包
wget http://mirrors.sohu.com/python/3.8.1/Python-3.8.1.tgz
3.安装python3.8.1
tar zxvf Python-3.8.1.tgz -C /opt/
cd /opt/Python-3.8.1/
./configure --prefix=/usr/local/python3
make && make install
若遇到编译问题:
zipimport.ZipImportError: can't decompress data; zlib not available #make && make install
yum install zlib zlib-devel -y
4.配置python,配置python3 pip3 软链接,设置软连接:目的是让我们直接在任何地方输入python3命令都可以得到python解释器的运行。
更改/usr/bin/python链接:
ln -s /usr/local/python3/bin/python3.8.1 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
mv /usr/bin/pip{,.backup}
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip #python2-pip没有,就没有这个pip.
查看是否安装成功
python3 -V
pip3 -V
更改/usr/bin/python默认链接,实现升级:
/usr/bin/python --version
Python 2.7.5
mv /usr/bin/python{,.old.backup}
ln -sf /usr/local/python3/bin/python3.8 /usr/bin/python
5.查看当python的版本,出现版本信息即为正确安装
python3 --version
安装python3.7出现ModuleNotFoundError: No module named '_ctypes'报错(重新编译一次就OK了)
来自:https://mhl.xyz/Python/python37_ctypes.html
6.更改yum脚本的python依赖
yum localinstall mysql-5.7.12-171123111505.el7.centos.x86_64.rpm
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
# ls /usr/bin/yum*
# ls yum*
yum yum-config-manager yum-debug-restore yum-groups-manager
yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python 改为 #!/usr/bin/python2
用Sed 一行搞定,参考自[实践OK]经常用到之linux sed 批量替换字符串,及模糊替换和模糊拼接的例子。http://jackxiang.com/post/2324/:
/usr/bin/yum-groups-manager #!/usr/bin/python -tt
/usr/bin/yumdownloader #直接python后面有一个空格
/usr/bin/yum-debug-restore #!/usr/bin/python -tt
/usr/bin/yum-debug-dump #!/usr/bin/python -tt
/usr/bin/yum-config-manager #!/usr/bin/python -tt
/usr/bin/yum-builddep #!/usr/bin/python -tt
/usr/bin/yum #python后面无空格
势必要有两种替换:
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-builddep
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-config-manager
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-dump
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-restore
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yumdownloader
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-groups-manager
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/bin/yum
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/libexec/urlgrabber-ext-down
这个-tt的没有啥用,只是起到警告作用,完全在替换时不要:
-t Issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it
depend on the worth of a tab expressed in spaces. Issue an error when the option is given twice.
-t 当源文件以制作缩进的方式混合制表符和空格时发出警告
取决于用空格表示的选项卡的价值。 当该选项被赋予两次时发出一个错误。
7.测试用Python的Pip3安装Python扩展:
rpm -qf /bin/pip
python2-pip-8.1.2-5.el7.noarch
/bin/pip --version
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
pip3 --version
pip 9.0.1 from /usr/local/python3/lib/python3.8.1/site-packages (python 3.8.1)
pip3 install PyEmail
Collecting PyEmail
Downloading https://files.pythonhosted.org/packages/ca/39/caf0436670b6fa9f072e322fab1a2b04d5631bdbdc8ea9857230aae02dd5/PyEmail-0.0.1.zip
Installing collected packages: PyEmail
Running setup.py install for PyEmail ... done
Successfully installed PyEmail-0.0.1
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip3 install ipdb
Collecting ipdb
Downloading https://files.pythonhosted.org/packages/80/fe/4564de08f174f3846364b3add8426d14cebee228f741c27e702b2877e85b/ipdb-0.11.tar.gz
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.8.1/site-packages (from ipdb)
Collecting ipython>=5.0.0 (from ipdb)
Downloading https://files.pythonhosted.org/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
62% |████████████████████ | 471kB 54kB/s eta 0:00:06
好一会下载安装就能装上这个,但是提示:You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
pip install --upgrade pip
pip install ipdb #再一次安装这个Python的调试扩展
python -m pdb mail.py
最后,这些脚本总结起来放一块就这些,方便后期再安装之用:
来自:https://blog.csdn.net/hobohero/article/details/54381475
来自:https://blog.csdn.net/wjqwinn/article/details/75633714
目前Python存在两个版本Python2和Python3系列,且这两个版本同时在更新与维护。到底是选择Python2还是选择Python3,取决于当前要使用的库、框架支持哪个版本。因此一台电脑上可能需要同时安装Python2和Python3两个版本。本文主要讲述的是如何在centos7系统中存在python2系列的同时安装python3.8.1(目前python3系列的最新版本)
1.安装升级相应的软件包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
2.下载python 3.8.1 的源码包
wget http://mirrors.sohu.com/python/3.8.1/Python-3.8.1.tgz
3.安装python3.8.1
tar zxvf Python-3.8.1.tgz -C /opt/
cd /opt/Python-3.8.1/
./configure --prefix=/usr/local/python3
make && make install
若遇到编译问题:
zipimport.ZipImportError: can't decompress data; zlib not available #make && make install
yum install zlib zlib-devel -y
4.配置python,配置python3 pip3 软链接,设置软连接:目的是让我们直接在任何地方输入python3命令都可以得到python解释器的运行。
更改/usr/bin/python链接:
ln -s /usr/local/python3/bin/python3.8.1 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
mv /usr/bin/pip{,.backup}
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip #python2-pip没有,就没有这个pip.
查看是否安装成功
python3 -V
pip3 -V
更改/usr/bin/python默认链接,实现升级:
/usr/bin/python --version
Python 2.7.5
mv /usr/bin/python{,.old.backup}
ln -sf /usr/local/python3/bin/python3.8 /usr/bin/python
5.查看当python的版本,出现版本信息即为正确安装
python3 --version
安装python3.7出现ModuleNotFoundError: No module named '_ctypes'报错(重新编译一次就OK了)
来自:https://mhl.xyz/Python/python37_ctypes.html
6.更改yum脚本的python依赖
yum localinstall mysql-5.7.12-171123111505.el7.centos.x86_64.rpm
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
# ls /usr/bin/yum*
# ls yum*
yum yum-config-manager yum-debug-restore yum-groups-manager
yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python 改为 #!/usr/bin/python2
用Sed 一行搞定,参考自[实践OK]经常用到之linux sed 批量替换字符串,及模糊替换和模糊拼接的例子。http://jackxiang.com/post/2324/:
/usr/bin/yum-groups-manager #!/usr/bin/python -tt
/usr/bin/yumdownloader #直接python后面有一个空格
/usr/bin/yum-debug-restore #!/usr/bin/python -tt
/usr/bin/yum-debug-dump #!/usr/bin/python -tt
/usr/bin/yum-config-manager #!/usr/bin/python -tt
/usr/bin/yum-builddep #!/usr/bin/python -tt
/usr/bin/yum #python后面无空格
势必要有两种替换:
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-builddep
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-config-manager
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-dump
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-restore
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yumdownloader
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-groups-manager
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/bin/yum
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/libexec/urlgrabber-ext-down
这个-tt的没有啥用,只是起到警告作用,完全在替换时不要:
-t Issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it
depend on the worth of a tab expressed in spaces. Issue an error when the option is given twice.
-t 当源文件以制作缩进的方式混合制表符和空格时发出警告
取决于用空格表示的选项卡的价值。 当该选项被赋予两次时发出一个错误。
7.测试用Python的Pip3安装Python扩展:
rpm -qf /bin/pip
python2-pip-8.1.2-5.el7.noarch
/bin/pip --version
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
pip3 --version
pip 9.0.1 from /usr/local/python3/lib/python3.8.1/site-packages (python 3.8.1)
pip3 install PyEmail
Collecting PyEmail
Downloading https://files.pythonhosted.org/packages/ca/39/caf0436670b6fa9f072e322fab1a2b04d5631bdbdc8ea9857230aae02dd5/PyEmail-0.0.1.zip
Installing collected packages: PyEmail
Running setup.py install for PyEmail ... done
Successfully installed PyEmail-0.0.1
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip3 install ipdb
Collecting ipdb
Downloading https://files.pythonhosted.org/packages/80/fe/4564de08f174f3846364b3add8426d14cebee228f741c27e702b2877e85b/ipdb-0.11.tar.gz
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.8.1/site-packages (from ipdb)
Collecting ipython>=5.0.0 (from ipdb)
Downloading https://files.pythonhosted.org/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
62% |████████████████████ | 471kB 54kB/s eta 0:00:06
好一会下载安装就能装上这个,但是提示:You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
pip install --upgrade pip
pip install ipdb #再一次安装这个Python的调试扩展
python -m pdb mail.py
最后,这些脚本总结起来放一块就这些,方便后期再安装之用:
来自:https://blog.csdn.net/hobohero/article/details/54381475
来自:https://blog.csdn.net/wjqwinn/article/details/75633714
kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
Unix/LinuxC技术 jackxiang 2018-6-11 17:51
用ssh登录阿里云centos7主机,过一会儿会自动出现以下信息,
Message from syslogd@docker_test_bj_sjs_10_71_159_108 at Jun 11 17:49:08 ...
kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
在这个信息中,我这里按ctrl+c可以退回到, 有兄弟说是内核版本太低,升级内核:
起因:
安装了Docker容器,运行过程中报:kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
相似问题描述:https://segmentfault.com/q/1010000007045424
解决办法:https://github.com/moby/moby/issues/5618
尝试升级到最新的4.19+内核。
1.查看操作系统版本
https://blog.csdn.net/lijing742180/article/details/80662062
2.查看内核版本
uname -sr
3.升级的三种方案
参考:
https://blog.csdn.net/breeze915/article/details/79243673
https://blog.csdn.net/qq_27281257/article/details/82049634
https://blog.csdn.net/RBPicsdn/article/details/79642932
4.删除旧内核
https://blog.csdn.net/RBPicsdn/article/details/79642932
rpm -qa | grep kernel
sudo yum remove -y 旧内核的名字就好了
术语解析:
术语解析
kernel-ml
kernel-ml 中的ml是英文【mainline stable】的缩写,elrepo-kernel中罗列出来的是最新的稳定主线版本。
kernel-lt
kernel-lt 中的lt是英文【long term support】的缩写,elrepo-kernel中罗列出来的长期支持版本。
转载至链接:https://my.oschina.net/boreboluomiduo/blog/3035332。
摘自:https://www.liangzl.com/get-article-detail-123785.html
https://m.aliyun.com/yunqi/ask/2877/
Message from syslogd@docker_test_bj_sjs_10_71_159_108 at Jun 11 17:49:08 ...
kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
在这个信息中,我这里按ctrl+c可以退回到, 有兄弟说是内核版本太低,升级内核:
起因:
安装了Docker容器,运行过程中报:kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
相似问题描述:https://segmentfault.com/q/1010000007045424
解决办法:https://github.com/moby/moby/issues/5618
尝试升级到最新的4.19+内核。
1.查看操作系统版本
https://blog.csdn.net/lijing742180/article/details/80662062
2.查看内核版本
uname -sr
3.升级的三种方案
参考:
https://blog.csdn.net/breeze915/article/details/79243673
https://blog.csdn.net/qq_27281257/article/details/82049634
https://blog.csdn.net/RBPicsdn/article/details/79642932
4.删除旧内核
https://blog.csdn.net/RBPicsdn/article/details/79642932
rpm -qa | grep kernel
sudo yum remove -y 旧内核的名字就好了
术语解析:
术语解析
kernel-ml
kernel-ml 中的ml是英文【mainline stable】的缩写,elrepo-kernel中罗列出来的是最新的稳定主线版本。
kernel-lt
kernel-lt 中的lt是英文【long term support】的缩写,elrepo-kernel中罗列出来的长期支持版本。
转载至链接:https://my.oschina.net/boreboluomiduo/blog/3035332。
摘自:https://www.liangzl.com/get-article-detail-123785.html
https://m.aliyun.com/yunqi/ask/2877/
[root@localhost ~]# mount -t xfs /dev/sdb /data
mount: mount /dev/sdb on /data failed: Structure needs cleaning
--------------------------
可以使用xfs_repair来修复,但是要注意 xfs_repair修复的分区中的文件都会丢失,即使是du能正常显示的文件也会丢失。
[root@yw-0-0 /]# mount -a
mount: Structure needs cleaning
[root@yw-0-0 /]# xfs_repair /dev/sdl
来自:http://blog.51cto.com/zwcmcm/1650764
mount: mount /dev/sdb on /data failed: Structure needs cleaning
--------------------------
可以使用xfs_repair来修复,但是要注意 xfs_repair修复的分区中的文件都会丢失,即使是du能正常显示的文件也会丢失。
[root@yw-0-0 /]# mount -a
mount: Structure needs cleaning
[root@yw-0-0 /]# xfs_repair /dev/sdl
来自:http://blog.51cto.com/zwcmcm/1650764
[实践发现]yum update -y 升级到centos7.5后mkfs.ext4突然没了,Raspberry Pi挂载NTFS磁盘。
Unix/LinuxC技术 jackxiang 2018-5-31 18:17
mkfs.ext4 经yum update的升级到CentOS7.5后没了mkfs.ext4,于是 得安装:
安装https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/Packages/e2fsprogs-1.42.9-11.el7.x86_64.rpm这个包
[root@iZ889v050nrZ:~]
#cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@iZ889v050nrZ:~]
#rpm -qf /sbin/mkfs.ext4
e2fsprogs-1.42.9-11.el7.x86_64
===========Raspberry挂载NTFS磁盘=====================
[root@mainboard_virtualbox_docker_10_10_0_106:~]
#ssh -l pi 10.10.0.38
fdisk -l
mkfs.ext4 -T largefile4 -n /dev/sda
mkfs.ext4 -T largefile4 -n /dev/sdb
root@raspberrypi:~# dmesg |tail
[ 2296.301317] sdb: sdb1 sdb2
[ 2334.288011] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0xe3c9e316)
[ 2334.288031] F2FS-fs (sda): Can't find valid F2FS filesystem in 1th superblock
[ 2334.288912] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[ 2334.288926] F2FS-fs (sda): Can't find valid F2FS filesystem in 2th superblock
[ 2334.288980] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0xe3c9e316)
[ 2334.288988] F2FS-fs (sda): Can't find valid F2FS filesystem in 1th superblock
[ 2334.288998] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[ 2334.289006] F2FS-fs (sda): Can't find valid F2FS filesystem in 2th superblock
[ 2512.016847] EXT4-fs (sda): VFS: Can't find ext4 filesystem
mkfs.ext3 -T largefile4 -n /dev/sda
mkfs.ext3 -T largefile4 -n /dev/sdb
mount -t ext3 /dev/sda /data0
mount -t ext3 /dev/sdb /data1
mount -t ntfs-3g /dev/sda /data0
mount: unknown filesystem type 'ntfs-3g'
sudo apt-get install ntfs-3g #From:https://www.cnblogs.com/-jimmy-/p/6986010.html
源不行,看末尾成功加清华源,且要注意版本(E: The repository 'http://archive.raspbian.org/raspbian wheezy Release' does no longer have a Release file.):
https://blog.csdn.net/qq_35586327/article/details/94597760?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-3-94597760.nonecase&utm_term=%E6%A0%91%E8%8E%93%E6%B4%BE%E6%B2%A1%E6%9C%89release%E6%96%87%E4%BB%B6
mainboard_virtualbox_docker_10_10_0_106 (1) 跳板登录:
root@raspberrypi:~# sudo apt-get install ntfs-3g --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libntfs-3g871
The following NEW packages will be installed:
libntfs-3g871 ntfs-3g
0 upgraded, 2 newly installed, 0 to remove and 309 not upgraded.
Need to get 540 kB of archives.
After this operation, 1,665 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian stretch/main armhf libntfs-3g871 armhf 1:2016.2.22AR.1+dfsg-1+deb9u1 [165 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian stretch/main armhf ntfs-3g armhf 1:2016.2.22AR.1+dfsg-1+deb9u1 [375 kB]
Fetched 540 kB in 0s (1,628 kB/s)
Selecting previously unselected package libntfs-3g871.
(Reading database ... 127338 files and directories currently installed.)
Preparing to unpack .../libntfs-3g871_1%3a2016.2.22AR.1+dfsg-1+deb9u1_armhf.deb ...
Unpacking libntfs-3g871 (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Selecting previously unselected package ntfs-3g.
Preparing to unpack .../ntfs-3g_1%3a2016.2.22AR.1+dfsg-1+deb9u1_armhf.deb ...
Unpacking ntfs-3g (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Processing triggers for initramfs-tools (0.130) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libntfs-3g871 (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Setting up ntfs-3g (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for initramfs-tools (0.130) ...
root@raspberrypi:~#
b
The value '\stable' is invalid for APT::Default-Release as such a release is not available in the sources
rm -rf /etc/apt/apt.conf.d/10defaultRelease
E: Unable to correct problems, you have held broken packages.
解决方案是先upgrade后update:
$ sudo apt-get upgrade
$ sudo apt-get update
源的问题:
安装https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/Packages/e2fsprogs-1.42.9-11.el7.x86_64.rpm这个包
[root@iZ889v050nrZ:~]
#cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@iZ889v050nrZ:~]
#rpm -qf /sbin/mkfs.ext4
e2fsprogs-1.42.9-11.el7.x86_64
===========Raspberry挂载NTFS磁盘=====================
[root@mainboard_virtualbox_docker_10_10_0_106:~]
#ssh -l pi 10.10.0.38
fdisk -l
mkfs.ext4 -T largefile4 -n /dev/sda
mkfs.ext4 -T largefile4 -n /dev/sdb
root@raspberrypi:~# dmesg |tail
[ 2296.301317] sdb: sdb1 sdb2
[ 2334.288011] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0xe3c9e316)
[ 2334.288031] F2FS-fs (sda): Can't find valid F2FS filesystem in 1th superblock
[ 2334.288912] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[ 2334.288926] F2FS-fs (sda): Can't find valid F2FS filesystem in 2th superblock
[ 2334.288980] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0xe3c9e316)
[ 2334.288988] F2FS-fs (sda): Can't find valid F2FS filesystem in 1th superblock
[ 2334.288998] F2FS-fs (sda): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[ 2334.289006] F2FS-fs (sda): Can't find valid F2FS filesystem in 2th superblock
[ 2512.016847] EXT4-fs (sda): VFS: Can't find ext4 filesystem
mkfs.ext3 -T largefile4 -n /dev/sda
mkfs.ext3 -T largefile4 -n /dev/sdb
mount -t ext3 /dev/sda /data0
mount -t ext3 /dev/sdb /data1
mount -t ntfs-3g /dev/sda /data0
mount: unknown filesystem type 'ntfs-3g'
sudo apt-get install ntfs-3g #From:https://www.cnblogs.com/-jimmy-/p/6986010.html
源不行,看末尾成功加清华源,且要注意版本(E: The repository 'http://archive.raspbian.org/raspbian wheezy Release' does no longer have a Release file.):
https://blog.csdn.net/qq_35586327/article/details/94597760?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-3-94597760.nonecase&utm_term=%E6%A0%91%E8%8E%93%E6%B4%BE%E6%B2%A1%E6%9C%89release%E6%96%87%E4%BB%B6
mainboard_virtualbox_docker_10_10_0_106 (1) 跳板登录:
root@raspberrypi:~# sudo apt-get install ntfs-3g --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libntfs-3g871
The following NEW packages will be installed:
libntfs-3g871 ntfs-3g
0 upgraded, 2 newly installed, 0 to remove and 309 not upgraded.
Need to get 540 kB of archives.
After this operation, 1,665 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian stretch/main armhf libntfs-3g871 armhf 1:2016.2.22AR.1+dfsg-1+deb9u1 [165 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian stretch/main armhf ntfs-3g armhf 1:2016.2.22AR.1+dfsg-1+deb9u1 [375 kB]
Fetched 540 kB in 0s (1,628 kB/s)
Selecting previously unselected package libntfs-3g871.
(Reading database ... 127338 files and directories currently installed.)
Preparing to unpack .../libntfs-3g871_1%3a2016.2.22AR.1+dfsg-1+deb9u1_armhf.deb ...
Unpacking libntfs-3g871 (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Selecting previously unselected package ntfs-3g.
Preparing to unpack .../ntfs-3g_1%3a2016.2.22AR.1+dfsg-1+deb9u1_armhf.deb ...
Unpacking ntfs-3g (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Processing triggers for initramfs-tools (0.130) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libntfs-3g871 (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Setting up ntfs-3g (1:2016.2.22AR.1+dfsg-1+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for initramfs-tools (0.130) ...
root@raspberrypi:~#
b
The value '\stable' is invalid for APT::Default-Release as such a release is not available in the sources
rm -rf /etc/apt/apt.conf.d/10defaultRelease
E: Unable to correct problems, you have held broken packages.
解决方案是先upgrade后update:
$ sudo apt-get upgrade
$ sudo apt-get update
源的问题:
[实践OK]CentOS下vim编辑器在可视模式下在secureCRT无法复制的办法。
Unix/LinuxC技术 jackxiang 2018-5-30 13:41
想鼠标切换又能复制,怎么办?
set mouse=a可视下,用:按住 shift 键,然后选择。
在~/.vimrc中加入 set mouse=a 后,vim鼠标右键变得不能复制了,解决办法如下:
按住 shift 键,然后选择,此时表示由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。
所以配置文件中的set mouse=a启动了所有模式, vim接管了鼠标的控制。
其中涉及的背景知识是:
鼠标事件有两种处理方式,程序处理和 X 处理。
如果 X 负责处理,则是左键选择,中间粘贴。
要让 vim 中由 X 负责处理,有两个方法:
1. 按住 shift 键,然后选择,此时由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。
2. 在 .vimrc 中设置 set mouse= (就是说清空),此时vim永远不再干涉鼠标选择,永远把处理权交给X,这个时候鼠标就处于无模式编辑状态, 当然也能用鼠标来切换vim里面的tab窗口了,vim中的编辑光标也不会跟随鼠标了。
实践Ok来自:https://blog.csdn.net/sinkary/article/details/7531747
:set mouse=v
但这样后,Vim的标签就无法用鼠标切换了,http://jackxiang.com/post/9110/
想用鼠标点vim里的Tab,能切换标签,得重新运行::set mouse=a ,实践是可行的。
阅读全文
set mouse=a可视下,用:按住 shift 键,然后选择。
在~/.vimrc中加入 set mouse=a 后,vim鼠标右键变得不能复制了,解决办法如下:
按住 shift 键,然后选择,此时表示由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。
所以配置文件中的set mouse=a启动了所有模式, vim接管了鼠标的控制。
其中涉及的背景知识是:
鼠标事件有两种处理方式,程序处理和 X 处理。
如果 X 负责处理,则是左键选择,中间粘贴。
要让 vim 中由 X 负责处理,有两个方法:
1. 按住 shift 键,然后选择,此时由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。
2. 在 .vimrc 中设置 set mouse= (就是说清空),此时vim永远不再干涉鼠标选择,永远把处理权交给X,这个时候鼠标就处于无模式编辑状态, 当然也能用鼠标来切换vim里面的tab窗口了,vim中的编辑光标也不会跟随鼠标了。
实践Ok来自:https://blog.csdn.net/sinkary/article/details/7531747
:set mouse=v
但这样后,Vim的标签就无法用鼠标切换了,http://jackxiang.com/post/9110/
想用鼠标点vim里的Tab,能切换标签,得重新运行::set mouse=a ,实践是可行的。
阅读全文
[实践OK]苹果Mac里输入文件路径的方法,Mac打开Finder快捷键.
Unix/LinuxC技术 jackxiang 2018-5-27 16:16
option + command + space打开Finder,command + shift + G;注意:打开finder后,再快捷键,然后输入“/”,前往根目录。
二)常用目录:硬盘图标拖拽至侧边栏。
三)shift + space :相当于快速查看目录大小。
1、通过“前往文件夹”快捷键组合
(1)打开finder,点击上部菜单栏“前往”,然后“个人”,直接跳转。
(2)快捷键组合:command + shift + G;注意:打开finder后,再快捷键,然后输入“/”,前往根目录。
2、将Macintosh HD快捷方式放入Finder侧边栏
对于经常要访问根目录的用户来说,将Macintosh HD快捷方式会更高效一些。在任何文件夹内(除了“我的所有文件”)右键点击标题栏(文件夹窗口最上面,居中的标题栏),然后选择Macintosh HD。最后将Macintosh HD左侧的硬盘图标拖拽至侧边栏即可完成操作。以后需要访问根目录时,只需点击侧边栏的快捷方式即可。
3、在桌面上显示硬盘
打开Finder的“偏好设置”,在“通用”模式下在“硬盘”前面的方块内勾选即可。这样桌面上就会有Macintosh HD,双击即可访问。
4、使用命令行迅速导航
导航打开终端应用,然后输入下面的命令即可迅速导航至根目录。
CD/
上面的命令是在终端中访问根目录,如果你想通过终端打开Finder的根目录,只需下面的命令即可:
open/
在Finder里,也不是类似下载文件夹里,输入:
Command+Shift+G
会弹出一个输入路径的框,输入路径也就跳转过去了。
---------------------------------------------------------------
option + command + space
直接通过Spotlight窗口就能打开Finder。简单吧!
| 设置Spotlight窗口的快捷键
在系统偏好设置-Spotlight中自行设置即可。
| 跳转到某个文件夹
进入Finder窗口后,shift+command+g后输入文件夹路径即可跳转到相应文件夹。
> 常见文件夹路径
跳转到根目录,输入
/
跳转到当前目录,默认为apple目录,输入
~
来自:http://www.cnblogs.com/tangyikejun/p/3997728.html
二)常用目录:硬盘图标拖拽至侧边栏。
三)shift + space :相当于快速查看目录大小。
1、通过“前往文件夹”快捷键组合
(1)打开finder,点击上部菜单栏“前往”,然后“个人”,直接跳转。
(2)快捷键组合:command + shift + G;注意:打开finder后,再快捷键,然后输入“/”,前往根目录。
2、将Macintosh HD快捷方式放入Finder侧边栏
对于经常要访问根目录的用户来说,将Macintosh HD快捷方式会更高效一些。在任何文件夹内(除了“我的所有文件”)右键点击标题栏(文件夹窗口最上面,居中的标题栏),然后选择Macintosh HD。最后将Macintosh HD左侧的硬盘图标拖拽至侧边栏即可完成操作。以后需要访问根目录时,只需点击侧边栏的快捷方式即可。
3、在桌面上显示硬盘
打开Finder的“偏好设置”,在“通用”模式下在“硬盘”前面的方块内勾选即可。这样桌面上就会有Macintosh HD,双击即可访问。
4、使用命令行迅速导航
导航打开终端应用,然后输入下面的命令即可迅速导航至根目录。
CD/
上面的命令是在终端中访问根目录,如果你想通过终端打开Finder的根目录,只需下面的命令即可:
open/
在Finder里,也不是类似下载文件夹里,输入:
Command+Shift+G
会弹出一个输入路径的框,输入路径也就跳转过去了。
---------------------------------------------------------------
option + command + space
直接通过Spotlight窗口就能打开Finder。简单吧!
| 设置Spotlight窗口的快捷键
在系统偏好设置-Spotlight中自行设置即可。
| 跳转到某个文件夹
进入Finder窗口后,shift+command+g后输入文件夹路径即可跳转到相应文件夹。
> 常见文件夹路径
跳转到根目录,输入
/
跳转到当前目录,默认为apple目录,输入
~
来自:http://www.cnblogs.com/tangyikejun/p/3997728.html