lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘,lspci 列出所有 PCI 总线lsusb 列出与本机相连的所有 USB 设备的信息。
Unix/LinuxC技术 jackxiang 2019-5-22 14:56
yum install lshw
lshw 这个命令是一个比较通用的工具,它可以详细的列出本机的硬件信息。但这个命令并非所有的发行版都有,比如 Fedora 就默认没有,需要自己安装。
lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘等。如果不带选项的话,列出的信息将很长,加上 -short 选项时,将只列出概要信息。
lshw -short
H/W path Device Class Description
======================================================
system NF5280M2 (To Be Filled By O.E.M.)
/0 bus 2U
/0/0 memory 64KiB BIOS
/0/4 processor Xeon (To Be Filled By O.E.M.)
/0/4/5 memory 256KiB L1 cache
/0/4/6 memory 1MiB L2 cache
/0/4/7 memory 12MiB L3 cache
/0/8 processor Xeon (To Be Filled By O.E.M.)
/0/8/9 memory 256KiB L1 cache
/0/8/a memory 1MiB L2 cache
lspci 列出所有 PCI 总线,以及与 PCI 总线相连的所有设备的详细信息,比如 VGA 适配器、显卡、网络适配器、usb 端口、SATA 控制器等。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
00:09.0 PCI bridge: Intel Corporation 7500/5520/5500/X58 I/O Hub PCI Express Root Port 9 (rev 22)
00:13.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub I/OxAPIC Interrupt Controller (rev 22)
00:14.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers (rev 22)
lsusb 列出与本机相连的所有 USB 设备的信息。默认情况下,只列出概要信息,使用 -v 选项可以列出每一个 USB 口的详细信息。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
lshw 这个命令是一个比较通用的工具,它可以详细的列出本机的硬件信息。但这个命令并非所有的发行版都有,比如 Fedora 就默认没有,需要自己安装。
lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘等。如果不带选项的话,列出的信息将很长,加上 -short 选项时,将只列出概要信息。
lshw -short
H/W path Device Class Description
======================================================
system NF5280M2 (To Be Filled By O.E.M.)
/0 bus 2U
/0/0 memory 64KiB BIOS
/0/4 processor Xeon (To Be Filled By O.E.M.)
/0/4/5 memory 256KiB L1 cache
/0/4/6 memory 1MiB L2 cache
/0/4/7 memory 12MiB L3 cache
/0/8 processor Xeon (To Be Filled By O.E.M.)
/0/8/9 memory 256KiB L1 cache
/0/8/a memory 1MiB L2 cache
lspci 列出所有 PCI 总线,以及与 PCI 总线相连的所有设备的详细信息,比如 VGA 适配器、显卡、网络适配器、usb 端口、SATA 控制器等。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
00:09.0 PCI bridge: Intel Corporation 7500/5520/5500/X58 I/O Hub PCI Express Root Port 9 (rev 22)
00:13.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub I/OxAPIC Interrupt Controller (rev 22)
00:14.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers (rev 22)
lsusb 列出与本机相连的所有 USB 设备的信息。默认情况下,只列出概要信息,使用 -v 选项可以列出每一个 USB 口的详细信息。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
[转]Linux tmp目录自动清理总结
Unix/LinuxC技术 jackxiang 2019-5-15 15:17
在Linux系统中/tmp文件夹下的文件是会被清理、删除的,文件清理的规则是如何设定的呢? 以Redhat为例,这个主要是因为作业里面会调用tmpwatch命令删除那些一段时间没有访问的文件。
那么什么是tmpwatch呢?其实tmpwatch是一个命令或者说是一个包。如下所示
tmpwatch - removes files which haven’t been accessed for a period of time
[root@DB-Server ~]# rpm -qa | grep tmpwatch
tmpwatch-2.9.7-1.1.el5.5
[root@DB-Server ~]# whereis tmpwatch
tmpwatch: /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
[root@DB-Server ~]# file /usr/sbin/tmpwatch
/usr/sbin/tmpwatch: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@DB-Server ~]#
关于tmpwatch命令的参数,不同版本可能有所不同,下面以Red Hat Enterprise Linux Server release 5.7下TMPWATCH(8)为列
作用:
删除一段时间没有被访问的文件。
参数:
-u 按照文件的最后access时间,即最后访问时间为参考。默认选项。可通过ls -lu查看。
-m 按照文件的最后modified时间,即最后修改时间为参考。可通过ls -l查看。
-c 按照文件的-ctime时间做参考,ctime更新的条件为写入、更改属主、权限。可通过ls -lc查看。
-M 按照目录的修改时间来删除目录而不是访问时间。
-a 删除所有类型文件。包括目录和symbolic links
-d --nodirs 排除目录文件,即使是空目录。
-d --nosysmlinks 排除symbolic links类型文件。
-f 强制删除那些root没有写权限的文件。比如root的readonly文件
-q 只报告错误信息。
-x /PATH 排除特定目录,即不删除该子目录里的文件。
-U user_name 排除属于特定用户的文件,即不删除该用户的文件。
-v 显示删除过程。默认是不显示删除了什么文件,直接删除的。
-t 用于测试,并不真正删除文件,能显示出要删除文件的过程。
-d 不删除文件里的子目录,但是子目录里面的文件还是会被删除。
参数后加时间,默认是hours。也可以使用30d表示30天,但是有些版本只支持hours。 时间后是要检查的目录。可以多个目录用空格分开。如下所示表示720小小时~=30天。
[root@DB-Server ~]# more /etc/cron.daily/tmpwatch
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 240 /tmp
/usr/sbin/tmpwatch "$flags" 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 720 "$d"
fi
done
[root@DB-Server ~]#
如果你想将强制删除30天没有访问的文件改为7天,只需"/usr/sbin/tmpwatch "$flags" 720 /var/tmp"和"/usr/sbin/tmpwatch "$flags" -f 720 "$d" 里面的720改为189即可。
来自:http://www.cnblogs.com/kerrycode/p/5759941.html
==========================实践================================
rpm -qa | grep tmpwatch
tmpwatch-2.9.16-6.el6.x86_64
whereis tmpwatch
tmpwatch: /usr/bin/tmpwatch /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
cat /etc/cron.daily/tmpwatch
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \
-X '/tmp/pymp-*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
那么什么是tmpwatch呢?其实tmpwatch是一个命令或者说是一个包。如下所示
tmpwatch - removes files which haven’t been accessed for a period of time
[root@DB-Server ~]# rpm -qa | grep tmpwatch
tmpwatch-2.9.7-1.1.el5.5
[root@DB-Server ~]# whereis tmpwatch
tmpwatch: /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
[root@DB-Server ~]# file /usr/sbin/tmpwatch
/usr/sbin/tmpwatch: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@DB-Server ~]#
关于tmpwatch命令的参数,不同版本可能有所不同,下面以Red Hat Enterprise Linux Server release 5.7下TMPWATCH(8)为列
作用:
删除一段时间没有被访问的文件。
参数:
-u 按照文件的最后access时间,即最后访问时间为参考。默认选项。可通过ls -lu查看。
-m 按照文件的最后modified时间,即最后修改时间为参考。可通过ls -l查看。
-c 按照文件的-ctime时间做参考,ctime更新的条件为写入、更改属主、权限。可通过ls -lc查看。
-M 按照目录的修改时间来删除目录而不是访问时间。
-a 删除所有类型文件。包括目录和symbolic links
-d --nodirs 排除目录文件,即使是空目录。
-d --nosysmlinks 排除symbolic links类型文件。
-f 强制删除那些root没有写权限的文件。比如root的readonly文件
-q 只报告错误信息。
-x /PATH 排除特定目录,即不删除该子目录里的文件。
-U user_name 排除属于特定用户的文件,即不删除该用户的文件。
-v 显示删除过程。默认是不显示删除了什么文件,直接删除的。
-t 用于测试,并不真正删除文件,能显示出要删除文件的过程。
-d 不删除文件里的子目录,但是子目录里面的文件还是会被删除。
参数后加时间,默认是hours。也可以使用30d表示30天,但是有些版本只支持hours。 时间后是要检查的目录。可以多个目录用空格分开。如下所示表示720小小时~=30天。
[root@DB-Server ~]# more /etc/cron.daily/tmpwatch
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 240 /tmp
/usr/sbin/tmpwatch "$flags" 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 720 "$d"
fi
done
[root@DB-Server ~]#
如果你想将强制删除30天没有访问的文件改为7天,只需"/usr/sbin/tmpwatch "$flags" 720 /var/tmp"和"/usr/sbin/tmpwatch "$flags" -f 720 "$d" 里面的720改为189即可。
来自:http://www.cnblogs.com/kerrycode/p/5759941.html
==========================实践================================
rpm -qa | grep tmpwatch
tmpwatch-2.9.16-6.el6.x86_64
whereis tmpwatch
tmpwatch: /usr/bin/tmpwatch /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
cat /etc/cron.daily/tmpwatch
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \
-X '/tmp/pymp-*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
[实践OK]resolv.conf:search、domain、nameserver解释 发表评论 A+ 所属分类:Linux
Unix/LinuxC技术 jackxiang 2019-4-26 14:40
resolv.conf是resolver类库使用的配置文件,每当一个程序需要通过域名来访问internet上面的其它主机时,需要利用该类库将域名转换成对应的IP,然后才可进行访问.
resolv.conf文件的配置选项不多,从man文档中看了半天,不理解domain和search使用来干嘛的。这里做个解释,防止以后忘了(环境:ubuntu12.04):
nameserver x.x.x.x该选项用来制定DNS服务器的,可以配置多个nameserver指定多个DNS。
domain mydomain.com这个用来指定本地的域名,在没有设置search的情况下,search默认为domain的值。这个值可以随便配,目前在我看来,domain除了当search的默认值外,没有其它用途。也就说一旦配置search,那domain就没用了。
search google.com baidu.com该选项可以用来指定多个域名,中间用空格或tab键隔开。它是干嘛的呢?
如:在没有配置该选项时,执行
#ping new
sping: unknown host news
配置search google.com baidu.com后,再执行
#ping news
PING news.google.com (74.125.128.101) 56(84) bytes of data.
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=1 ttl=47 time=78.9 ms
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=2 ttl=47 time=63.6 ms
它就去ping news.google.com了。原来当访问的域名不能被DNS解析时,resolver会将该域名加上search指定的参数,重新请求DNS,直到被正确解析或试完search指定的列表为止。
由于news不能被DNS解析,所以去尝试news.google.com,被正常解析。如果没有被解析还会去尝试news.baidu.com。
来自:http://www.ttlsa.com/linux/resolv-conf-desc/
实践如下:
google 在前:
#ping news
PING news.google.com (172.217.24.14) 56(84) bytes of data.
baidu在前:
ping news
PING news.n.shifen.com (202.108.23.82) 56(84) bytes of data.
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=1 ttl=55 time=1.97 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=2 ttl=55 time=2.01 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=3 ttl=55 time=1.99 ms
resolv.conf文件的配置选项不多,从man文档中看了半天,不理解domain和search使用来干嘛的。这里做个解释,防止以后忘了(环境:ubuntu12.04):
nameserver x.x.x.x该选项用来制定DNS服务器的,可以配置多个nameserver指定多个DNS。
domain mydomain.com这个用来指定本地的域名,在没有设置search的情况下,search默认为domain的值。这个值可以随便配,目前在我看来,domain除了当search的默认值外,没有其它用途。也就说一旦配置search,那domain就没用了。
search google.com baidu.com该选项可以用来指定多个域名,中间用空格或tab键隔开。它是干嘛的呢?
如:在没有配置该选项时,执行
#ping new
sping: unknown host news
配置search google.com baidu.com后,再执行
#ping news
PING news.google.com (74.125.128.101) 56(84) bytes of data.
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=1 ttl=47 time=78.9 ms
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=2 ttl=47 time=63.6 ms
它就去ping news.google.com了。原来当访问的域名不能被DNS解析时,resolver会将该域名加上search指定的参数,重新请求DNS,直到被正确解析或试完search指定的列表为止。
由于news不能被DNS解析,所以去尝试news.google.com,被正常解析。如果没有被解析还会去尝试news.baidu.com。
来自:http://www.ttlsa.com/linux/resolv-conf-desc/
实践如下:
google 在前:
#ping news
PING news.google.com (172.217.24.14) 56(84) bytes of data.
baidu在前:
ping news
PING news.n.shifen.com (202.108.23.82) 56(84) bytes of data.
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=1 ttl=55 time=1.97 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=2 ttl=55 time=2.01 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=3 ttl=55 time=1.99 ms
[实践OK]Linux centos vpn软件下载成功安装地址,/usr/bin/vpnd 2>&1是由vpn生成的,VPNClient工具,在MacBook/Iphone7/CentOS7均以安装的安装vpn软件之MotionPro。
Unix/LinuxC技术 jackxiang 2019-4-25 06:09
下载地址:
http://client.arraynetworks.com.cn:8080/zh/troubleshooting
点击上述链接,下载合适的版本:
https://support.arraynetworks.net/prx/000/http/supportportal.arraynetworks.net/downloads/motionpro/Linux/Fedora/1.1.1/MotionPro_Linux_RedHat_x86-64_1.1.1.sh
安装
sudo ./MotionPro_Linux_Ubuntu_x86-64_1.2.1.sh
https://blog.csdn.net/yitengtongweishi/article/details/86378026
实践如下:
wget https://support.arraynetworks.net/prx/000/http/supportportal.arraynetworks.net/downloads/motionpro/Linux/Fedora/1.1.1/MotionPro_Linux_RedHat_x86-64_1.1.1.sh
[root@mainboard_kvmops_10_10_0_103 src]# chmod +x MotionPro_Linux_RedHat_x86-64_1.1.1.sh
[root@mainboard_kvmops_10_10_0_103 src]# ./MotionPro_Linux_RedHat_x86-64_1.1.1.sh
Verifying archive integrity... 100% All good.
Uncompressing MotionPro Setup 100%
installing vpnd...
starting vpnd...
installing MotionPro...
creating desktop shortcut for MotionPro...
install MotionPro successfully.
[实践OK]修改错fstab后出现无法个性/etc/fstab出现无法读取磁盘的问题,centos进入救援模式,修复fstab错误
Unix/LinuxC技术 jackxiang 2019-4-21 19:07
在centos数秒启动页面,按e,进入编辑模式
找到2步中的ro,修改成:rw init=/sysroot/bin/sh,然后按ctrl+x重启
执行chroot /sysroot获取root权限,使用vi /etc/fstab编辑fstab配置文件
来自:https://blog.csdn.net/laotoumo/article/details/82746131
找到2步中的ro,修改成:rw init=/sysroot/bin/sh,然后按ctrl+x重启
执行chroot /sysroot获取root权限,使用vi /etc/fstab编辑fstab配置文件
来自:https://blog.csdn.net/laotoumo/article/details/82746131
[实践OK]AWK增加列分割符号,增加一列相同的值。
Unix/LinuxC技术 jackxiang 2019-4-17 16:36
一)AWK增加列分割符号:
| awk -v 'OFS=:' '{print $1,$1,$1}'
二)增加一列相同的值,如何用awk在每行最后添加字段:
awk '{print $0, 新字段}' 文件名
https://zhidao.baidu.com/question/2121603287620619987.html
| awk -v 'OFS=:' '{print $1,$1,$1}'
二)增加一列相同的值,如何用awk在每行最后添加字段:
awk '{print $0, 新字段}' 文件名
https://zhidao.baidu.com/question/2121603287620619987.html
ip_local_port_range: prefer different parity for start/end values.
Unix/LinuxC技术 jackxiang 2019-4-9 23:01
Linux increase ip_local_port_range TCP port range using sysctl.conf
Finally, edit /etc/sysctl.conf file, to make changes to /proc filesystem permanently i.e. append the following line to your /etc/sysctl.conf file:
# increase system IP port limits
net.ipv4.ip_local_port_range = 1024 65535
来自:https://www.cyberciti.biz/tips/linux-increase-outgoing-network-sockets-range.html
Finally, edit /etc/sysctl.conf file, to make changes to /proc filesystem permanently i.e. append the following line to your /etc/sysctl.conf file:
# increase system IP port limits
net.ipv4.ip_local_port_range = 1024 65535
来自:https://www.cyberciti.biz/tips/linux-increase-outgoing-network-sockets-range.html
[实践OK]linux下修改fstab的只读问题,linux下修改fstab后出现只读问题。
Unix/LinuxC技术 jackxiang 2019-4-9 22:12
今天自己已开始做在虚拟机上做实验,增加了一个磁盘sdb1,而且也增加了自动挂载的功能/etc/fstab里增加了记录。后来自己把这个磁盘给删除了,再次重新启动服务器的时候,系统启动不了了。
系统提示:
按提示 输入 root的密码,进入以Repair filesystem 为提示符的界面。
vi /etc/fstab后 提示,只读,也就是没权限修改。
解决方案如下:
于是输入 mount -o remount,rw /
逗号前面无空格(切记),而且一定要有/这个
表示重新挂载为读写模式。
这个时候再 vi /etc/fstab 发现已经可以修改了,修改完毕,重启,正常。
---------------------
原文:https://blog.csdn.net/waterxcfg304/article/details/49766467
系统提示:
按提示 输入 root的密码,进入以Repair filesystem 为提示符的界面。
vi /etc/fstab后 提示,只读,也就是没权限修改。
解决方案如下:
于是输入 mount -o remount,rw /
逗号前面无空格(切记),而且一定要有/这个
表示重新挂载为读写模式。
这个时候再 vi /etc/fstab 发现已经可以修改了,修改完毕,重启,正常。
---------------------
原文:https://blog.csdn.net/waterxcfg304/article/details/49766467
[实践Ok]Linux内建命令和外部命令的判断以及帮助命令——pwd,以及这俩的性能对比。
Unix/LinuxC技术 jackxiang 2019-4-4 17:24
help [-s] [pattern]
显示关于内建命令的有用的信息。如果指定了 pattern (模式), help 给出关于所有匹配 pattern 的命令的详细帮助;否则所有内建命令的帮助和 shell
控制结构将被打印出来。 选项 -s 限制信息显示为简短的用法概要。 返回 0,除非没有匹配 pattern 的命令。
在shell中,通过awk,sed,expr 等都可以实现,字符串上述操作。下面我们进行性能比较。
[chengmo@localhost ~]$ test='c:/windows/boot.ini'
[chengmo@localhost ~]$ time for i in $(seq 10000);do a=${#test};done;
real 0m0.173s
user 0m0.139s
sys 0m0.004s
[chengmo@localhost ~]$ time for i in $(seq 10000);do a=$(expr length $test);done;
real 0m9.734s
user 0m1.628s
速度相差上百倍,调用外部命令处理,与内置操作符性能相差非常大。在shell编程中,尽量用内置操作符或者函数完成。使用awk,sed类似会出现这样结果。
time for i in $(seq 10000);do a=${#test};done;
real 0m0.751s
user 0m0.747s
sys 0m0.004s
time for i in $(seq 10000);do a=$(expr length $test);done;
real 0m13.291s
user 0m4.898s
sys 0m9.004s
$type echo
echo is a shell builtin
$type expr
expr is /usr/bin/expr
来自:http://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html
显示关于内建命令的有用的信息。如果指定了 pattern (模式), help 给出关于所有匹配 pattern 的命令的详细帮助;否则所有内建命令的帮助和 shell
控制结构将被打印出来。 选项 -s 限制信息显示为简短的用法概要。 返回 0,除非没有匹配 pattern 的命令。
在shell中,通过awk,sed,expr 等都可以实现,字符串上述操作。下面我们进行性能比较。
[chengmo@localhost ~]$ test='c:/windows/boot.ini'
[chengmo@localhost ~]$ time for i in $(seq 10000);do a=${#test};done;
real 0m0.173s
user 0m0.139s
sys 0m0.004s
[chengmo@localhost ~]$ time for i in $(seq 10000);do a=$(expr length $test);done;
real 0m9.734s
user 0m1.628s
速度相差上百倍,调用外部命令处理,与内置操作符性能相差非常大。在shell编程中,尽量用内置操作符或者函数完成。使用awk,sed类似会出现这样结果。
time for i in $(seq 10000);do a=${#test};done;
real 0m0.751s
user 0m0.747s
sys 0m0.004s
time for i in $(seq 10000);do a=$(expr length $test);done;
real 0m13.291s
user 0m4.898s
sys 0m9.004s
$type echo
echo is a shell builtin
$type expr
expr is /usr/bin/expr
来自:http://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html
[实践学习]Linux Shell 中各种括号的作用()、(())、[]、[[]]、{}
Unix/LinuxC技术 jackxiang 2019-4-4 15:37
#echo {{6379..6387},6389,6399}
6379 6380 6381 6382 6383 6384 6385 6386 6387 6389 6399
#for i in {{6379..6387},6389,6399}; do echo $i;
> done
6379
6380
6381
6382
6383
6384
6385
6386
6387
6389
6399
echo $(cd "$(dirname /tmp/error.txt)";pwd)
/tmp
array=(a b c d)
echo $array
a b c d
echo ${#array[@]}
4
a=5
((a++))
echo $a
6
b=3
((a=$a+$b))
echo $a #6+3=9
$for((i=0;i<5;i++))
> do
> echo $i;
> done
0
1
2
3
4
$echo $(seq -w 001 2 10)
001 003 005 007 009
换行:
echo "$(seq -w 001 2 10)"
001
003
005
007
009
$echo -e -n "$(seq -w 001 2 10)"
001
003
005
007
009
${var:num1:num2},num1是位置,num2是长度。表示从$var字符串的第$num1个位置开始提取长度为$num2的子串。不能为负数。
echo ${tag:2:2}
a5
tag=baa506fbd77d78ad3cfb912a50a4eac99c0d19c1
tag=${tag:0:8}
echo $tag
baa506fb
取字符串长度:
echo ${#tag}
8
# ls {ex1,ex2}.sh
ex1.sh ex2.sh
# ls {ex{1..3},ex4}.sh #{1...100} 中间仨个点 # echo {{1..3},9,20}
ex1.sh ex2.sh ex3.sh ex4.sh
# ls {ex[1-3],ex4}.sh #注意:是逗号
ex1.sh ex2.sh ex3.sh ex4.sh
echo $0
-bash
echo <FILE> $0=FILE
(1)${a} 变量a的值, 在不引起歧义的情况下可以省略大括号。
(2)$(cmd) 命令替换,和`cmd`效果相同,结果为shell命令cmd的输,过某些Shell版本不支持$()形式的命令替换, 如tcsh。
(3)$((expression)) 和`exprexpression`效果相同, 计算数学表达式exp的数值, 其中exp只要符合C语言的运算规则即可, 甚至三目运算符和逻辑表达式都可以计算。
阅读全文
6379 6380 6381 6382 6383 6384 6385 6386 6387 6389 6399
#for i in {{6379..6387},6389,6399}; do echo $i;
> done
6379
6380
6381
6382
6383
6384
6385
6386
6387
6389
6399
echo $(cd "$(dirname /tmp/error.txt)";pwd)
/tmp
array=(a b c d)
echo $array
a b c d
echo ${#array[@]}
4
a=5
((a++))
echo $a
6
b=3
((a=$a+$b))
echo $a #6+3=9
$for((i=0;i<5;i++))
> do
> echo $i;
> done
0
1
2
3
4
$echo $(seq -w 001 2 10)
001 003 005 007 009
换行:
echo "$(seq -w 001 2 10)"
001
003
005
007
009
$echo -e -n "$(seq -w 001 2 10)"
001
003
005
007
009
${var:num1:num2},num1是位置,num2是长度。表示从$var字符串的第$num1个位置开始提取长度为$num2的子串。不能为负数。
echo ${tag:2:2}
a5
tag=baa506fbd77d78ad3cfb912a50a4eac99c0d19c1
tag=${tag:0:8}
echo $tag
baa506fb
取字符串长度:
echo ${#tag}
8
# ls {ex1,ex2}.sh
ex1.sh ex2.sh
# ls {ex{1..3},ex4}.sh #{1...100} 中间仨个点 # echo {{1..3},9,20}
ex1.sh ex2.sh ex3.sh ex4.sh
# ls {ex[1-3],ex4}.sh #注意:是逗号
ex1.sh ex2.sh ex3.sh ex4.sh
echo $0
-bash
echo <FILE> $0=FILE
(1)${a} 变量a的值, 在不引起歧义的情况下可以省略大括号。
(2)$(cmd) 命令替换,和`cmd`效果相同,结果为shell命令cmd的输,过某些Shell版本不支持$()形式的命令替换, 如tcsh。
(3)$((expression)) 和`exprexpression`效果相同, 计算数学表达式exp的数值, 其中exp只要符合C语言的运算规则即可, 甚至三目运算符和逻辑表达式都可以计算。

[实践OK]Mac gitk安装与优化
Unix/LinuxC技术 jackxiang 2019-4-1 16:12
gitk --all
--all
Show all branches.
gitk --max-count=100 --all -- Makefile #查看Makefile 100条内容
Show at most 100 changes made to the file Makefile. Instead of only looking for changes in the current branch look in all branches.
实践:gitk --max-count=100 --all -- dns\ 运维手册.md
实践:
gitk --since="2 weeks ago" -- dns\ 运维手册.md #显示dns\ 运维手册.md两周内的改动
gitk v2.6.12.. include/scsi drivers/scsi #显示在自从版本v2.6.12后这两个子目录的改动
Show the changes since version v2.6.12 that changed any file in the include/scsi or drivers/scsi subdirectories
实践:
gitk 3667109.. . #查看版本号3667109当前目录的改动
来自:https://git-scm.com/docs/gitk/1.6.1
一、mac系统安装gitk
gitk是git的一个bin工具,如果git不包含gitk只能说明当前使用的git版本过老。
因此我们只需要安装最新的git就可以了。安装git方法如下:
首先安装brew,方便安装git
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后更新软件源并安装git
brew update
brew install git
查看git版本
git --version # 我安装之后git version 2.18.0
安装完成后执行type命令检查git路径
type -a git
如果结果路径包含/usr/local/bin/git则安装成功,此时只需在项目目录下输入gitk命令就可以启动gitk了。
但是默认情况下gitk显示很模糊,网上查了之后发现是由于mac自带的Wish软件版本很老,没有对retina屏幕做适配导致的,因此需要做优化。
二、系统优化,开启Wish高分辨率适配
git在Mac下其实早就适配了高分辨率了,其patch链接如下:
https://gist.githubusercontent.com/cynthia/5f2355a87c2f15d96dbe/raw/6727e73a007b0efabf55dd065e588467ffccc016/wish_app_info_plist.patch
开启高分辨率适配步骤如下:
1、重启系统,在黑屏界面的时候按住command + r直至出现进度条,进入系统recovery模式
2、在recovery模式中选择简体中文进入桌面,在最顶层的工具栏中找到“实用工具” -> “终端”,启动命令行终端
3、执行以下命令关闭系统保护,详细了解OS X的rootless
csrutil disable
4、重启正常进入系统,修改系统配置文件(如果没有上面的csrutil disable,是无法修改/System目录内的任何内容的)
sudo vim /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist
这个/System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist在recovery模式下是找不到的
然后在这个文件内容中增加以下两行配置:
<key>NSHighResolutionCapable</key>
<true/>
增加位置如下图
然后更新Wish.app配置
sudo touch /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app
5、再次重启,黑屏时按下command+r直到出现进度条,重新进入recovery模式
6、进入recovery模式桌面后,执行“实用工具”->“终端”启动命令行终端
7、执行命令开启系统文件保护
csrutil enable
8、重启系统,正常进入系统,gitk就OK了。
来自:https://www.cnblogs.com/snowater/p/9286122.html
--all
Show all branches.
gitk --max-count=100 --all -- Makefile #查看Makefile 100条内容
Show at most 100 changes made to the file Makefile. Instead of only looking for changes in the current branch look in all branches.
实践:gitk --max-count=100 --all -- dns\ 运维手册.md
实践:
gitk --since="2 weeks ago" -- dns\ 运维手册.md #显示dns\ 运维手册.md两周内的改动
gitk v2.6.12.. include/scsi drivers/scsi #显示在自从版本v2.6.12后这两个子目录的改动
Show the changes since version v2.6.12 that changed any file in the include/scsi or drivers/scsi subdirectories
实践:
gitk 3667109.. . #查看版本号3667109当前目录的改动
来自:https://git-scm.com/docs/gitk/1.6.1
一、mac系统安装gitk
gitk是git的一个bin工具,如果git不包含gitk只能说明当前使用的git版本过老。
因此我们只需要安装最新的git就可以了。安装git方法如下:
首先安装brew,方便安装git
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后更新软件源并安装git
brew update
brew install git
查看git版本
git --version # 我安装之后git version 2.18.0
安装完成后执行type命令检查git路径
type -a git
如果结果路径包含/usr/local/bin/git则安装成功,此时只需在项目目录下输入gitk命令就可以启动gitk了。
但是默认情况下gitk显示很模糊,网上查了之后发现是由于mac自带的Wish软件版本很老,没有对retina屏幕做适配导致的,因此需要做优化。
二、系统优化,开启Wish高分辨率适配
git在Mac下其实早就适配了高分辨率了,其patch链接如下:
https://gist.githubusercontent.com/cynthia/5f2355a87c2f15d96dbe/raw/6727e73a007b0efabf55dd065e588467ffccc016/wish_app_info_plist.patch
开启高分辨率适配步骤如下:
1、重启系统,在黑屏界面的时候按住command + r直至出现进度条,进入系统recovery模式
2、在recovery模式中选择简体中文进入桌面,在最顶层的工具栏中找到“实用工具” -> “终端”,启动命令行终端
3、执行以下命令关闭系统保护,详细了解OS X的rootless
csrutil disable
4、重启正常进入系统,修改系统配置文件(如果没有上面的csrutil disable,是无法修改/System目录内的任何内容的)
sudo vim /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist
这个/System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist在recovery模式下是找不到的
然后在这个文件内容中增加以下两行配置:
<key>NSHighResolutionCapable</key>
<true/>
增加位置如下图
然后更新Wish.app配置
sudo touch /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app
5、再次重启,黑屏时按下command+r直到出现进度条,重新进入recovery模式
6、进入recovery模式桌面后,执行“实用工具”->“终端”启动命令行终端
7、执行命令开启系统文件保护
csrutil enable
8、重启系统,正常进入系统,gitk就OK了。
来自:https://www.cnblogs.com/snowater/p/9286122.html
[可以改改]教教大家修改alt+c,alt+v快捷键
Unix/LinuxC技术 jackxiang 2019-4-1 09:53
一直使用alt+c,alt+v来复制粘贴,挺不方便的,就试了试修改快捷键,果然可以。下来分享给大家,很简单,会的同学就飘过吧~~,有其他方法的顺便也回复下吧
第一步,系统偏好设置,选择键盘
第一步
第二步,选择》添加应用程序快捷键
第三步,点击小加号
第二步,第三步
第四步,在菜单标题里输入快捷键名称
第五步,在键盘快捷键里,直接按“CTRL+C”。
同理,可以将复制,粘贴,剪切,全选都添加进去(不过撤销貌似不行,知道的回复下吧:)
第四步,第五步
第六步,enjoy
结论:
其实可以用修饰键来搞定
不过我现在都习惯了。
来自:http://bbs.pcbeta.com/viewthread-1040611-1-1.html
第一步,系统偏好设置,选择键盘
第一步
第二步,选择》添加应用程序快捷键
第三步,点击小加号
第二步,第三步
第四步,在菜单标题里输入快捷键名称
第五步,在键盘快捷键里,直接按“CTRL+C”。
同理,可以将复制,粘贴,剪切,全选都添加进去(不过撤销貌似不行,知道的回复下吧:)
第四步,第五步
第六步,enjoy
结论:
其实可以用修饰键来搞定
不过我现在都习惯了。
来自:http://bbs.pcbeta.com/viewthread-1040611-1-1.html
ipv6导致域名解析慢!关闭ipv6
Unix/LinuxC技术 jackxiang 2019-3-13 14:04
centos下判断是否开启ipv6及关闭ipv6的方式
已有 392 次阅读 2012-01-31 17:14 标签: ipv6
linux默认是开启ipv6的,但是很多网络服务还不支持ipv6,开启了ipv6反而会影响服务器的网络性能。可以考虑关闭ipv6功能
在Linux下首先确认IPv6是否已经被启用,可以从三个方面确定。
1.使用ifconfig查看自己的IP地址是否含有IPv6地址。
eth0 Link encap:Ethernet HWaddr 00:0A:E4:FE:6F:E1
inet addr:172.28.245.104 Bcast:172.28.245.127 Mask:255.255.255.128
inet6 addr: fe80::20a:e4ff:fefe:6fe1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96998 errors:0 dropped:0 overruns:0 frame:0
TX packets:69963 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113588678 (108.3 MiB) TX bytes:8894978 (8.4 MiB)
Interrupt:20
2.查看服务监听的IP中是否有IPv6格式的地址。(netstat -tuln)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
udp 0 0 172.28.245.104:61440 0.0.0.0:*
udp 0 0 0.0.0.0:32823 0.0.0.0:*
udp 0 0 0.0.0.0:32824 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
3.使用lsmod|grep ipv6查看ipv6的模块是否被加载。
ipv6 245989 12
关闭IPV6的方式:
当确定IPv6已经开启后就可以按照下面的方法将其关闭
1.使用vi编辑器,打开/etc/modprobe.conf
2.在文档中加入如下的两条:
alias net-pf-10 off
alias ipv6 off
保存退出,并且重新启动系统。
重启之后可以使用上面的三种方法去验证IPv6支持是否已经被关闭。
IPv6是默认支持的,所以当你要重新开起IPv6支持时,将/etc/modprobe.conf中的两条指令注释掉就可以了。
======================================================================
http://www.111cn.net/sys/CentOS/50864.htm
http://www.linuxso.com/linuxrumen/17201.html
http://blog.csdn.net/suplxj/article/details/7773423
方法一:
CentOS 6 默认安装后,IPv6是自动开启的,但是现在IPv6还没有普及基本用不到这个功能,建议关闭IPv6模块。下面介绍一下关闭方法。
说明:蓝色=命令名称
浅绿=命令参数
浅蓝=选项
紫色=目录
系统环境:CentOS 6.2 i686
1、查看系统是否开启ipv6
a)通过网卡属性查看
命令:ifconfig
注释:有 “inet6 addr:。。。。。。。“ 的表示开启了ipv6功能
b)通过内核模块加载信息查看
命令:lsmod | grep ipv6
2、ipv6关闭方法
在/etc/modprobe.d/dist.conf结尾添加
alias net-pf-10 off
alias ipv6 off
可用vi等编辑器,也可以通过命令:
cat <<EOF>>/etc/modprobe.d/dist.conf
alias net-pf-10 off
alias ipv6 off
EOF
写改完毕重启电脑。
来自:http://www.cnblogs.com/taosim/articles/3152516.html
已有 392 次阅读 2012-01-31 17:14 标签: ipv6
linux默认是开启ipv6的,但是很多网络服务还不支持ipv6,开启了ipv6反而会影响服务器的网络性能。可以考虑关闭ipv6功能
在Linux下首先确认IPv6是否已经被启用,可以从三个方面确定。
1.使用ifconfig查看自己的IP地址是否含有IPv6地址。
eth0 Link encap:Ethernet HWaddr 00:0A:E4:FE:6F:E1
inet addr:172.28.245.104 Bcast:172.28.245.127 Mask:255.255.255.128
inet6 addr: fe80::20a:e4ff:fefe:6fe1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96998 errors:0 dropped:0 overruns:0 frame:0
TX packets:69963 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113588678 (108.3 MiB) TX bytes:8894978 (8.4 MiB)
Interrupt:20
2.查看服务监听的IP中是否有IPv6格式的地址。(netstat -tuln)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
udp 0 0 172.28.245.104:61440 0.0.0.0:*
udp 0 0 0.0.0.0:32823 0.0.0.0:*
udp 0 0 0.0.0.0:32824 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
3.使用lsmod|grep ipv6查看ipv6的模块是否被加载。
ipv6 245989 12
关闭IPV6的方式:
当确定IPv6已经开启后就可以按照下面的方法将其关闭
1.使用vi编辑器,打开/etc/modprobe.conf
2.在文档中加入如下的两条:
alias net-pf-10 off
alias ipv6 off
保存退出,并且重新启动系统。
重启之后可以使用上面的三种方法去验证IPv6支持是否已经被关闭。
IPv6是默认支持的,所以当你要重新开起IPv6支持时,将/etc/modprobe.conf中的两条指令注释掉就可以了。
======================================================================
http://www.111cn.net/sys/CentOS/50864.htm
http://www.linuxso.com/linuxrumen/17201.html
http://blog.csdn.net/suplxj/article/details/7773423
方法一:
CentOS 6 默认安装后,IPv6是自动开启的,但是现在IPv6还没有普及基本用不到这个功能,建议关闭IPv6模块。下面介绍一下关闭方法。
说明:蓝色=命令名称
浅绿=命令参数
浅蓝=选项
紫色=目录
系统环境:CentOS 6.2 i686
1、查看系统是否开启ipv6
a)通过网卡属性查看
命令:ifconfig
注释:有 “inet6 addr:。。。。。。。“ 的表示开启了ipv6功能
b)通过内核模块加载信息查看
命令:lsmod | grep ipv6
2、ipv6关闭方法
在/etc/modprobe.d/dist.conf结尾添加
alias net-pf-10 off
alias ipv6 off
可用vi等编辑器,也可以通过命令:
cat <<EOF>>/etc/modprobe.d/dist.conf
alias net-pf-10 off
alias ipv6 off
EOF
写改完毕重启电脑。
来自:http://www.cnblogs.com/taosim/articles/3152516.html
[实践OK]mac下安装redis 和 redis可视化工具rdm并且连接redis
Unix/LinuxC技术 jackxiang 2019-2-28 17:57
jackXiang@jackXsMacBook-Pro ~/ops master ● brew cask install rdm
Updating Homebrew...
Error: Cask 'rdm' is unavailable: No Cask with this name exists. Did you mean one of these?
avibrazil-rdm keyboard-maestro safeincloud-password-manager wordmark
avibrazil-rdm keyboard-maestro safeincloud-password-manager wordmark
keeper-password-manager orelord-mongodb watchguard-mobile-vpn-with-ssl
keeper-password-manager orelord-mongodb watchguard-mobile-vpn-with-ssl
可以在这里下载dmg:
链接:https://pan.baidu.com/s/1IPAgiaEByU0zA8fIov930w 密码:4pwi
安装之后的节目,输入连接名,地址,以及端口号就行了,点击下面的test connection测试连接
来自:https://blog.csdn.net/qq_41140741/article/details/86593955
Updating Homebrew...
Error: Cask 'rdm' is unavailable: No Cask with this name exists. Did you mean one of these?
avibrazil-rdm keyboard-maestro safeincloud-password-manager wordmark
avibrazil-rdm keyboard-maestro safeincloud-password-manager wordmark
keeper-password-manager orelord-mongodb watchguard-mobile-vpn-with-ssl
keeper-password-manager orelord-mongodb watchguard-mobile-vpn-with-ssl
可以在这里下载dmg:
链接:https://pan.baidu.com/s/1IPAgiaEByU0zA8fIov930w 密码:4pwi
安装之后的节目,输入连接名,地址,以及端口号就行了,点击下面的test connection测试连接
来自:https://blog.csdn.net/qq_41140741/article/details/86593955
[实践OK]static和extern理解
Unix/LinuxC技术 jackxiang 2019-2-28 10:05
[实践OK]Mac OS X mkdir: mkdir -p /home/xiangdong 出现mkdir: /home/xiangdong: Operation not supported
Unix/LinuxC技术 jackxiang 2019-2-24 11:55
现象:bogon:tmp root# mkdir -p /home/xiangdong
mkdir: /home/xiangdong: Operation not supported
目的:fFileZilla SFTP同步Linux上的家目录到Mac上。
解决办法:
sudo vim /etc/auto_master
/home auto_home -nobrowse,hidefromfinder #加上#号
bogon:tmp root# sudo automount
bogon:tmp root# mkdir -p /home/xiangdong #重启automount后就能成功创建。
Hmmm, trying to create a directory under '/home' on a Mac?
Well, Apple doesn't want you to (with good reason, automounter owns this dir, which makes it easier to do NFS mounts and such) so you shouldn't muck with it but if you really just 'have to do it', here is how you can.
Basically: Edit /etc/auto_master and remove or comment out the line that starts with "/home".
example:
sudo vim /etc/auto_master
before:
# Automounter master map
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
after:
# Automounter master map
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
#/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
to have the change take effect without a reboot:
sudo automount
mkdir /home/test
ls -l /home/
total 0
drwxr-xr-x 3 root admin 102 Aug 10 11:33 test
NOTE: I wouldn't do anything 'important' with this directory as it's easy to forget you altered this and an upgrade will plow over this directory, removing all data. (this dir is also not included in any Time Machine backups.
来自:https://blog.csdn.net/lychao89/article/details/53667068
mkdir: /home/xiangdong: Operation not supported
目的:fFileZilla SFTP同步Linux上的家目录到Mac上。
解决办法:
sudo vim /etc/auto_master
/home auto_home -nobrowse,hidefromfinder #加上#号
bogon:tmp root# sudo automount
bogon:tmp root# mkdir -p /home/xiangdong #重启automount后就能成功创建。
Hmmm, trying to create a directory under '/home' on a Mac?
Well, Apple doesn't want you to (with good reason, automounter owns this dir, which makes it easier to do NFS mounts and such) so you shouldn't muck with it but if you really just 'have to do it', here is how you can.
Basically: Edit /etc/auto_master and remove or comment out the line that starts with "/home".
example:
sudo vim /etc/auto_master
before:
# Automounter master map
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
after:
# Automounter master map
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
#/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
to have the change take effect without a reboot:
sudo automount
mkdir /home/test
ls -l /home/
total 0
drwxr-xr-x 3 root admin 102 Aug 10 11:33 test
NOTE: I wouldn't do anything 'important' with this directory as it's easy to forget you altered this and an upgrade will plow over this directory, removing all data. (this dir is also not included in any Time Machine backups.
来自:https://blog.csdn.net/lychao89/article/details/53667068
[实践OK]设置mac锁屏但不关闭网络,试图对Inode进行不断开的设置。
Unix/LinuxC技术 jackxiang 2019-2-22 13:47
背景:Inode在Mac下锁屏时间长后,网络断开了,如果中午吃饭后,再回来,就断开了,出现:
2019-02-22 09:36:26 Connecting to the network...
2019-02-22 09:36:31 Beginning authentication... [xiangdong]
2019-02-22 09:36:36 You have passed the identity authentication
2019-02-22 09:36:37 Obtaining IP address...
2019-02-22 09:36:44 Current IP address is 172.20.232.65
2019-02-22 09:36:49 Start security check session...
2019-02-22 09:36:49 Security check is passed.
2019-02-22 13:00:37 Disconnecting from the network...
2019-02-22 13:00:38 disconnect for time limit
2019-02-22 13:00:43 Connection failed.
------------------------------------------------------------------------------------------------------------------
在使用TeamViewer时,mac会自动休眠导致网络断开链接无法远程的问题。
尝试了一些方法,以下方法效果显著,特此记录。
第一步:
要设定锁定输入密码的设置,进入‘系统偏好设置’‘安全性与隐私’,将选项‘进入睡眠或开始屏幕保护程序后’打勾,选‘立即’。
第二步:
到‘launchpad’中的‘其他’文件夹打开‘Automator’,或者直接到spotlight中输入定位过去(就是拿火箭筒的小机器人)
第三步:
接下来,会弹出一个窗口,选‘新建文稿’,在弹出窗口中的‘文稿类型’选择‘服务’。
第四步:
首先可以到搜索框中输‘屏幕’,所有和屏幕有关的项目就都出来了,包括我想要的‘启动屏幕保护程序’,选中拖动到右面的框里,记住,要把“‘服务’收到”这项改为‘没有输入’,然后到菜单‘文件’中选择‘存储’,输个服务的名称,比如‘屏保’。
第五步:
到‘系统偏好设置’‘键盘’‘快捷键’‘服务’ 中,找到刚刚那个服务‘屏保’,添加快捷键,最好不要和其他的冲突 。
参考地址:http://blog.csdn.net/wo2niliye/article/details/52440012
原文:https://blog.csdn.net/zww1984774346/article/details/79303563
2019-02-22 09:36:26 Connecting to the network...
2019-02-22 09:36:31 Beginning authentication... [xiangdong]
2019-02-22 09:36:36 You have passed the identity authentication
2019-02-22 09:36:37 Obtaining IP address...
2019-02-22 09:36:44 Current IP address is 172.20.232.65
2019-02-22 09:36:49 Start security check session...
2019-02-22 09:36:49 Security check is passed.
2019-02-22 13:00:37 Disconnecting from the network...
2019-02-22 13:00:38 disconnect for time limit
2019-02-22 13:00:43 Connection failed.
------------------------------------------------------------------------------------------------------------------
在使用TeamViewer时,mac会自动休眠导致网络断开链接无法远程的问题。
尝试了一些方法,以下方法效果显著,特此记录。
第一步:
要设定锁定输入密码的设置,进入‘系统偏好设置’‘安全性与隐私’,将选项‘进入睡眠或开始屏幕保护程序后’打勾,选‘立即’。
第二步:
到‘launchpad’中的‘其他’文件夹打开‘Automator’,或者直接到spotlight中输入定位过去(就是拿火箭筒的小机器人)
第三步:
接下来,会弹出一个窗口,选‘新建文稿’,在弹出窗口中的‘文稿类型’选择‘服务’。
第四步:
首先可以到搜索框中输‘屏幕’,所有和屏幕有关的项目就都出来了,包括我想要的‘启动屏幕保护程序’,选中拖动到右面的框里,记住,要把“‘服务’收到”这项改为‘没有输入’,然后到菜单‘文件’中选择‘存储’,输个服务的名称,比如‘屏保’。
第五步:
到‘系统偏好设置’‘键盘’‘快捷键’‘服务’ 中,找到刚刚那个服务‘屏保’,添加快捷键,最好不要和其他的冲突 。
参考地址:http://blog.csdn.net/wo2niliye/article/details/52440012
原文:https://blog.csdn.net/zww1984774346/article/details/79303563