Linux Tricks and Techniques

For Linux Experts

Use the website for easy leaning of Linux

Tuesday, 14 November 2017

How to save output of commands in a file in Linux.

Linux allow us to save all the command outputs in a file while we are working on a Linux server. A command script is used to save these commands output in a file. It is good to use script command to save all necessary command output before stating any major activity. These commands can be any of the Linux command like df -h, fdisk -l, ifconfig -a etc. Here I am sharing on of the same script to save command outputs in a file named logs.txt.

In the above image a file named logs.txt is created using script command, which shows script started file is logs.txt. It means that all the work we will do on this terminal will get save in logs.txt file. To stop these outputs to be saved in logs.txt we need to exit from script as already shown in image. Once we exit from the script we can check all the saved outputs inlogs.txt using vi command.

#vi logs.txt will show the outputs of executed commands in logs.txt file as show below.

So this is how you can save commands output in a file using script command in Linux.

Visit for more articles.


No comments:
Write comments