IBM Support

vi command returns to prompt

Troubleshooting


Problem

# /usr/bin/vi myfile
# 
No errors displayed and vi does not enter the editor shell

Symptom

No error. Command just returns to prompt.

Cause

Symptoms are typical of a null/zeroed out binary.
Symptom may also be due to a missing /var/tmp directory (used by vi), or due to missing write permission for /var/tmp directory.

Diagnosing The Problem

1) Verify that the vi binary is not nulled out....
# ls -l /usr/bin/vi
-r-xr-xr-x    5 bin      bin          0 Mar 14 05:52 /usr/bin/vi
                                      ^ <-- !!! File size is 0 bytes!
If the file size is 0 bytes copy the binary from another system with the same level or extract it from bos.rte.edit.
 
2) If vi binary is not null, collect truss of the vi command:
 
# truss -aefo /tmp/truss.out vi myfile
2a) If /var/tmp does not exist:

The truss output shows statx of /var/tmp returns ENOENT (does not exist) and vi exits:
 
3736044: execve("/usr/bin/vi", 0x2FF22C50, 0x200130A8) argc: 2
3736044: 29229335: argv: vi myfile
3736044: 29229335: envp: _=/usr/bin/truss LANG=C LOGIN=root
...
3736044: 29229335: statx("/var/tmp", 0x2FF22278, 76, 0) Err#2 ENOENT    <-- !!!
3736044: 29229335: sigprocmask(0, 0x00000000, 0x30413738) = 0
3736044: 29229335: kwrite(1, "1B [ ? 1 0 4 9 h1B [ 4 4".., 26) = 26
3736044: 29229335: kwrite(2, "1B [ 7 m N o s u c h ".., 29) = 29
3736044: 29229335: kwrite(2, "1B [ 2 7 m", 5) = 5
3736044: 29229335: _getpid() = 3736044
3736044: 29229335: kwrite(1, "\n", 1) = 1
3736044: 29229335: lseek(0, 0, 2) = 0
3736044: 29229335: sigcleanup(0x30413738) = 0
3736044: 29229335: kwrite(1, "\n", 1) = 1
3736044: 29229335: kwrite(1, "1B [ ? 1 0 4 9 l", 8) = 8
3736044: 29229335: kioctl(2, 21511, 0xF09F6D9E, 0x00000000) = 0
3736044: 29229335: kwrite(1, "1B [ J", 3) = 3
3736044: 29229335: kwrite(1, "1B [ ? 1 2 l1B [ ? 2 5 h", 12) = 12
3736044: 29229335: kfcntl(1, F_GETFL, 0x30002084) = 67110914
3736044: 29229335: kfcntl(2, F_GETFL, 0x2FF22FFC) = 67110914
3736044: 29229335: _exit(1)


==> Check for existence of /var/tmp directory:
 
# ls -l /var/tmp
/var/tmp not found
--> /var/tmp does not exist
==> recreate it with the following commands:
# mkdir /var/tmp
# chown bin:bin /var/tmp
# chmod 1777 /var/tmp
2b) If the write permission is missing for /var/tmp:
The truss output shows kopen of the temporary file in /var/tmp fails with EACCES (access denied) and vi exits:
51839734: execve("/usr/bin/vi", 0x2FF22AE0, 0x20016CE8)  argc: 2
51839734: 26673987: argv: vi myfile
51839734: 26673987: envp: _=/usr/bin/truss LANG=en_US LOGIN=in02539p VISUAL=emacs
[...]
51839734: 26673987: statx("/var/tmp", 0x2FF22108, 76, 0) = 0
51839734: 26673987: _getpid()            = 51839734
51839734: 26673987: kopen("/var/tmp/Ex39734", O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR) Err#13 EACCES      <-- !!!
51839734: 26673987: __ksetjmp(0x30411E40, 0x0000000D, 2, 0x30411EA4, 0x1001F960, 0x32242302, 0x30005E88, 0xD034E4C8) = 0
51839734: 26673987: access("/usr/lib/nls/msg/en_US/libc.cat", 0) = 0
51839734: 26673987: _getpid()            = 51839734
51839734: 26673987: kopen("/usr/lib/nls/msg/en_US/libc.cat", O_RDONLY) = 3
51839734: 26673987: kioctl(3, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
51839734: 26673987: kfcntl(3, F_SETFD, 0x00000001) = 0
51839734: 26673987: kioctl(3, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
51839734: 26673987: kread(3, "\0\001 ▒\007\007 I S O 8".., 4096) = 4096
51839734: 26673987: lseek(3, 0, 1)               = 4096
51839734: 26673987: lseek(3, 0, 1)               = 4096
51839734: 26673987: __libc_sbrk(0x00000000) = 0x309DAA00
51839734: 26673987: lseek(3, 0, 1)               = 4096
51839734: 26673987: _getpid()            = 51839734
51839734: 26673987: lseek(3, 0, 1)               = 4096
51839734: 26673987: close(3)             = 0
51839734: 26673987: kwrite(1, "1B [ ? 1 0 4 9 h1B [ 6 2".., 34) = 34
51839734: 26673987: kwrite(2, "1B [ 7 m T h e   f i l e".., 66) = 66
51839734: 26673987: kwrite(2, "1B [ 2 7 m", 5) = 5
51839734: 26673987: _getpid()            = 51839734
51839734: 26673987: kwrite(1, "\n", 1)   = 1
51839734: 26673987: lseek(0, 0, 2)               = 0
51839734: 26673987: __ksetjmp(0x30411E40, 0x00000001, 18, 0x00000000, 0x00000000, 0x00000000, 0xF0A491E4, 0xD034E4C8) = 0
51839734: 26673987: kwrite(1, "\n", 1)   = 1
51839734: 26673987: kwrite(1, "1B [ ? 1 0 4 9 l", 8) = 8
51839734: 26673987: kioctl(2, 21511, 0xF145965E, 0x00000000) = 0
51839734: 26673987: kwrite(1, "1B [ J", 3)       = 3
51839734: 26673987: kwrite(1, "1B [ ? 1 2 l1B [ ? 2 5 h", 12) = 12
51839734: 26673987: kfcntl(1, F_GETFL, 0x305CA9E8) = 67110914
51839734: 26673987: kfcntl(2, F_GETFL, 0x2FF22FFC) = 67110914
51839734: 26673987: _exit(1)

==> Check for permissions of /var/tmp directory:
 
# ls -ld /var/tmp
drwxrwxr-t    8 bin      bin           12288 May  9 05:37 /var/tmp/
        ^ <-- !!! write permission is missing
--> /var/tmp has no write permission for other
==> change permissions to include write for other:
# chmod 1777 /var/tmp

Resolving The Problem

If the vi binary is 0 bytes in size restore it from fileset bos.rte.edit (or copy it from another system).
If /var/tmp directory is missing recreate it:

# mkdir /var/tmp
# chown bin:bin /var/tmp
# chmod 1777 /var/tmp
If /var/tmp is missing write permission then correct the permissions:
# chmod 1777 /var/tmp

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z000000cvzgAAA","label":"Commands"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"6.1.0;7.1.0;7.2.0;7.3.0"}]

Document Information

Modified date:
12 May 2025

UID

isg3T1022710