Saturday, December 13, 2008

Linux Command

1. file: identify files by examining their contents.
2. wc: print newline, word, and byte counts for each file.
3. whereis: locate the binary, source, and manual page files for a command.
4. whoami: print effective userid
5. test: check file types and compare values
6. which: locate a command. $ which -a ls
7.

Linux - Blogs

David Futcher: a young kid of MOTU team

Linux Packaging

How to make a "Basic" .deb (from Ubuntu forum)
PackagingGuide/Complete
How can I make this setup.py better (from Ubuntu forum)
GoogleCode-debianpackagemaker

Debian Linux apt-get package management

Package management tools:
[1] apt-get: advanced package tool.
[2] dpkg: Debian packaging tool.
[3] GUI tools: aptitude(a text-based interface) & synaptic(GUI front end)

# apt-get remove {package-name}
apt-get remove the package but keep the configuration files
# apt-get --purge remove {package-name}
apt-get remove the package and configuration file
# dpkg --info {package-name.deb}
get package information such as description of package, version etc.
# dpkg -l {package-name}
list all installed packages or individual package
# dpkg -L {package-name}
list files provided (or owned) by the installed package
# dpkg --contents {package-name.deb}
list files provided (or owned) by the package
# dpkg -S {/path/to/file}
find what package owns the file
# dpkg -s {package-name} | grep Status
find out if package is installed or not (status)
# apt-cache depends {package-name}
display a listing of each dependency a package has and all the possible other packages that can fulfill that dependency.
# apt-get source {package-name}
downloads the source code to the stated package
# apt-get build-dep {package-name}
to build a package from a source file


To configure your system, you need to setup your source.list file which is located in /etc/apt/sources.list. You can add any repository that you like, a good list of third-party sources is available on http://www.apt-get.org.

When you install a package APT retrieves the needed files from the hosts listed in /etc/apt/sources.list, stores them in a local repository(/var/cache/apt/archives/), and then proceeds with installation. apt-get clean removes everything except lock files from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. Thus, if you need to reinstall a package APT should retrieve it again. apt-get autoclean removes only package files that can no longer be downloaded.

Linux Tools

Advanced Packaging Tool (APT):
APT - wikipedia
APT Debian Wiki
APT - HOWTO
Apt-get Guide
apt-get manual page
apt-cache manual page

Linux Programming

linux.com - Programming
Programming on Linux - from Linuxselfhelp.com
Free On-line Technical Books and Tutorials - from linuxtopia.com (good!)

Linux Tips - 1

1. Install packages at the command: sudo dpkg -i packagename.deb
2. Compiling from source.
Grab the package's build dependencies with sudo apt-get build-dep packagename. Don't make install when you compile from source -- use Checkinstall instead. Checkinstall will create a Debian package and install it for you, so you can remove or upgrade the software more easily later on. After you've run ./configure; make, just run sudo checkinstall and answer a few simple questions.

Thursday, December 11, 2008

C/C++ Coding Standard

C++ Programming/Code/Style Conventions - from Wiki Books
GNU Coding Standards
Google C++ Style Guide
C++ Coding Standards - Book Home Page

Uwyn C++ Coding Standard(good one)


CERT C++ Secure Coding Standard
CERT C Secure Coding Standard

Programming Tools

Edit Tools:
Vi/Vim;

Debug Tools:
Valgrind:
Valgrind Homepage
Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications

GDB: The GUN Debugger, usually called just GDB, is the standard debugger for the GNU software system.
GNU Debugger - Wiki
GDB Homepage
Zen and the Art of Debugging C/C++ in Linux with GDB
Using GNU's GDB Debugger - Tutorial

GNU Binutils: The GNU Binary Utilities, or binutils, is a collection of programming tools for the manipulation of object code in various file format.
GNU Binutils - Wiki
GNU Binutils Homepage

GNU gprof:
GNU gprof Table of Content
GNU gprof from cs.utah.edu

TAU:
Tuning and Analysis Utilities: a portable profiling and tracing toolkit for performance analysis of parallel programs written in Fortran, C, C++, Java, Python.

Version Control Tools:
List of revision control software
CVS:
Software Version Control
The CVS manual - Version Management with CVS
SVN: to be a mostly-compatible successor to the widely used CVS.
Subversion(SVN) - Wiki
Version Control with Subversion - online book
Subversion - yolinux tutorial

Compile, Link, Build, Configure and Package:
GCC:
GCC, the GNU Compiler Collection
An Introduction to GCC

GNU Make: Make is a tool which controls the generation of executables and other non-source files for a program from the program's source files.
GNU Make Homepage

GNU Core Utilities: The GNU Core Utilities or coreutils is a package of GNU software containing many of the basic tools such as cat, ls, and rm needed for Unix-like operating systems.
GNU Core Utilities - Wiki
GNU coreutils manual

