Solved

Accidently wrote binary file into Terminal window AIX 6.1 error

Posted on 2010-11-25
12
1,092 Views
Last Modified: 2012-05-10
Hello
I believe i had accidently wrote a binary file to my / filessystem.
I was trying to transfer a file over to my aix box over telnet via a software called SecureCRT.

I had logged into my aix server via SecureCRT and chosen an option from within that software to transfer a binary a file.
After i chose that option, i believe that particulary binary file got written onto / filesystem or the terminal- i am not really sure what happened!

But now i got bunch of weird looking files in my / filesystem and i am getting an error in my putty session after i type ls command. the error i get is puttyputtyputty name on the command line.

I know the reason i am getting the puttyputtyputty error is due to those weird binary files in / filesystem, and the error is only in / filesystem, every other filesystem works just fine.

[root@server] / # ls
_       h
~                           .sh_history                 bharamount                  home                        pconsole                    u
Ô
óð                           .toc                        bin                         image.data                  proc                        unix
-[ó±
ÅÚþ ôôæ®öOØþ
   .TTauthority                .wmrc                       bosinst.data                lib                         smit.log                    uxm
.Xauthority                 TFSMOUNT                    cdrom                       lost+found                  smit.script                 var
.dt                         TT_DB                       configassist.log            lpp                         smit.transaction            websm.script
.dtprofile                  a.out                       dev                         mbox                        test
.exrc                       aap                         etc                         mio                         testmount                   ©$
                                                                                                                                              ÂH
.java                       abc                         fia                         mkcd                        tfs
.kshrc                      abcd                        gcc                         mnt                         tftpboot
.mozilla                    admin                       gcc-4.2.0-3.aix5.3.ppc.rpm  notes                       tmp
.profile                    audit                       helloworld.c                opt                         tsa
[root@server] / # PuTTYPuTTYPuTTY

i tried deleting whatever werid files i was able to, but i am unable to delete the remaining files, as the names are weird and broken of those files.

can someone help me undo this binary copy that i did? also tell me how i can remove all contents of a directory with one command without removing the actual directory.

thanks.


0
Comment
Question by:assistunix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 17

Assisted Solution

by:sweetfa2
sweetfa2 earned 100 total points
ID: 34214452
try entering

stty sane<ctrl-j>

in your putty session.

To remove wierd files try "rm -i *"

That will ask you to confirm each file before you delete

To delete all files in a directory without removing the directory "rm -f directorypath/*"
0
 
LVL 78

Expert Comment

by:arnold
ID: 34214468
rm -i * go through one item at a time approving the ones you want deleted.

the other option do:
ls > /tmp/files
edit /tmp/files and remove the items you do not want removed.
then run:
 rm -i `echo /tmp/files`

or run
cat /tmp/files | while read a; do
rm "$a"
0
 

Author Comment

by:assistunix
ID: 34214473
[root@server] / # rm -i *
rm: Remove _    h
~? y             g
rm: Remove Ô
óð? y
rm: Remove -[ó±
ÅÚþ            ôôæ®öOØþ
   rm: 0653-603 Cannot remove directory TFSMOUNT.
rm: 0653-603 Cannot remove directory TT_DB.
rm: Remove a.out? n
rm: 0653-603 Cannot remove directory aap.
rm: 0653-603 Cannot remove directory abc.
rm: 0653-603 Cannot remove directory abcd.
rm: 0653-603 Cannot remove directory admin.
rm: 0653-603 Cannot remove directory audit.
rm: 0653-603 Cannot remove directory bharamount.
rm: Remove bin? N
rm: Remove bkprofile? N
rm: Remove bosinst.data? N
rm: Remove configassist.log? N
rm: 0653-603 Cannot remove directory dev.
rm: 0653-603 Cannot remove directory etc.
rm: 0653-603 Cannot remove directory fia.
rm: 0653-603 Cannot remove directory home.
rm: Remove image.data? N
rm: Remove lft0? N
rm: Remove lib? N
rm: 0653-603 Cannot remove directory lost+found.
rm: 0653-603 Cannot remove directory lpp.
rm: Remove mbox? N
rm: 0653-603 Cannot remove directory mio.
rm: 0653-603 Cannot remove directory mnt.
rm: 0653-603 Cannot remove directory notes.
rm: 0653-603 Cannot remove directory opt.
rm: 0653-603 Cannot remove directory pconsole.
rm: 0653-603 Cannot remove directory proc.
rm: 0653-603 Cannot remove directory sbin.
rm: Remove smit.log? N
rm: Remove smit.script? N
rm: Remove smit.transaction? N
rm: Remove test? N
rm: 0653-603 Cannot remove directory testmount.
rm: 0653-603 Cannot remove directory tftpboot.
rm: 0653-603 Cannot remove directory tmp.
rm: Remove tsa? N
rm: Remove u? N
rm: Remove unix? N
rm: 0653-603 Cannot remove directory usr.
rm: 0653-603 Cannot remove directory var.
rm: Remove websm.script? N
rm: Remove? N
rm: Remove ©$
             ÂH? PuTTYY
[root@server] / # ls
-[ó±
ÅÚþ ôôæ®öOØþ
   .TTauthority      .mozilla          TT_DB             bharamount        fia               mbox              sbin              tmp
.Xauthority       .profile          a.out             bin               home              mio               smit.log          tsa               ©$
                                                                                                                                                  ÂH
.dt               .sh_history       aap               bkprofile         image.data        mnt               smit.script       u
.dtprofile        .toc              abc               bosinst.data      lft0              notes             smit.transaction  unix
.exrc             .vi_history       abcd              configassist.log  lib               opt               test              usr
.java             .wmrc             admin             dev               lost+found        pconsole          testmount         var
[root@server] / # rm -i *
rm: Not a recognized flag: [
Usage: rm [-firRe] [--] File...
[root@server] / # rm -i *
rm: Not a recognized flag: [
Usage: rm [-firRe] [--] File...
[root@server] / #

i used rm -i * as you said, the command worked, but the issue was still there so i tried running the command again, but now it doesn't work- did i accidently delete or mess up the rm -i * command function?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 68

Accepted Solution

by:
woolmilkporc earned 400 total points
ID: 34214498
That's because your directory listing now starts with a dash "-" which is interpreted as a flag by "rm"

If everything fails you can do

ls -i

to get the inode numbers of all files listed in the first column of the output.

Note the numbers of all files you want to remove, then issue against every number:

find . -type f -inum number -exec rm {} \;

number is an inode number from "ls -i".

0
 

Author Comment

by:assistunix
ID: 34214501
it seems as if, after once running the rm command with wild flag * , the * flag is no longer valid or available within / filesystem. i can run rm -i * and ls * in /tmp , but when i try running rm -i * or even ls * in / filesystem, it does not run.


[root@server] / # ls *
ls: Not a recognized flag: [
ls: Not a recognized flag: ó
ls: Not a recognized flag: ±
ls: Not a recognized flag:

ls: Not a recognized flag: ô
ls: Not a recognized flag:
ls: Not a recognized flag:
ls: Not a recognized flag: ô
ls: Not a recognized flag:
ls: Not a recognized flag: æ
ls: Not a recognized flag: ®
ls: Not a recognized flag: ö
ls: Not a recognized flag: O
ls: Not a recognized flag:
ls: Not a recognized flag:
ls: Not a recognized flag:
ls: Not a recognized flag: Ø
ls: Not a recognized flag: þ
ls: Not a recognized flag:
ls: Not a recognized flag: Å
ls: Not a recognized flag: Ú
ls: Not a recognized flag: þ
ls: Not a recognized flag:
ls: Not a recognized flag:

ls: Not a recognized flag: Ø
ls: Not a recognized flag:

ls: Not a recognized flag: ¢
ls: Not a recognized flag: w
ls: Not a recognized flag: Þ
ls: Not a recognized flag: ñ
ls: Not a recognized flag: ß
ls: Not a recognized flag: Ä
ls: Not a recognized flag:
ls: Not a recognized flag: z
ls: Not a recognized flag:
ls: Not a recognized flag:
ls: Not a recognized flag: Ø
ls: Not a recognized flag:
ls: Not a recognized flag: ä
ls: Not a recognized flag: »
ls: Not a recognized flag: 2
ls: Not a recognized flag:
ls: Not a recognized flag:
Usage: ls [-1ACFHLNRabcdefgilmnopqrstuxEUX] [File...]
[root@server] / # PuTTYPuTTY
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34214517
ATTENTION: Better use this additional parameter with find

find . -type f -inum number -xdev -exec rm {} \;
0
 

Author Comment

by:assistunix
ID: 34214522
Great- thank you - wmp . that worked.
i am not too familiar with inode concept, but from the look of things , it seems as inode is a number generated by system which is assiged to every file and directory, as there is UID assigned to every user.
Is that correct?
0
 

Author Comment

by:assistunix
ID: 34214526
i had used your first command and that worked- would you like me to try using the second command as well, with the additional parameter- what does the additional parameter signify ?
0
 

Author Comment

by:assistunix
ID: 34214536
@ sweetfa2

your command - stty sane<ctrl-j> hadn't dont anything, what was it suppose to do? is that like reset command?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34214586
Yes, the inode contains meta-information about a file, every file has its inode and every inode has its number. find is able to select files based on this number ("-inum")

No need to repeat the command - -xdev is to prevent find from finding an inode with the same number in a filesystem mounted under / - it's only a precaution.

stty sane resets a terminal's parameters to some "reasonable" (quoting the manpage) values.
It could have been that there was a terminal control character inside your binary data stream which could have messed up the terminal settings. stty sane would possibly repair this.

Regarding the output you posted this doesn't seem to have been necessary.

0
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34214607
Yes - just reset of the terminal if you have had a lot of crap control characters output to the screen
0
 

Author Closing Comment

by:assistunix
ID: 34214617
Thank you.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question