Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.7/

Posted by 撒得一地 on 2015年12月21日 in Linux笔记

我是一个使用Unix / Linux命令行bash/ksh/tcsh的新用户。我被告知要使用ps命令如下:

ps -auxf | sort -nr -k 4 | head -10


Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ



ps auxf | sort -nr -k 4 | head -10


但为什么"ps -aux"报一个bogus(虚假-) '-'?

根据POSIX和UNIX的标准,上面的命令要求显示终端上所有进程(一般命令是用户输入运行的)并且这些进程的拥有者属于用户"x"。如果用户不存在,那么PS会假设你命令真正的意思是“ps aux”。警告是轻轻地打破你的习惯,如果这个"x"用户真的存在,那么上面使用的命令会使你陷入麻烦(产生歧义)。而这些可能产生的歧义信息被记录在/usr/share/doc/procps-3.2.7/FAQ 文件中:


less /usr/share/doc/procps-3.2.8/FAQ 
less /usr/share/doc/procps-3.2.7/FAQ

Sample outputs:

Why does "ps -aux" complain about a bogus '-'?

According to the POSIX and UNIX standards, the above command asks to display all processes with a TTY (generally the commands users are running) plus all processes owned by a user named "x". If that user doesn't exist, then ps will assume you really meant "ps aux". The warning is given to gently break you of a habit that will cause you trouble if a user named "x" were created.

Why don't I see SMP (per-CPU) stats in top?

You didn't enable it. Press '?' for built-in help or read the man page. Per-CPU stats are disabled by default because they take up too much space. Some Linux systems have hundreds of CPUs.

Why do long usernames get printed as numbers?

The UNIX and POSIX standards require that user names and group names be printed as decimal integers when there is not enough room in the column. Truncating the names, besides being a violation of the standard, would lead to confusion between names like MichelleRichards and MichelleRichardson. The UNIX and POSIX way to change column width is to rename the column:

ps -o pid,user=CumbersomeUserNames -o comm

The easy way is to directly specify the desired width:

ps -o pid,user:19,comm

Why is %CPU underreported for multi-threaded (Java, etc.) apps?

You need to upgrade to the 2.6.10 kernel at least. Older kernels do not provide a reasonable way to get this information.

Why do ps and top show threads individually?

The 2.4.xx kernel does not provide proper support for grouping threads by process. Hacks exist to group them anyway, but such hacks will falsely group similar tasks and will fail to group tasks due to race conditions. The hacks are also slow. As none of this is acceptable in a critical system tool, task grouping is not currently available for the 2.4.xx kernel. The 2.6.xx kernel allows for proper thread grouping and reporting. To take advantage of this, your programs must use a threading library that features the CLONE_THREAD flag. The NPTL pthreads provided by recent glibc releases use CLONE_THREAD.

What systems are supported?

Linux 2.4.xx and 2.6.xx are commonly tested and expected to work well. SMP is well supported. Multi-node cluster views require a multi-node /proc filesystem; without that you will see a single-node view.

Where to I send bug reports?

You may use the Debian bug tracking system or send your report to procps-feedback@lists.sf.net (no subscription required) instead.

Why are there so many procps projects?

The original maintainer seems to have had little time for procps. Whatever his reasons, the project didn't get maintained. Starting in 1997, Albert Cahalan wrote a new ps program for the package. For the next few years, Albert quietly helped the Debian package maintainer fix bugs. In 2001, Rik van Riel decided to do something about what appeared to be the lack of a maintainer. He picked up the buggy old code in Red Hat's CVS and started adding patches. Meanwhile, other people have patched procps in a great many ways. In 2002, Albert moved procps to this site. This was done to ensure that years of testing and bug fixes would not be lost. The major version number was changed to 3, partly to avoid confusing users and partly because the top program has been redone.

Why does ps get signal 17?

No ps release has ever had this problem. Most likely your system has been broken into. You might want to install a more recent version of the OS. If you'd rather take your chances, simply upgrade procps.






电子邮件地址不会被公开。 必填项已用*标注

0 + 0 = ?


Copyright © 2015-2017 技术拉近你我! All rights reserved.