[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1128
  • Last Modified:

Accidently wrote binary file into Terminal window AIX 6.1 error

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
assistunix
Asked:
assistunix
  • 6
  • 3
  • 2
  • +1
2 Solutions
 
sweetfa2Commented:
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
 
arnoldCommented:
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
 
assistunixAuthor Commented:
[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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
woolmilkporcCommented:
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
 
assistunixAuthor Commented:
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
 
woolmilkporcCommented:
ATTENTION: Better use this additional parameter with find

find . -type f -inum number -xdev -exec rm {} \;
0
 
assistunixAuthor Commented:
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
 
assistunixAuthor Commented:
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
 
assistunixAuthor Commented:
@ sweetfa2

your command - stty sane<ctrl-j> hadn't dont anything, what was it suppose to do? is that like reset command?
0
 
woolmilkporcCommented:
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
 
sweetfa2Commented:
Yes - just reset of the terminal if you have had a lot of crap control characters output to the screen
0
 
assistunixAuthor Commented:
Thank you.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now