LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rename a file with hexa decimal characters (https://www.linuxquestions.org/questions/linux-software-2/rename-a-file-with-hexa-decimal-characters-606362/)

sandeshsk007 12-12-2007 03:09 PM

Rename a file with hexa decimal characters
 
Hi all,

I am trying to rename a file with hexadecimal characters(not the regular ASCII characters)
so that i can hide my files from other users.Could you please help me out in this regard.

Thanks

matthewg42 12-12-2007 03:15 PM

What do you mean?

forrestt 12-12-2007 04:17 PM

That won't hide your files from other users.

Forrest

sandeshsk007 12-12-2007 04:24 PM

ok ...how would i rename my file such that it is not displayed in the ls all option ? What should be done in order that the file name is not displayed when i use ls to list the file with the all option .

Thanks

unSpawn 12-12-2007 04:42 PM

Can't you just rename the file to something innocuous and use simple encryption (like 'openssl enc -e -bf -in inputfile -out outputfile') instead of trying to dodge 'ls'?

sandeshsk007 12-12-2007 04:47 PM

I want a simple rename and very simple thing of to not display the filename when used with ls.

forrestt 12-12-2007 04:49 PM

ls -a, list all, does just that, it lists ALL files. Unless you can figure out how to have a file that isn't a file, you aren't going to be able to do it. You can encrypt the file so only you can open it, but you can't make it so it isn't able to be seen with ls. You can rename it to " " but even that will show up in ls.

Code:

/home/forrest% touch \ <-- there is a space here
/home/forrest% ls -la
total 32
-rw-r--r--  1 forrest  forrest        0 Dec 12 17:39  <-- there is a file called " "
drwxr-xr-x  6 forrest  forrest      512 Dec 12 17:39 ./
drwxr-xr-x  11 root    root        512 Feb  1  2007 ../
-rw-------  1 forrest  forrest      156 Dec 11 10:33 .Xauthority

/home/forrest% rm \ <-- there is a space here

Your best bet is to get a USB key and keep your file on it in an encrypted form. Then it will only be on the system when you have it plugged in, and only you can read it.

I'm not sure I want to know why you want to do this.

HTH

Forrest

unSpawn 12-12-2007 05:31 PM

Quote:

Originally Posted by forrestt (Post 2988731)
you can't make it so it isn't able to be seen with ls.

Other than dots, spaces, encryption or stego, yes you can, it's just that the effort is disproportionate and suggesting it means breaking the LQ Rules.

matthewg42 12-12-2007 05:45 PM

When you remove a file using the rm command (or directly using the unlink system call), Linux decrements the link counter for that file. When the link counter reaches 0 the file is actually deleted from the disk, but not until then.

When you create a hard link to file, the counter is incremented, so if the file is deleted using the original path, the counter gets decremented but because there is still a link to the file from the new location, it is not removed from the disk.

When a program opens a file, the link count is also incremented until either the program terminates or the file is closed in the program.

You could "hide" a file by opening it in a program, unlinking it from the directory, but keep the program running with the file open.

One could conceive of a mechanism by which a daemon process holds a file open in this manner, and will provide the data to programs via some IPC interface - perhaps using shared memory or sockets.

The snag is that if the program terminates (e.g. it crashes or the system is rebooted), the file will be lost, and of course you can't the use regular disk IO mechanisms on the file.

rsashok 12-12-2007 05:51 PM

Create a directory with your private access attributes, and move all your personal files there. Other users, besides root, won't be able to 'ls' on this directory, they would get: /home/your_name/my_private: Permission denied

forrestt 12-12-2007 05:59 PM

unSpawn, I'll take your word for it. It's not something that I would think possible with standard commands (and I would hope if it is it would be considered a bug and fixed).

So, as far as I'm concerned my advice stands, "you can't make it so it isn't able to be seen with ls." You may however be able to break your file system and get it to not be seen, but I wouldn't advise that.

Also, I'm assuming this is a non-root user, otherwise, just make an unmounted filesystem.

Forrest

matthewg42 12-12-2007 06:27 PM

Quote:

Originally Posted by unSpawn (Post 2988765)
Other than dots, spaces, encryption or stego, yes you can, it's just that the effort is disproportionate and suggesting it means breaking the LQ Rules.

I'm assuming you're referring to some sort of kernel hack? I don't believe this is possible with only user space tools.

chrism01 12-12-2007 07:01 PM

If you set your home dir and other dirs and all files to rw only for owner (and x where reqd) and group and other perms to none (---) then only you can see them eg
rwx------ executable files only
or
rw------- non-exes

eg
chmod -R u=rw,go= *

chmod u=rwx,go= *.sh
and others eg .pl, binaries

unSpawn 12-13-2007 02:11 AM

Yes, you're both right: kernel or binary subversion.


All times are GMT -5. The time now is 06:51 PM.