Run it as root under strace. that'll show you the system calls and return codes, usually gets to the bottom of wierd issues like that. Eg heres what I get running grep successfully so that it just shows only its help page. You can see a lot of detail about whats going on between it and the system.
Code: Select all
[antus@ant bin]$ strace grep
execve("/usr/bin/grep", ["grep"], [/* 75 vars */]) = 0
brk(NULL) = 0x133f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb6a000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=159779, ...}) = 0
mmap(NULL, 159779, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9cbeb42000
close(3) = 0
open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=402384, ...}) = 0
mmap(NULL, 2494984, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe6e8000
mprotect(0x7f9cbe748000, 2097152, PROT_NONE) = 0
mmap(0x7f9cbe948000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x60000) = 0x7f9cbe948000
close(3) = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P%\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2173512, ...}) = 0
mmap(NULL, 3981792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe31b000
mprotect(0x7f9cbe4de000, 2093056, PROT_NONE) = 0
mmap(0x7f9cbe6dd000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c2000) = 0x7f9cbe6dd000
mmap(0x7f9cbe6e3000, 16864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9cbe6e3000
close(3) = 0
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0m\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144792, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb41000
mmap(NULL, 2208904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe0ff000
mprotect(0x7f9cbe116000, 2093056, PROT_NONE) = 0
mmap(0x7f9cbe315000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f9cbe315000
mmap(0x7f9cbe317000, 13448, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9cbe317000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb3f000
arch_prctl(ARCH_SET_FS, 0x7f9cbeb3f740) = 0
mprotect(0x7f9cbe6dd000, 16384, PROT_READ) = 0
mprotect(0x7f9cbe315000, 4096, PROT_READ) = 0
mprotect(0x7f9cbe948000, 4096, PROT_READ) = 0
mprotect(0x624000, 4096, PROT_READ) = 0
mprotect(0x7f9cbeb6b000, 4096, PROT_READ) = 0
munmap(0x7f9cbeb42000, 159779) = 0
set_tid_address(0x7f9cbeb3fa10) = 29987
set_robust_list(0x7f9cbeb3fa20, 24) = 0
rt_sigaction(SIGRTMIN, {0x7f9cbe1057e0, [], SA_RESTORER|SA_SIGINFO, 0x7f9cbe10e6d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f9cbe105870, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f9cbe10e6d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL) = 0x133f000
brk(0x1360000) = 0x1360000
brk(NULL) = 0x1360000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9cb7bd6000
close(3) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 9), ...}) = 0
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb69000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2502
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7f9cbeb69000, 4096) = 0
open("/usr/share/locale/en_AU.utf8/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_AU/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Usage: grep [OPTION]... PATTERN "..., 42Usage: grep [OPTION]... PATTERN [FILE]...
) = 42
write(2, "Try 'grep --help' for more infor"..., 40Try 'grep --help' for more information.
) = 40
close(1) = 0
close(2) = 0
exit_group(2) = ?
+++ exited with 2 +++