TalkitUp - A Debian Forum at debiantutorials.org
*
Home
Help
Search
Calendar
Login
Register
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 12, 2008, 10:58:11 AM

Login with username, password and session length
This forum exists to discuss the tutorials at debiantutorials.org.   It is primarily for new users to Debian and can assist your Windows to Linux migration.  Everyone is welcome.
Search:     Advanced search
2951 Posts in 689 Topics by 105 Members Latest Member: - haisong17 Most online today: 4 - most online ever: 61 (March 06, 2008, 12:51:36 AM)
Linux Incompatibility List
Linux Commands
Securing Debian
Debian Support
Old, Still Relevant
More Linux Commands
Trecherous Computing
DRM Dissertation
Installation
Switch Mom to Linux
A pal's Debian based distro forum
Debian GNU/Linux
Compressed Files
More Compression
Prompt Lovliness
File Management
Basic Admin
Really Useful Stuff
Harden your Rig
Multimedia on Etch
Wireless, Broadcom
Linux Forums - Debian
Etch Release Notes
10 good Unix Habits
More Commands
Securing Debian
Computer Security Software
Locked - Skinny Elephants
Effective Linux
HTML Reference
Wireless, Atheros
An old, great thread
Linux Questions - Debian

Pages: [1]
Send this topic | Print
Author Topic: In bash, lock up your .bash_history file - prevent changes  (Read 249 times)
0 Members and 1 Guest are viewing this topic.
machiner
The sun is out!
Administrator
member

Offline

Posts: 1255


red headed step-child


« on: January 10, 2008, 12:50:43 PM »

In Linux you have about 45 ways to do about anything.  We all have our favorites and this proves to be excellent geek-campfire fodder.  Some ultra-mega with his 12-string Martin will undoubtedly belt out an impromptu ode-to-bash ditty.  Someone spills a beer from his roiling with laughter...the wind forces a choke-cloud of smoke and heat right at you.  You casually move around the fire, stopping next to the ultra-mega guy long enough to bop to his beat for a few bars....."Hey Lenny, where's your sister?"  **ssssssmack**

ba hahahahaaaa lol......

good times.



Oh -- yeah, to prevent bash from adding your commands to the .bash_history file, (which can be really handy - or a detriment to security -  It's all in how you look at it.) there are a few things that you can do.  One surefire way is to dissllow all access, even from root.  We change the file attributes allowing no access by making the file immutable - an immutable object is an object whose state cannot be modified after it is created

Wicked easy, but like anything -- maybe you should understand it a little before you go poking your clumsy nose around in it, ey?

chattr -- look up file attributes, immutable, advanced file system operations -- put a +debian or +linux in your search phrase, as well.

Here's what we do.  FIrst - fire up your terminal and become root.  Then:

# rm .bash_history

Now, make a new one:

# touch .bash_history

Now, make it immutable if you've got no saved list of handy commands (regular user, that's what we're tweaking right now) - or, if you do have a group of commands you use all the time, open the file you just made and paste your list in.  This is your only chance, because the next step creates an unchangeable file.

I'll wait....


OK -- you removed the original, made a new one, added your favorite commands if applicable, and now we make it permanent:

# chattr +i .bash_history

There ya go.  You'll have to type out all of your commands, of course, but there will be nothing saved, so a snoop cannot go poking around in your .bash_history and notice passwords that you carelessly typed into your console.

Logged

"My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fibre, and that I am therefore excused from saving Universes" -- from the same place that told you the importance of a towel, and 42.
Tags: bash chattr immutable 
Pages: [1]
Send this topic | Print
TalkitUp - A Debian Forum at debiantutorials.org  |  Linux General  |  Linux Tips & Tricks (Moderator: machiner)  |  Topic: In bash, lock up your .bash_history file - prevent changes
Jump to:  

Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
This forum is owned by nobody and operated by debiantutorials.org.
All © belongs to individual posters
debtoots