Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-08-2008, 03:07 PM   #1
Registered: Jun 2001
Location: 28N,82W
Distribution: XP,Ubuntu 9
Posts: 472

Rep: Reputation: 30
Terminal : How to list previous commands?


In a Terminal : How to list previous commands? More importantly, is it possible to put them in a file?
Old 03-08-2008, 03:21 PM   #2
Senior Member
Registered: Dec 2005
Distribution: Slackware -current, 14.2
Posts: 1,086

Rep: Reputation: 195Reputation: 195
to view previous commands:

$ history

to create a file:

$ history >> filename

edit: of course, it already exists in a file - .bash_history


Last edited by mrclisdue; 03-08-2008 at 03:23 PM.
Old 03-08-2008, 03:23 PM   #3
Registered: Jun 2007
Posts: 54

Rep: Reputation: 15
it is simple..
type "history" to list the previous commands..
history > output
typing that in the terminal will save the output to a file
also the script command is a useful one to record the terminal activities

type script in the terminal the moment from which you want the activities recorde.then when you are done just type exit.and you will find a file named typesdript in the home directory..that will do
Old 03-08-2008, 04:05 PM   #4
LQ Guru
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,311

Rep: Reputation: Disabled
To re-use previous commands type a few letters from beginning and tap Page-Up. Depending how long is your history - usually 1000 lines - it makes life real easy.
Old 03-08-2008, 04:41 PM   #5
Registered: Jun 2001
Location: 28N,82W
Distribution: XP,Ubuntu 9
Posts: 472

Original Poster
Rep: Reputation: 30
Thanks folks. It works.
Old 07-12-2011, 08:21 AM   #6
LQ Newbie
Registered: Mar 2010
Posts: 9

Rep: Reputation: 0
Re: previous commands

Hi friends,

A am using RHEL5.4 and in my server I logined as a root user and i have done some tasks like creating files,
directories deleting directories and before logout as root i entered a command "history -c".
Then what is the procedure to view also those previous commands.

I used a command "lastcomm", but it is not ginving the complete information.
Friends is there any command to view my previous commands
Old 07-12-2011, 09:00 AM   #7
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Apart from reading the dead thread you just resurrected, you could also check the man page, because there's no such argument for the history command.

man history


history, terminal

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
In Solaris(command Line ), How to get the previous commands? kcarun Solaris / OpenSolaris 22 10-19-2012 03:49 AM
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 10:34 AM
Clear previous commands in Terminal Hitboxx Fedora 4 07-12-2006 07:20 AM
going through previous bash commands corrupts console text? juanbobo Linux - Software 1 08-30-2005 10:24 AM
Can ash recall previous commands? Scerj Linux - General 0 06-06-2001 02:18 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:55 AM.

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