Monday, November 23, 2009

Bash - Shortcut + Stuffs

Bash Movements
Ctrl+A Move cursor to beginning of line.
Ctrl+B Move cursor to left.
Ctrl+C Abort current command.
Ctrl+D Delete character at current cursor position.
Ctrl+E Move cursor to end of line.
Ctrl+F Move cursor to the right.
Ctrl+H Delete character to the left of current cursor position.
Ctrl+K Erase from current cursor position to end of line.
Ctrl+L Clear screen and display current line.
Ctrl+N Bring up next command line.
Ctrl+P Bring up previous command line.
Ctrl+Q Continue displaying to screen.
Ctrl+S Stop displaying to screen.
Ctrl+U Erase from current cursor position to beginning of line.
Ctrl+W Delete word at current cursor position to the left.
Ctrl+Y Yank back the last item erased by ....
Ctrl+Z Suspend the current command.
Alt+B Move cursor one word to the left.
Alt+C Capitalize first letter of the following word.
Alt+D Delete word at current cursor position (to the right).
Alt+F Move cursor one word to the right.
Alt+L De-capitalize following word.
Alt+R Revert to last command line.
Alt+U Capitalize following word.
Alt+BS Delete word at current cursor position (to the left).
Alt+. Last argument of last previous command.

Bash Variables
$0 - Shell Name
$$ - Shell Process ID
!$ - Holds the last command Argument - similar to $_ ( But you can see change in behavior)
!:1 - last command first argument

Wednesday, November 11, 2009

GNU Binary Utilities for Linux/Unix


ar : Create, modify, and extract from archives
nm : List symbols from object files
objcopy : Copy and translate object files
objdump : Display information from object files
ranlib : Generate index to archive contents
readelf : Display the contents of ELF format files.
size : List section sizes and total size
strings : List printable strings from files
strip : Discard symbols
c++filt : Filter to demangle encoded C++ symbols
cxxfilt : MS-DOS name for c++filt
addr2line : Convert addresses to file and line
nlmconv : Converts object code into an NLM
windres : Manipulate Windows resources

For Development Utilities
cdecl : C declaration
c++decl : C++ declaration

Related to Modules
dlltool: Create files needed to build and use DLLs
dlmod: Load shared objects
lsmod - List or display loaded modules
rmmod - : remove the existing modules
insmod : insert a module

You can be part of this@http://www.gnu.org/software/binutils/

Monday, January 12, 2009

Screen - screen manager


-- screen program allows you to use multiple windows[Virtual consoles] in UNIX/LINUX, with one remote login session.
-- all virtual console devices can be open at once, but only one is active at a time

Useful-- when you log on to the the remote server

Scenarios
---When you log on to the remote server(using ssh,telent,etc), you may need more windows/terminal for the same host. But you do want to open multiple terminal from your host and many log on to the same host

---You have logged into the remote system,doing work. Suddenly connection closed(due to some network errors or may even your system failure). You have lost the session to remote system, and also lost work done.

Solution
--- use the screen manager once you log on the remote server.

How to use:
1. Once you log on to the remoter server launch the screen manager((/usr/local/bin/screen @ FreeBSD, check with your system) .
2. Create multiple windows using the following command

Eg:
Once you log on the remote host run
screen

Create a screen and remains in the same window
Ctrl+ a c -- creates a new window
Ctrl+ a w -- list the windows created. * mark indicates the active window
Ctrl+a A(Shift+a) -- Set title for the current window
Ctrl+a k -- kill the current window
Ctrl+a n -- go to the nth window
Ctrl+a Ctrl+a -- toggle between current window and previous window
Ctrl+a ? -- Display help
exit -- exit the current window (as usual to UNIX terminal exit)
Ctrl+a d -- detach the screen (Screen keeps on running, you can attach later)

You can find more options with Cntrl+a ? (Shift+?)

screen -ls -- will show the what are all the screens running behalf of you
screen -r -- will load the running screen.

I will explain more features in future





Following is a sample configure file .screenrc. Place this file at your home directory /home/user/.screenrc


# skip the startup message
startup_message off

# go to home dir
chdir

# Automatically detach on hangup.
autodetach on

# Change default scrollback value for new windows
defscrollback 1000

# start with visual bell as default
vbell on
vbell_msg "bell on %t (%n)"


# look and feel
caption always "%{= bb}%{+b w}%n %h %=%t %C%a"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"

activity "^GActivity in %t(%n)"
bell_msg "^GBell in %t(%n)"

bindkey -k P prev
bindkey -k N next

shelltitle "shell"

#Number of login shells to be open when screen creteatd in
screen -t SHELL 0 bash
screen -t SHELL 1 bash
screen -t SHELL 2 bash