Mar 26 2009

History Linux Command Overview/Tutorial. Only The Useful.

Linux / Unix Command: history

Linux Command Description
This command displays a list of the most recently executed commands on Linux and Unix workstations and servers.

For the impatient here is the proper syntax:

history [n]
history -c
history -d offset
history [-anrw] [filename]
history -ps arg

Here are the only real useful options for this very useful linux command.

-c will clear the history list.

history -c

will remove all entries in your history list.

-d will delete the command at the specified offset.

history -d 24

will remove the 24th entry. Each line is labeled so it’s easy to clean up after yourself if you don’t want your boss to easily find your blunder.

There are other arguments available but I’ve never had a use for them and you can always use the man pages to check up on them if you need to.

Sometimes the history file removes some entries in order to keep the list from taking to much space. This can be unpleasant when you’re looking for some nix command that you know you’ve executed but can’t remember the exact syntax of. To increase the size of the list you will need to edit your bash_profile in your home directory (That is, assuming you are using bash like most sane linux users). This can be done very easily :

Add these two lines to your .bash_profile. This will not take effect until your next login.

vi ~/.bash_profile


Mar 19 2009

reset auto increment integer in mysql

Because I use auto-increment integers in almost every table I can for the primary key, they tend to get very large very fast. This can sometimes be an annoying problem when I’m debugging an application or testing a mysql database query. They are resetable and it’s so much quicker to select from the database when you’re checking for id=3 or id=25 then id=305678.

The query to reset the auto increment primary id of your choosing is :


It is also possible to set the next auto_increment number
You can do it like this :

SET insert_id=5;

Now your next mysql_insert_id() will be 5.