How to Encode and Decode Using base64 in Linux

Base64 is a binary-to-text encoding that converts binary data into a sequence of printable characters but limited to a set of 64 unique characters. In this tutorial we will see how to encode and decode string and file content using base64 command.

Encode String Using the base64 Command:

Open the terminal app (ctrl+alt+t) and run below command.

base64 <<< 'CONNECTwww.com'

base64

Alternatively you can also use below command.

echo 'CONNECTwww.com' | base64

base64 encode

but the results are same.

Decode String Using the base64 Command:

Open the terminal app (ctrl+alt+t) and run below command to decode the string.

base64 -d <<< Q09OTkVDVHd3dy5jb20K

base64 decode

[OR]

echo 'Q09OTkVDVHd3dy5jb20K' | base64 -d

base64 decode string

Encode File Using the base64 Command:

If you want to encode file.txt text file from your Home directory, then run below command.

base64 file.txt

base64 file encode

Decode File Using the base64 Command:

If you want to decode, the above content then run below command.

base64 -d <<< Q09OTkVDVHd3dy5jb20KQnkKTWFuaWthbmRhbgo=

base64 file decode

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Also Read:  How to Enable Night Light in Ubuntu

Leave a Reply