Solved

send top command output to  a text file ?

Posted on 2013-06-10
2
382 Views
Last Modified: 2013-06-10
Hello, I am using an Ubuntu 12.04 Linux system and am trying to capture the output of the top command using the following command:

 sudo top -n 1 -b > top-output.txt

when I run this command I get the following error, can someone let me know what I need to do to avoid this error and be able to capture the output as a text file?

-bash: top-output.txt: Permission denied
 

Thank you,
A
0
Comment
Question by:aej1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 39233948
sudo will run top with root privs, but any file redirection will occur as the userid invoking the command.

Unless sudo has suid disabled, then there's no need to use sudo.

Just redirect the output to a directory you have write permission for, eg:

top -n 1 -b >/tmp/top-output.txt
0
 

Author Comment

by:aej1973
ID: 39234005
Thank you, it works.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question