Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
Have you ever used a command in the Terminal, but then later forgot what you typed, and wished there was some way that you could view the last used commands?
There are many ways to search through your command history. Here are 3:
use the up and down arrows on your keyboard when at the command prompt.
use the history command.
Simply press : Control + R when at the command prompt.
E.g : Control + R , then write php
I often use bash-builtin command "history" to search for a certain command, e.g. to get the last sudo command type:
history | grep sudo | tail -n 1
gives the last command (with number) with sudo in it. "tail -n 1" gives the last matched line. Then use
!<number>
to execute exactely this command.
!-1
executes the last command, by the way. works well in bash.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am following a book on Linux. One of the first commands is to execute who am i. It should return my username. However, it returns an empty prompt.
What am I missing?
I am using Fedora 25.
When you write:
who am i
You're actually passing two parameters ("am" and "i") to the who command:
:~$ who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
You want to do (without the spaces; it's a different function):
whoami
to get what you want.
When you execute the command from a terminal in Gnome, it does not return information. However, it does show results you if execute it in a tty terminal.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
In Linux when I type "CTRL+C" to cancel the current line and move to the next, I get the following symbol "^C" below showing that I have cancelled the previous command as shown below:
sqldba#SQL-linux-001:/etc# ^C
sqldba#SQL-linux-001:/etc#
I would like to remove the "^C" symbol from showing when I cancel from my previous command and show it as below without the "^C" symbol. Basically the same as when you press enter on an empty line, it will show the below. I would like the same as when "CTRL+C" is used
sqldba#SQL-linux-001:/etc#
sqldba#SQL-linux-001:/etc#
I am unsure of the file to edit to make this change, whether it can be done in the .bashrc profile or the .bash_profile
Thanks.
pipe it through a stream editor. Try this:
echo $PATH | sed 's/^C//g'
Not entirely sure this is what you want, so please clarify. What this will do is remove all instances of ^C from your PATH system variable.
If this is not what you want, take a look at https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path as well as man sed
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am just getting started with Linux, could someone please explain these commands? (ls), (ls -l), (whoami), (pwd), (cal 2013) and (man cal). Thanks.
The only command you have to know, is "man". Type "man ls", and you'll get an answer about what "ls" does, and so on.
man is the very first command a Unix/Linux beginner needs to know. It means manual and gives access to the reference manual (or online help) of the command specified on the same line:
man cal
displays the manual of the cal command.
From there, you can type
man intro
to get a list with a short summary of all available commands.
Sometimes, instead of the manual of the command you requested, you'll get the manual of bash, which is the program that interprets all the commands you type. This means that your requested command is not a simple command like cal but a special command directly implemented in the bash itself. In that case, the description of your requested command is buried in the huge manual of bash.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Your system has 2 versions of the same utility installed, both which have the same filename.
How would you find out where the utility you would run by default is located?
If the utility's file name is "foo", type which foo
You'are looking for which command
which - shows the full path of (shell) commands.
Let's say you have perl installed in /usr/bin/perl and /usr/local/bin/perl and if the default path is the second one then
$ which perl
/usr/bin/local/perl
Check the $PATH.
echo $PATH
The first is started default.
or
which
Similar to which , whence gives you whence command from Korn Shell tells how a name would be interpreted by the shell: it detects commands and aliases, and searches your path.
whence {executable-you-are-looking-for}
and also in linux, just typing name & hitting tab will show list of available versions with which you can run.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am relatively new to linux environment. My doubt is this:
I run a lot of commands of various types , so when ever i want to rerun a old one i have to look through the entire history. is there any bash command that displays just the commands that begin with a particular combination of characters( my case here is i just want a list of all the ./ eg: ./ifv_script , ./run_regression i've run from the terminal)
Three methods:
You can grep your current history, e.g.:
$ history | grep ifv
You can also recall commands from the history by typing ControlR and then type a few characters from the command.
Finally you can grep your saved history file for older invocations from previous sessions, e.g.:
$ grep ifv ~/.bash_history
Just press Ctrl+R, and you will enter into reverse-i-search mode.
Now you can type a few characters that appear anywhere in the command and bash will start finding matches.
Final approach (bash only):
history | grep term