LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 05-19-2011, 03:03 PM   #1
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
How to record a command line session to a file?


I recently borked my video driver with a series of upgrades and found my system booting to the TTY with no access to the desktop, graphical login, or even X. I spent some days troubleshooting the problem and experimenting with possible fixes. I found myself wishing for some way to copy and paste from the TTY, or at least log all input and output to a file.

I have considered that something like this might lead to a solution:

Code:
# bash 2>&1 | tee /tty-session.log
I'm not sure it would work as expected, and it doesn't seem very graceful.

Does anyone have nice solution?
 
Old 05-19-2011, 03:07 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

Hi there,

Check out the following links:

http://www.cyberciti.biz/faq/list-co...n-linuxserver/

http://www.cyberciti.biz/tips/howto-...ccounting.html
 
Old 05-19-2011, 05:45 PM   #3
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Original Poster
Rep: Reputation: 147Reputation: 147
psacct seems a little heavy. I'm not after forensic analysis and accounting.

Suppose in a command line only session (no desktop, no X, just me and TTY1 and bash) I did something like this:

Code:
grep -i 'nouveau' /var/log/Xorg.0.log
The command produced a few interesting lines of output, but then I made some configuration changes and rebooted to try something else. Afterward I realize that it would have been nice to refer back to some of those lines as they were before the configuration changes.

Code:
sudo find / -name 'nvidia*' -print -delete
The name of each file is printed, and then it is deleted without prompting. After the process completes I realize that 50 or more filenames scrolled off screen and I can't scroll back to read the names of them all.

In Konsole I have tons of scrollback and I can easily copy and paste with my mouse. Not so with the TTY without X.
 
Old 05-19-2011, 06:24 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

Then you can use script command to capture the activities going on, on your terminal. For more info check out this link: https://knowledgecenter.citrix.com/article/CTX116378
 
1 members found this post helpful.
Old 05-19-2011, 07:07 PM   #5
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Original Poster
Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by T3RM1NVT0R View Post
Then you can use script command to capture the activities going on
http://manpages.ubuntu.com/manpages/.../script.1.html
http://manpages.ubuntu.com/manpages/...treplay.1.html

Hmm ... this is actually quite nice

Code:
foo$ ls
input-file.txt  timingfile  typescript
foo$ script -t 2> timingfile
Script started, file is typescript
foo$ rm input-file.txt
foo$ exit
Script done, file is typescript
foo$ ls
timingfile  typescript
foo$ scriptreplay timingfile
foo$ rm input-file.txt
foo$ exit
foo$
What about copy and paste without X? Does such a thing exist?

Last edited by Telengard; 05-19-2011 at 07:14 PM.
 
Old 05-19-2011, 07:18 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

When you say copy and paste I am assuming that you want to copy a particular file or directory or directory with subdirectory to a particular location. If that is the case then you can go with the following commands:

cp -arvp /root/test /tmp

The above command will work on both when test is a file or when test is a directory, this will copy over test file or directory from /root to /tmp. Good thing about using all these switches (-arvp) is that it will copy over hidden files as well.

Where,

a=all (including hidden)
r=recursive
v=verbose
p=preserve permissions

Edit: I just realized that you might be pointing to copying and pasting commands as we can do in X console. Well that will not be possible when you are working on CLI without X.

Last edited by T3RM1NVT0R; 05-19-2011 at 07:32 PM.
 
  


Reply

Tags
command line, cut and paste, log, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] command line to open a second telnet session Lucard Linux - Newbie 5 03-18-2010 09:39 PM
awk command line: blank line record sep, new line field sep robertmarkbram Programming 4 02-21-2010 06:25 AM
record dvb streams (with subtitles !!) from the command line henning Linux - Software 5 03-08-2009 10:23 AM
editing a file in command line during ssh session...need advise! reddog1 Suse/Novell 8 05-31-2006 10:09 PM
logout of X session from a command line interface? pwc101 Linux - Software 10 05-02-2006 01:01 PM


All times are GMT -5. The time now is 12:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration