3

I have a thumbdrive which I use to plug in at print shops to get my printing done. The first time it got infected by a Windows malware "Gamarue", I copied out files using Ubuntu and formatted it, no harm done. I head on down to an entirely different print shop, and it gets infected again with the same malware. :(

Anyway, interesting question the malware hides your content in a "nameless" folder and to the unsuspecting user baits you into double clicking a .lnk file which, I assume, allows the malware to copy onto your computer. I couldn't see this nameless folder while in Windows.

While using the file viewer in Ubuntu, I can see that there is a folder there with no name containing all my files. Now just for kicks, I decided to access this folder via terminal. All I need to do is to cd into /media, view the folder and copy out the folders if I desire right? Well nope...

$ ls -l
total 20
drwx------ 1 seelan seelan  4096 Sep 27 10:11 System Volume Information
-rw------- 2 seelan seelan   817 Sep 27 10:11 Theia (30GB).lnk
drwx------ 1 seelan seelan 12288 Sep 27 10:11  

Tadaaaa a nameless folder/directory that I cannot access via terminal. How would I go about accessing this folder? Any ideas?

Edit: a little more research into it shows that the non-printing character is octal character 302 240. this was done by "ls -l | od -c" showing the octal character occupying the space. link states that "The character-pair \302\240 is the "NO-BREAK SPACE" from UTF-8 encoding.". Only issue now is you cannot rename files via terminal and you can't enter octal characters when copying the file or can you?

Answer Edit: Considering it was a non-printing character, i looked for a way to change the encoding of the terminal, hopefully i could find a way to view the name of the folder. For some reason while attempting the various tutorials, i tried to cd into the folder using a variable substitution.

cd $'\302\240'

Further looking things up on this webpage. i found out that this will expand single/multi escape octal characters into its relevant ascii/unicode character. Using the same concept you can make and remove the directory if you'd like.

  • 2
    It looks like a space. Try cd " ". – user448115 Sep 30 '15 at 19:17
  • 1
    Try the -b, -N, -q or -Q flags of ls. Maybe they show some normally invisible characters. – Byte Commander Sep 30 '15 at 19:17
  • If it's a space then cd ./\ / might work too. – Wolfer Sep 30 '15 at 19:55
2

You can't have a file with an empty name. However, the name could be something you can't see. Like a space, a non-breaking space, a tab, a horizontal tab, or even a character which isn't even printable like a end of message character or an escape character.

To show this, I've just created a folder having a blank as its name and anther one having a non-braking space as its name.

$ ls -l
total 8
drwxrwxr-x 2 christoph christoph 4096 Sep 30 22:02  
drwxrwxr-x 2 christoph christoph 4096 Sep 30 22:02  

As you can see, there is no obvious way of seeing which one is which (though the non-breaking space really is displayed (in your browser: just copy one of the lines, press ctrl + F to search for it, and only 1 result will be shown) but ls -l doesn't display all characters, so it's possible to make different folders with actually the same output line of ls -l).

If you're using any version of Ubuntu but 15.04, first execute this command:

sudo apt-get install nautilus-open-terminal

This will give you the entry Open in Terminal in the context menu of Nautilus. If it doesn't Nautilus has to be restarted, so simply log out and log in again. Ubuntu 15.04 already comes with this entry, so you don't need to install nautilus-open-terminal or you'll have the entry twice.

Then you can use the opened terminal window to do whatever you want to do at this location.

Edit: I assumed you wanted to open the location in a terminal. If you want to browse it and only have a terminal available, you can use a terminal file browser like Ranger. Here is a page showing you how to install and use it.

  • 1
    The question specifically states terminal so this isn't really an answer. – Wolfer Sep 30 '15 at 19:54
2

The easy way is to just copy all your files without moving into the folder:

find /media -mindepth 2 -not -path '/media/System*' -exec cp -rt /new/dir {} +

Let's break that down:

  • find /media : searc in the directory /media
  • -mindepth 2 : only look for files or directories that are in a subdirectory of /media. This will ensure you skip things in /media itself.
  • -not -path '/media/System*' : exclude any files or directories whose path matches /media/System*. This will make find ignore anything in the /media/System Volume Information directory.
  • -exec cp -rt /new/dir {} : copy anything found to /new/dir.

That's it, your files have been copied and you don't need to cd into the weird name.


Just for fun, to actually cd into this, you can try a few things:

  • Use the -F option of ls, to annotate the type of item listed.That will add a / after each directory name:

    $ ls -lF media/
    total 8
    drwxr-xr-x 3 root root 4096 Oct  1 02:09  /
    drwxr-xr-x 2 root root 4096 Oct  1 02:09 System Volume Information/
    

    Now, copy the characters you can't see, making sure you leave one space after the time, the rest will be your directory's name. Then, just paste that into the terminal, inside quotes:

    cd /media/" "/
               ^----- this is the pasted character.
    
  • Assuming the directory's name is a space, you can do:

    cd /media/" "
    
  • If the name is another whitespace character(s), you can try matching it and cding that way:

    for d in media/*; do [[ "$d" =~ /[[:blank:]]  ]] && cd "$d"; done  
    
  • 1
    a little more research into it shows that the non-printing character is octal character 302 240. this was done by "ls -l | od -c" showing the octal character occupying the space. link states that "The character-pair \302\240 is the "NO-BREAK SPACE" from UTF-8 encoding.". Only issue now is you cannot rename files via terminal and you can't enter octal characters when copying the file or can you? – seelani Oct 1 '15 at 11:41
  • @seelani please edit your question to provide this interesting additional information. Otherwise it might become lost or is not well seen. thanks. – Byte Commander Oct 5 '15 at 8:21
  • @seelani sure. Just copy/paste it as I suggested. The character you describe is just a simple space though, so all you need is mv " " newname. – terdon Oct 5 '15 at 13:41
  • @terdon , this does not work. I get the error mv: cannot stat ' ': no such file or directory – seelani Oct 7 '15 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.