How To Save Linux Command Output To An Image Or A File
Ever been in a situation where you have to send the output of a Linux command to your colleague or friend to get help? This simple Linux hack will definitely be useful to you. You can save a Linux command output to an image or a file and send it to the respective person who wants to review the output of a particular Linux commands.Save Linux Command Output To An Image
Install ImageMagick tool first. In Ubuntu-like systems, you can install it a shown below.sudo apt-get install imagemagick
In Arch Linux and its derivatives, run:
sudo pacman -S imagemagick
Now, To save a output of any Linux command to an image, just run the following command:
ifconfig | convert label:@- myipaddress.png
The above command will save the ifconfig command output to an Image and save it in the current working directory. Let us bread down the above command and see what each option does.
- ifconfig will display the IP address of your Linux system.
- convert command will save the output to an Image.
- label:@- myipaddress.png will save the command output to an called myipaddress.png.
Here is another one. I saved my Linux Kernel output to an Image.
uname -a | convert label:@- mylinuxkernel.png
Sample output:
What we have seen above, we have saved the command’s output in an Image. Also, we can save the output on an existing Image file. To do this, run:
convert -font -misc-fixed-*-*-*-*-*-*-*-*-*-*-*-* -fill black -draw "text 270,260 \" `ip addr` \"" Linux.jpg myipaddress.jpg
This command will print the output of “ip addr” command to an image called Linux.jpg and saves it with a new name “myipaddress.jpg”.
Here is the output of the above command:
Pretty easy, isn’t? You can save the output of any command and send it to anyone who can help you to fix your system.
Save Linux Command Output To A File
We know how to save a command’s output to/into a image. We can save the output of a Linux command to a file too.For example, we can save the “ip addr” command’s output to a file called myipaddress.txt using command:
ip addr > myipaddress.txt
To verify it, view the text file using your favorite text viewers. Or, we can do using “cat” command like below.
cat myipaddress.txt
The following command will save my pacman.log to a file called mylogs.txt.
tail -f /var/log/pacman.log > mylogs.txt
And, we can easily save the IP details using command:
ifconfig > mynetworkdetails.txt
That’s it. Now you know how to save any command’s output to an Image or a file without having to use any additional tools. Hope this helps. If you find this guide useful
No comments:
Post a Comment