Hongmu Notes
Home Summary of pitfalls Clear Linux command-line history
Summary of pitfalls

Clear Linux command-line history

Clear Linux command-line history

In Linux systems, the history of command-line commands is typically stored in the user's home directory..bash_historyIn the document. You can clear your history using the following methods:

Manual deletion. bash_history file:

Open the terminal and use it.cdUse the `cd` command to navigate to your home directory (for example, if your username is "username", then your home directory is /home/username)./home/username), then use it.rmCommand to delete the bash_history file:

cd /home/username
rm .bash_history

Note: This method is only applicable to the current user; if you are using a different shell (e.g., sh, zsh, etc.), you may need to delete the corresponding shell history file, such as.sh_history.zsh_history

Use the `history` command to clear the history:

Enter the following command in the terminal:

history -c

This command clears all history from the current session. If you wish to save the history to a file, you can use the following command:

history > history.txt

This will export the historical records to a file named "history.txt".

Edit the bashrc file:

You can add the following line to your `bashrc` file to disable history saving:

unset HISTFILE
set history=0

This way, even if you enter a command, it will not be saved to the `bash_history` file. When you need to reuse this history again, you can temporarily set the `HISTFILE` variable:

export HISTFILE=/dev/null

This will save your history to a dedicated location, where you can view and edit it at any time. When you no longer need to save your history, simply set HISTFILE to an empty string.

 
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

(PC + WAP) Metal Cutting Equipment Website Template – Download Blue Machinery and Equipment Website Source Code – 0124

(PC + WAP) Metal Cutting Equipment Website Template – Download Blue Machinery and Equipment Website Source Code – 0124 Practical Collection pbootcms Template

A blue PbootCMS website template designed specifically for the metal cutting equipment and machinery industry, compatible with both PC and mobile devices. Its rugged, industrial design is ideal for showcasing products such as laser cutting machines and plasma cutting machines. This template helps metal processing equipment manufacturers build their online brand presence and expand their customer base within the manufacturing sector. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password:...
👁 57
Smart Electronic Door Lock Website Template 0917

Smart Electronic Door Lock Website Template 0917 Practical Collection Yiyou template

An EyouCMS website template designed for the smart electronic door lock industry. Its modern and secure design is ideal for showcasing smart door lock products, security technologies, application scenarios, and brand identity. This template helps smart lock manufacturers showcase their products online and attract both residential and commercial customers. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | Eyou...
👁 52
(Adaptive mobile version) Responsive mechanical components and equipment company website – PBootCMS template; Download source code for hardware and metal machinery equipment websites – 0768

(Adaptive mobile version) Responsive mechanical components and equipment company website – PBootCMS template; Download source code for hardware and metal machinery equipment websites – 0768 Practical Collection pbootcms Template

A responsive PbootCMS website template designed for a mechanical components and hardware machinery company, compatible with both PC and WAP devices. Its professional and precise design is ideal for showcasing mechanical parts, machining services, and industrial products. This template helps component manufacturers showcase their expertise online and attract industrial customers. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5...
👁 42
PHP database connection and SQL file import.

PHP database connection and SQL file import. Language Notes PHP

To connect to a database and import an SQL file in PHP, you can use the MySQLi extension. Here is a simple example of code that demonstrates how to connect to a database and execute an SQL file: // Configure database connection information $host = "localhost"; // Database host name $user = "username"; // Database user...
👁 154
Responsive international logistics freight company website template 0245

Responsive international logistics freight company website template 0245 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for international logistics and freight forwarding companies. Its efficient, modern design effectively showcases logistics services, freight routes, customs clearance services, and corporate strength, helping international logistics firms attract cross-border trade clients online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 45
(PC + WAP) Steel Structure Outpost – Marketing-oriented PbootCMS Website Template; Red Outdoor Outpost Website Source Code Download – 0125

(PC + WAP) Steel Structure Outpost – Marketing-oriented PbootCMS Website Template; Red Outdoor Outpost Website Source Code Download – 0125 Practical Collection pbootcms Template

This PbootCMS template features a vibrant red marketing style and is specifically designed for manufacturers of steel and outdoor guard亭 (outdoor security booths), supporting both PC and WAP devices. The page design focuses on product showcasing and brand identity, making it ideal for attracting clients such as municipal authorities and property management companies. It enables guard亭 manufacturers to efficiently present their products online and secure construction projects. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin
👁 34