Software Development Management
Bugzilla

Misc:
Useful Tools tutorial

General Resources

Ubuntu Forum - How to learn to program, and Linux programming

Geeky Programmer
Programming Master
Blogs

Programming Contest
Programming Community

OOP
Design Pattern
Extreme Programming

CodePedia

C/C++

POSIX-Wiki

C/C++ Programming Language:
C Programming Language - Wiki
C++ Programming Language - Wiki
C99 - Wiki
JTC1/SC22/WG14 - C
The C++ Standards Committee
Wiki Books - C++ Programming Category
Wiki Books - C++ Programming/Weblinks

C/C++ Library, Syntax, Technology:
C/C++ Coding Standard
C/C++ Library

Reference:
C/C++ Reference

Miscellaneous:
C/C++ Course Links
C/C++ Community
C/C++ General Material Website

Material:
C++ Programming HOW-TO
Complatibility of C and C++

Sunday, December 7, 2008

.bashrc file collection

Bash-Making use of your .bashrc file
A Sample .bashrc File from Advanced Bash-Scripting Guide

BASH

Bash-wiki
GNU BASH
BashScripts.org Forum

Tutorials:
BASH Programming - Introduction HOW-TO
Bash Shell Programming in Linux
Bash Guide For Beginners
Advanced Bash-scripting Guide
Getting Started with BASH

Tips:
Customizing your Bash environment

Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc

The difference between ~/.bashrc, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, and ~/.bash_logout:
[1] When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. Basically, ~/.bashrc allows you to create shortcuts (aliases) and interactive programs (functions) that run on the startup of the bash shell or that are used when running an interactive shell.

[2] When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

[3] When bash exits the file called .bash_logout in the user's home directory is run.

Reference:
[1] http://telin.ugent.be/~slippens/drupal/bashrc_and_others
[2] http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlbash.html

Saturday, December 6, 2008

Master the Linux bash command line with these 10 shortcuts

The bash shell is the primary interface to the Linux operating system -- it accepts, interprets and executes your commands, and provides you with the building blocks for shell scripting and automated task execution.

[1] Easily recall previous commands
"speed search" previously-executed commands by typing the first few letters of the command followed by the key combination Ctrl-R.

[2] Use command aliases
You can obtain a list of available aliases by invoking alias without any argument, and you can delete an alias with unalias.

[3] Use filename auto-completion
To use this feature, type the first few letters of the file name, followed by Tab. Bash will scan the current directory, as well as all other directories in the search path, for matches to that name.

[4] Use key shortcuts to efficiently edit the command line
Ctrl-A/E: moves the cursor to the beginning/end of the command line.
Ctrl-W/K: deletes the word immediately before/after the cursor.

[5] Get automatic notification of new mail
MAILPATH='/var/spool/mail/USERNAME'
export MAILPATH

[6] Run tasks in the background
To run a task in the background, add an ampersand(&) to the end of its command line.

[7] Quickly jump to frequently-used directories
$PATH variables lists bash's "search path" - the directories it will search when it can't find the requested file in the current directory. However, bash also supports the $CDPATH variable, which lists the directories the cd command will look in when attempting to change directories.

[8] Perform calculations
echo $((16/2))
type in the artithmetic expression you wish to evaluate at the prompt within double parentheses.

[9] Customize the shell prompt
PS1='\u@\h:\w \@> '
export PS1
This will display the name of the current logged-in user, the host name, the current working directory and the current time at the shell prompt.

[10] Get context-specific help
help alias

Reference:
Master the Linux shell command line with these 10 shortcuts

Tuesday, December 2, 2008

C++ Standard Library

Nicolai M. Josuttis: The C++ Standard Library - A Tutorial and Referece

Smart Pointer

A smart pointer is an abstract data type that simulates a pointer while providing additional features, such as automatic garbage collection or bounds checking. Smart pointers typically keep track of the objects that point to them for the purpose of memory management. In C++ language, smart pointers may be implemented as a template class that mimics, by means of operator overloading, the behavior of traditional pointers, (e.g. dereferencing, assignment) while providing additional memory management algorithms.

Why?
1. Less bugs. 2. Exception Safety. 3. Garbage collection. 4. Efficiency. 5. STL containers.

Efficiency: to make efficient use of available memory and to shorten allocation and deallocation time. A common strategy for using memory more efficiently is copy on write (COW). The same object is shared by many COW pointers as long as it is only read and not modified. The standard string class is commonly implemented using COW semantics.

Reference:
Smart pointer - Wiki

Additional Reading:
Smart pointer templates in C++ by David Harvey

Object-Oriented Technology

Object-oriented tips

Generic Programming:
Generic Programming Wiki
generic-programming.org