• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
  • OS
    • HPUX
    • Linux
  • Commands & tools
    • Commands
    • Software & Tools
    • System services
  • Cloud computing
    • AWS CSA preparation guide!
    • Cloud Services
  • Tips & Tricks
  • Linux commands
You are here: Home / Howto

File encryption / password protect file in HPUX

Published: December 12, 2016 | Modified: June 20, 2020 | 753 views



Learn how to password protect files in HPUX. This is helpful to encrypt some public readable files using a password and decrypt them whenever needed.

It’s pretty obvious that you can control file access using permissions but sometimes you may want to protect file lying in a public directory like with password of your choice. Or sometimes you may want even root shouldn’t read your files šŸ˜‰

In that case, you can use crypt command to encrypt your file with a password of your choice. This command is available in HPUX, Solaris. I couldn’t found it in Linux though. crypt command is basically used to encrypt or decrypt files. So basically you will be encrypting your file with the key of your choice and whenever you want to read it back, you need to decrypt it by supplying password/key you chose at the time of encryption.

Locking / encrypting file with key

Let’s take a myfile.txt sample file for encryption. You need to supply this file as an input to crypt command and define the output file (see example below).

# cat myfile.txt
This is test file for crypt.

# crypt < myfile.txt > myfile.crypt
Enter key:

# cat myfile.crypt
3ā–’ā–’ā–’xā–’ā–’Xā–’nā–’dā–’6ā–’ā–’=ā–’ā–’qā–’j

Now, crypt command will ask you for a key. Its a password you can set of your choice. Note that, it won’t ask you to retype key. Once executed you can new output file created (with the name given in command). This file is encrypted and can’t be read using cat, more etc commands!

That’s it! your file in encrypted. Now you can safely delete your original file myfile.txt and keep an encrypted copy on the machine.

Unlocking / decrypting file with key

Now, to retrieve file content back i.e. decryption of file you can run the same command. Only input and output file names will be exchanging their positions. Now, the encrypted filename will be your input file and the original filename will be the output file name.

# rm myfile.txt
# crypt < myfile.crypt > myfile.txt
Enter key:
# ll myfile.txt
-rw-------   1 root       users           29 Dec 12 11:51 myfile.txt
# cat myfile.txt
This is test file for crypt.

crypt command checks input file and get to know its encrypted one. So it uses key supplied by user to decrypt it into output file specified in command. You get your file back as it was!

⇠ Previous article
How to configure NTP client in Linux
Next article ⇢
How to get directory size in Linux

Related stuff:

  • Hyperthreading in HPUX
  • Difference between hard link and soft link
  • How to restart inetd service in Linux
  • 12 useful zypper command examples
  • How to disable direct root login on Linux & HPUX
  • Command alias in Linux, Unix
  • How to get directory size in Linux
  • How to save top command output in file
  • How to run your script with system boot in HPUX
  • Password file commands
  • Move disks/LUN from one server to another without losing data
  • Adding extra or secondary swap in HPUX

Filed Under: Commands, Howto, HPUX Tagged With: crypt command, decrypt file in unix, encrypt file in unix, how to give password to file in unix, how to lock file in unix, password protect file in unix, secure file in hpux

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Popular posts

  • How to start, stop & restart MariaDB server in Linux
  • How to reset iptables to the default settings
  • 4 ways to check the size of physical memory (RAM) in Linux
  • How to rescan disk in Linux after extending VMware disk
  • How to remount filesystem in the read-write mode under Linux
  • How to list YUM repositories in RHEL / CentOS
  • mount.nfs: requested NFS version or transport protocol is not supported
  • How to setup domain name in Linux server
  • How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora)
  • MobaXterm X11 proxy: Authorisation not recognised

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2020 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.