LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 07-04-2012, 04:11 AM   #1
Cinnamint
LQ Newbie
 
Registered: Feb 2012
Posts: 27

Rep: Reputation: Disabled
Stored terminal commands?


When using terminal, you can use up and down arrow keys to scroll through previous commands entered as the user. What file is this list stored in if I wished to print it?
 
Old 07-04-2012, 04:17 AM   #2
Genocide_Hoax
Member
 
Registered: Apr 2011
Distribution: OpenSuse 12.3 , Slackware 13.1 ; Centos 6.2 ; Fedora 14
Posts: 90

Rep: Reputation: 8
use the command history to print them. And they are stored in the following location /<username>/.bash_history. So for the root user it'll be /root/.bash_history
 
1 members found this post helpful.
Old 07-04-2012, 04:22 AM   #3
okcomputer44
Member
 
Registered: Jun 2008
Location: /home/laz
Distribution: CentOS/Debian
Posts: 241

Rep: Reputation: 51
Hi,

It stored at /home/"username"/.bash_history

But this file is hidden, so you need to issue
Quote:
ls -al
to see it in your home directory.
And you can list it with the
Quote:
history
command too.

If you want to use any command again which previously used, you could use the !"number here" to rerun the command again.
e.g.:
Quote:
!25
will run the 25 command from the bash history.

Laz
 
Old 07-04-2012, 07:40 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,564

Rep: Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658
Note, though, that the shell (well, bash at least) updates that file only when the shell exits. As long as the shell is running, it just updates its internal copy of the command history.
 
Old 07-04-2012, 08:00 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Incidentally, extending post#3, you can also use
Code:
!tail
to re-run the last cmd beginning with that string
 
1 members found this post helpful.
Old 07-05-2012, 01:03 AM   #6
okcomputer44
Member
 
Registered: Jun 2008
Location: /home/laz
Distribution: CentOS/Debian
Posts: 241

Rep: Reputation: 51
Quote:
Originally Posted by chrism01 View Post
Incidentally, extending post#3, you can also use
Code:
!tail
to re-run the last cmd beginning with that string
Nice one!
I didn't know this one.
 
Old 07-06-2012, 03:07 AM   #7
Cinnamint
LQ Newbie
 
Registered: Feb 2012
Posts: 27

Original Poster
Rep: Reputation: Disabled
ha, of course, .bash_history, it's been way too long since I worked with the shell
Thanks for the other tips too.
 
  


Reply


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
Where are my commands stored? ifeatu Linux - Newbie 9 10-06-2008 12:08 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 07:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 07:53 AM
commands stored into variables? benne Programming 2 11-15-2004 08:20 PM
Editing stored Terminal commands ShaanAli Linux - Software 2 01-13-2004 08:55 AM


All times are GMT -5. The time now is 11:28 AM.

Main Menu
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