LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
Member
 
Registered: Feb 2012
Posts: 32

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: 246

Rep: Reputation: 53
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: Rocky Linux
Posts: 4,803

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,418

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
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: 246

Rep: Reputation: 53
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
Member
 
Registered: Feb 2012
Posts: 32

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:57 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
Open Source Consulting | Domain Registration