how other user cannot read my script?

Hi All,

If I don't want other user read my script, what can i do? :confused:

Do you own it (I assume you do)?

chmod 700 /path/to/myscript

Of course, root can still read it.

Cheers
ZB

thank you...
also, can i hide the directory or file?

Use chmod command to remove the read permission (or all permissions, whatever appropriate) of files and directories for particular users/groups.
There is no seperate hide functionality in *NIX

Consider encrypting the files if you want them to be meaningless for other users.

Thank you all! :smiley:

user vi -x to create the file then you have to provide an encription key (password) to read it..

which version of vi is this? mine doesn't have it.

You can "hide" a file or directory in unix. Just add a "." at the begining of the file's name and users won't see it unless they do "ls -a" :slight_smile:

$ touch one two .three
$ ls
one two
$ ls -A
one two .three
$

But, if you don't want other users to list your files in some_dir, just "chmod o-x /some_dir"

Though, as it's been said before, if you do not want anybody be able to read your files, you should use ecryption...

Corona688, I think tbdo88 is using VIM in Linux, which has that option :slight_smile:
I my Linux box, VIM v7.0.17 has it.

Regards.

:slight_smile: thank you very much.

All version of vi. I have been using this feature for more than 15 years. Check your man page first on vi:

-x Encryption option. When used, vi simulates the X com-
mand of ex and prompts the user for a key. This key is
used to encrypt and decrypt text using the algorithm
of the crypt command. The X command makes an educated
guess to determine whether text read in is encrypted
or not. The temporary buffer file is encrypted also,
using a transformed version of the key typed in for
the -x option. If an empty encryption key is entered
(that is, if the return key is pressed right after the
prompt), the file will not be encrypted. This is a
good way to decrypt a file erroneously encrypted with
a mistyped encryption key, such as a backspace or undo
key.

Ok, It's fantastic the fact that your vi has had that option for at least 15 years. I swear I work with several AIX machines, less than 4 years old, and neither vi nor vi's man page says anything about "-x". Be sure that I always check man pages before posting, and I suppose that Corona688 does the same. NOT all versions of vi have "-x".

Regards.

Be carefull when you use "." to hide the file. "." has feature called self-autoexecution. It will automatically execute when you login. - Just FYI.

I've never actually seen this option myself, but it seems quite useful.

Just out of interest, when using it to create a script, how do you convert it to non-encrypted form for execution?

Thanks

What?
I think you are a little bit confused...
Perhaps you are talking about shell initialization files such as ".profile", ".bashrc", ".cshrc", etc...
The fact that a filename starts by "." has nothing to do with self-auto-execution...

And ... which is the best method to execute the encrypted script?

Thx.

un-encrypt it! :smiley:

umm ... is there any way to execute it encrypted? :rolleyes:

You don't have to un-encrypt the script - just execute it.

:eek: Test it, and see for yourself that's not true.
If you make an script with "vi -x", then you won't be able to run it unless you un-encryp it. I've tested it. If I'm wrong, show me.

Grial is correct, as far as the shell is concerned the file will be garbage binary content unless it is decrypted, and in order to prevent further inaccuracy or further slide into flaming I am closing the thread.