10 Linux commands you’ve Never Used

February 20, 2007

Nice blog entry detailing: pgrep, pstree, bc, split, nl, mkfifo, ldd, col, lsof, xmlwf

I also want to go on record that I HAVE used 5 of them.


Linux Quick Hacks Site

September 14, 2006

Check Linux Hardware Support

May 17, 2006

First run 'lspci -n' and paste it after you -
Go to http://kmuto.jp/debian/hcl/index.cgi


Bash Shell Shortcuts

May 17, 2006

Bash, which is the default shell in Linux contains a whole lot of key bindings which makes it really easy to use . The most commonly used shortcuts are listed below :

____________CTRL Key Bound_____________
Ctrl + a – Jump to the start of the line
Ctrl + b – Move back a char
Ctrl + c – Terminate the command
Ctrl + d – Delete from under the cursor
Ctrl + e – Jump to the end of the line
Ctrl + f – Move forward a char
Ctrl + k – Delete to EOL
Ctrl + l – Clear the screen
Ctrl + r – Search the history backwards
Ctrl + R – Search the history backwards with multi occurrence
Ctrl + u – Delete backward from cursor
Ctrl + xx – Move between EOL and current cursor position
Ctrl + x @ – Show possible hostname completions
Ctrl + z – Suspend/ Stop the command
____________ALT Key Bound___________
Alt + < – Move to the first line in the history
Alt + > – Move to the last line in the history
Alt + ? – Show current completion list
Alt + * – Insert all possible completions
Alt + / – Attempt to complete filename
Alt + . – Yank last argument to previous command
Alt + b – Move backward
Alt + c – Capitalize the word
Alt + d – Delete word
Alt + f – Move forward
Alt + l – Make word lowercase
Alt + n – Search the history forwards non-incremental
Alt + p – Search the history backwards non-incremental
Alt + r – Recall command
Alt + t – Move words around
Alt + u – Make word uppercase
Alt + back-space – Delete backward from cursor

—————-More Special Keybindings——————-

Here "2T" means Press TAB twice

$ 2T – All available commands(common)
$ (string)2T – All available commands starting with (string)
$ /2T – Entire directory structure including Hidden one
$ 2T – Only Sub Dirs inside including Hidden one
$ *2T – Only Sub Dirs inside without Hidden one
$ ~2T – All Present Users on system from "/etc/passwd"
$ $2T – All Sys variables
$ @2T – Entries from "/etc/hosts"
$ =2T – Output like ls or dir

[original link]

Also check out free book: Advanced BASH Scripting by Mendel Cooper 


Unix Cheat Sheet

May 15, 2006

Really good cheatsheet for unix and solaris commands:
http://www.rblweb.com/unix_commands.html 


cron Format (crontab)

April 14, 2006
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- day of week (0 - 6) (Sunday=0)
| | | ------- month (1 - 12)
| | --------- day of month (1 - 31)
| ----------- hour (0 - 23)
------------- min (0 - 59)

Show Solaris Configuration

April 10, 2006

Try these commands to get hardware info:

prtconf

vmstat

dmesg


Using Top Efficiently

March 30, 2006

Here is a link disussuing using TOP to create performance snapshots and other tips.


PERL for search and replace

March 16, 2006

You can use PERL as a stream editor to replace strings in one or more files in a directory like this:

perl -pi.orig -e ’s/bgcolor=#ffffff/bgcolor=#000000/i’ *.html

The above replaces the color white with black in all html files in this directory and saves the original files with .orig extension.


Keep local environment when logging to remote servers

March 15, 2006

Use the script movein.sh from O’Reilley.

#!/bin/sh

if [ -z "$1" ]; then
echo "Usage: `basename $0` hostname"
exit
fi

cd ~/.skel
tar zhcf - . | ssh $1 "tar zpvxf -"

Read link for more info...


Generate SSL Certificate

March 15, 2006

Need OpenSSL for this -

openssl genrsa 512/1024 www.mysite.com.key
openssl req -new -key www.mysite.com.key >  www.mysite.com.csr

Enter country, state, locality, org name, org unit, comon name, and email when asked. Note: Common Name is www.mysite.com.

openssl -req -x509 -key www.mysite.com.key -in www.mysite.com.csr www.mysite.com.crt


Apache Tweaks

March 15, 2006

Avoid truncated filenames in log by editing httpd.conf:
IndexOptions FancyIndexing NameWidth=*

Here is a handy Perl script to compress all Apache logs automatically called LogFlume.

Serve an additional site under same DocumentRoot:

Add new Virtual Host:

ServerName www.newsite.biz
ServerAdmin mike@newsite.biz
DocumentRoot /home/www/htdocs #same as other site
RewriteEngine On
RewriteRule ^/$ /home/www/htdocs/newsite/index.html
RewriteRule ^/index.html$ /home/www/htdocs/newsite/index.html


Apache Toolbox

March 15, 2006

When installing Apache, check out Apache Toolbox and this article/script.


Restore single MySQL table from large DB dump

March 15, 2006

Here’s how to restore one or more tables from a full database archive. It assumes you used mysqldump to save the database and stored it in a gz file. First create the file extract-table.pl:

#!/usr/bin/perl -wn
# extract-table.pl
BEGIN { $table = shift @ARGV }
print if /^create table $table\b/io .. /^create table (?!$table)\b/io;

Then do the following to restore the table:

zcat /path/mysqldump.date.gz | extract-table Mytable> ~/Mytable.dump
mysql  mydatabase -e "drop table Mytable"
mysql mydatabase


mtop/mkill – MySQL Monitoring Tools

March 15, 2006

mtop can be used like top in Unix. Download from HERE first.

Must start mysql with mtop user and passwd:
mysql --dbuser=monitor --password=n0tell