IBM Support

AIX Base Commands: Why do commands report an existing file or directory does not exist?

Question & Answer


Question

I want to remove an existing file, but the ls and rm commands say it does not exist.

#ls authorized_keys*
authorized_keys2
authorized_keys

# ls authorized_keys
ls: 0653-341 The file authorized_keys does not exist.

# rm authorized_keys
rm: authorized_keys: A file or directory in the path name does not exist.



Answer

The most likely root cause is a non-printing character in the file name. You can check the characters in the file name with the od command:

# ls -1 | od -xc
0000000     6175    7468    6f72    697a    6564    5f6b    6579    7332
           a   u   t   h   o   r   i   z   e   d   _   k   e   y   s   2
0000020     0a61    7574    686f    7269    7a65    645f    6b65    7973
          \n   a   u   t   h   o   r   i   z   e   d   _   k   e   y   s
0000040     32
7f    000a
           2 177  \0
0000043

Root Cause: 
There is a non-printing x7f (DELETE) character in the file name.

Solution: 
You can use the full file name to list or remove the file.

# ls authorized_keys2?
authorized_keys
 
# rm authorized_keys2?
(No error)

Verify that the authorized_keys2 remains:

# ls -q authorized_keys*
authorized_keys2


 

 
SUPPORT

If you require more assistance, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract.  

1.  Document (or collect screen captures of) all symptoms, errors, and messages related to your issue.

2.  Capture any logs or data relevant to the situation.

3.  Contact IBM to open a case:

   -For electronic support, see the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, see the web page:
      https://www.ibm.com/planetwide/

4.  Provide a clear, concise description of the issue.

5.  If the system is accessible, collect a system snap, and upload all of the details and data for your case.

 - See Working with IBM AIX Support: Collecting snap data


[{"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":"All Versions"}]

Document Information

More support for:
AIX

Component:
Commands

Software version:
All Versions

Operating system(s):
AIX

Document number:
7150235

Modified date:
03 May 2024

UID

ibm17150235

Manage My Notification Subscriptions