cat ~/.bash_history | grep java view linux history command

Keywords: Java Linux bash

Query the recently executed Java command cat ~/.bash_history | grep java

7. history command

The history command is used to display the commands executed in history. The format is "history [-c]".

The history command should be the author's favorite command. Executing the history command can display the last 1000 command records executed by the current user in the local computer. If you think 1000 is not enough, you can also customize the HISTSIZE variable value in the / etc/profile file. When using the history command, if you use the - c parameter, all command history will be cleared. You can also use "! Encoded number" to repeat a command. In short, the history command has many interesting ways to play, waiting for you to develop.

[root@linuxprobe ~]# history
1 tar xzvf VMwareTools-9.9.0-2304977.tar.gz
2 cd vmware-tools-distrib/
3 ls
4 ./vmware-install.pl -d
5 reboot
6 df -h
7 cd /run/media/
8 ls
9 cd root/
10 ls
11 cd VMware\ Tools/
12 ls
13 cp VMwareTools-9.9.0-2304977.tar.gz /home
14 cd /home
15 ls
16 tar xzvf VMwareTools-9.9.0-2304977.tar.gz
17 cd vmware-tools-distrib/
18 ls
19 ./vmware-install.pl -d
20 reboot
21 history
[root@linuxprobe ~]# !15
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates
Desktop          Downloads  Music                 Public    Videos

Historical commands are saved to. Bash in the user's home directory_ In the history file. Files starting with dot (.) in Linux system represent hidden files. Most of these files are system service files. You can view their contents with cat command.

[root@linuxprobe ~]# cat ~/.bash_history

To clear the Linux command history information executed by the current user on the machine, execute the following command:

[root@linuxprobe ~]# history -c

8. sosreport command

The sosreport command is used to collect system configuration and architecture information and output diagnostic documents in the format of sosreport.

When the Linux system fails and needs to contact the technical support personnel, most of the time, use this command to simply collect the system operation status and service configuration information, so that the technical support personnel can solve some small problems remotely or solve some complex problems in advance. In the following output information, the bold part is the collected data compressed file and check code, which can be sent to the technical support personnel:

[root@linuxprobe ~]# sosreport
sosreport (version 3.0)
This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.

An archive containing the collected information will be generated in
/var/tmp and may be provided to a Red Hat support representative.
Any information provided to Red Hat will be treated in accordance with
the published support policies at:

https://access.redhat.com/support/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.

Press ENTER to continue, or CTRL-C to quit

Please enter your first initial and last name [linuxprobe.com]: click enter here to confirm the host number
Please enter the case number that you are generating this report for:
Running plugins. Please wait ...
Running 70/70: yum...
Creating compressed archive...
Your sosreport has been generated and saved in:

/var/tmp/sosreport-linuxprobe.com-20170905230631.tar.xz
The checksum is: 79436cdf791327040efde48c452c6322
Please send this file to your support representative.

Posted by Darrel on Wed, 10 Nov 2021 03:17:03 -0800