Unix & Linux

Linux,FreeBSD和其他类似Un * x的操作系统用户的问答

7
为什么我必须从已删除的目录CD出来?
在我的服务器上,我有一个目录结构,看起来像这样: /myproject/code 我通常与服务器建立ssh连接,并在该目录中“站立”: root@machine:/myproject/code# 当我部署新版本的代码时,代码目录将被删除,因此我将剩下: root@machine:/myproject/code# ./run -bash: ./run: No such file or directory 我发现的唯一解决方案是cd并返回: root@machine:/myproject/code# cd ../code root@machine:/myproject/code# ./run Running... 我可以避免吗?这有点奇怪。如果您有一个很好的解释,为什么会这样,我将不胜感激。

8
hostapd不会通过“服务”启动,而是直接启动
我无法hostapd开始即服务。当我尝试启动它时失败: $ sudo service hostapd start [FAIL] Starting advanced IEEE 802.11 management: hostapd failed! 据我了解,这将使用以下配置/etc/default/hostapd: $ cat /etc/default/hostapd # Defaults for hostapd initscript # # See /usr/share/doc/hostapd/README.Debian for information about alternative # methods of managing hostapd. # # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration …


9
测试是否设置了多个变量
我想确保在脚本的某个点上,在访问source配置文件后,设置了几个变量,如果没有设置,将停止执行,以告知用户缺少的变量。我试过了 for var in $one $two $three ; do ... 但是,例如$two,如果未设置,则永远不会为执行该循环$two。我接下来尝试的是 for var in one two three ; do if [ -n ${!var} ] ; then echo "$var is set to ${!var}" else echo "$var is not set" fi done 但是,如果没有设置两个,我仍然会得到“两个设置为”而不是“两个未设置”。 如何确保设置了所有必需的变量? 更新/解决方案:我知道“设置”和“设置,但为空”之间存在区别。我现在使用(感谢/programming//a/16753536/3456281和此问题的答案)以下内容: if [ -n "${!var:-}" ] ; then …

9
禁用PulseAudio中的耳机插孔检测
我的笔记本电脑上有一个笨拙的耳机端口,无法可靠地检测到何时插入了耳机/外部扬声器。这意味着输出一直在静音/取消静音,这很烦人 如何配置pulseaudio禁用插孔检测(或者只是强制通过此插孔输出)? 我假设它将涉及编辑Analog-output-headphones.conf,但是我不知道该怎么做(analog-output.conf.common没有帮助)。
19 pulseaudio 

18
如何向后读取IP地址?
如果我们有以下字符串(IP地址):192.168.1.1 如何从此字符串派生(DNS反向记录形式),因此它将像1.1.168.192.in-addr.arpa使用Shell脚本一样显示?


3
nohup:忽略输入并将stderr重定向到stdout
我正在使用nohup下面提到的在后台启动我的应用程序- root@phx5qa01c:/bezook# nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname phx5qa01c.phx.qa.host.com > exhibitor.out & [1] 30781 root@phx5qa01c:/bezook# nohup: ignoring input and redirecting stderr to stdout 但是每次我看到此消息时- nohup: ignoring input and redirecting stderr to stdout 如果看到此消息,会有任何问题吗?这是什么意思,我该如何避免?

3
从/ dev / random读取不会产生任何数据
我经常使用命令 cat /dev/urandom | strings --bytes 1 | tr -d '\n\t ' | head --bytes 32 生成伪随机密码。这不适用于/dev/random。 特别 cat /dev/urandom | strings --bytes 1 | tr -d '\n\t ' 产生输出 cat /dev/random | strings --bytes 1 产生输出 cat /dev/random | strings --bytes 1 | tr -d '\n\t ' 不产生输出 注意:使用时,/dev/random您可能不得不扭动鼠标或按下键(例如ctrl,shift等)以产生熵。 …
19 linux  random 

1
索引节点,LBA,逻辑卷,块和扇区之间是什么关系?
我有点不好意思问这个问题,但是我想看一个图表,显示以下内容之间的关系。如果该图还包括在各个层之间进行映射所需的任何变换,那将是很好的。 据我了解,我相信它们之间的关系如下,但是我不确定我的理解是100%准确的。 .-----------------. | inode | '-----------------' | .-----------------. | EXT4 | '-----------------' | .---------------------. | logical volume (LV) | --- part of LVM '---------------------' | .-------------------. | volume group (VG) | --- part of LVM '-------------------' | .---------------. | /dev/<device> | '---------------' | .--------------------------------. | Logical Block Addressing (LBA) …

2
使用pandoc将.docx转换为.pdf
我正在尝试通过使用pandoc将邮件接收的.docx转换为正确的pdf(我正在使用GNU / Linux)。 我有一个关于字符编码的错误: $ pandoc file.docx -o file.pdf pandoc: Cannot decode byte '\x87': Data.Text.Encoding.decodeUtf8: Invalid UTF-8 stream 我试图识别编码: $ file -i file .docx file.docx: application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=binary 我有点惊讶charset=binary(我原以为是charset=iso8859-15)。但是我还是试图将.docx转换为utf8,但它不起作用: $ iconv -t utf-8 file.docx P! $iconv: séquence d'échappement non permise à la position 16 我在pandoc文档的命令行中有相同的错误: iconv -t utf-8 file.docx | pandoc …


5
在Debian测试中通过pip安装PIL /枕头(Jessie)
在Debian测试(杰西),当我尝试在安装PIL或枕头(Python图像库)virtualenv通过pip我得到以下错误: running egg_info writing Pillow.egg-info/PKG-INFO writing top-level names to Pillow.egg-info/top_level.txt writing dependency_links to Pillow.egg-info/dependency_links.txt warning: manifest_maker: standard file '-c' not found reading manifest file 'Pillow.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'Pillow.egg-info/SOURCES.txt' running build_ext building 'PIL._imaging' extension creating build/temp.linux-x86_64-2.7/libImaging x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC …
19 debian  python  pip 

3
使用^作为外壳元字符
我今天写了一个小脚本,其中包含 grep -q ^local0 /etc/syslog.conf 在审查过程中,一位同事建议^local0引用该词,因为^在Bourne外壳中意为“烟斗”。对此声明感到惊讶,我试图查找提及此内容的任何参考。我在互联网上没有发现任何暗示这是问题的信息。 但是,事实证明,bsh在AIX 7上的实现(声称是Bourne shell)实际上具有以下行为: > bsh $ ls ^ wc 23 23 183 $ ls | wc 23 23 183 我尝试过的其他“ Bourne shell”实现^都没有这种行为的方式(也就是说,根本不被认为是shell元字符)。我sh在CentOS(实际上是bash)和shFreeBSD(不是bash)上进行了尝试。我没有很多其他系统可以尝试。 这是预期的行为吗?哪些壳被认为^是管道元字符?


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.