GGshow reloaded GGshow reloaded

December 1, 2012

Linux command – 1.3 – Viewing file

more – file perusal filter for crt viewing

View a file in terminal with ability to scroll down.


more [-dlfpcsu] [-num] [+/pattern] [+linenum] [file ...]


This option specifies an integer number which is the screen size (in lines).

more will prompt the user with the message "[Press space to continue, 'q' to quit.]" and will display "[Press 'h' for instructions.]" instead of ringing the bell when an illegal key is pressed.

more usually treats ^L (form feed) as a special character, and will pause after any line that contains a form feed. The -l option will prevent this behavior.

Causes more to count logical, rather than screen lines (i.e., long lines are not folded).

Do not scroll. Instead, clear the whole screen and then display the text. Notice that this option is switched on automatically if the executable is named page.

Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.

Squeeze multiple blank lines into one.

Suppress underlining.

The +/ option specifies a string that will be searched for before each file is displayed.

Start at line number.

less – opposite of more

View a file in terminal with ability to scroll up and down.


less -?
less --help
less -V
less --version
less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~] [-b space] [-h lines] [-j line] [-k keyfile] [-{oO} logfile] [-p pattern] [-P prompt] [-t tag] [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines] [-# shift] [+[+]cmd] [--] [filename]...


-?, --help
This option displays a summary of the commands accepted by  less (the  same  as  the  h  command). (Depending on how your shell interprets the question mark, it may be necessary to  quote  the question mark, thus: "-?".)

-a, --search-skip-screen
Forward search skips current screen.

Forward search always skips target line.

-b[N], --buffers=[N]
Number of buffers.

-B, --auto-buffers
Don't automatically allocate buffers for pipes.

-c, --clear-screen
Repaint by clearing rather than scrolling.

-d, --dumb
Dumb terminal.

-D[xn.n], --color=xn.n
Set screen colors. (MS-DOS only)

-e, -E, --quit-at-eof, --QUIT-AT-EOF
Quit at end of file.

-f, --force
Force open non-regular files.

-F, --quit-if-one-screen
Quit if entire file fits on first screen.

-g, --hilite-search
Highlight only last match for searches.

Don't highlight any matches for searches.

-h [N], --max-back-scroll=[N]
Backward scroll limit.

-i, --ignore-case
Ignore case in searches that do not contain uppercase.

Ignore case in all searches.

-j [N], --jump-target=[N]
Screen position of target lines.

-J, --status-column
Display a status column at left edge of screen.

-k [file], --lesskey-file=[file]
Use a lesskey file.

-K, --quit-on-intr
Exit less in response to ctrl-C.

-L, --no-lessopen
Ignore the LESSOPEN environment variable.

-m, -M, --long-prompt, --LONG-PROMPT
Set prompt style.

-n, -N, --line-numbers, --LINE-NUMBERS
Don't use line numbers.

-o [file], --log-file=[file]
Copy to log file (standard input only).

-O [file], --LOG-FILE=[file]
Copy to log file (unconditionally overwrite).

-p [pattern], --pattern=[pattern]
Start at pattern (from command line).

-P [prompt], --prompt=[prompt]
Define new prompt.

-q, -Q, --quiet, --QUIET, --silent, --SILENT
Quiet the terminal bell.

-r, -R, --raw-control-chars, --RAW-CONTROL-CHARS
Output "raw" control characters.

-s, --squeeze-blank-lines
Squeeze multiple blank lines.

-S, --chop-long-lines
Chop long lines.

-t [tag], --tag=[tag]
Find a tag.

-T [tagsfile], --tag-file=[tagsfile]
Use an alternate tags file.

-u, -U, --underline-special, --UNDERLINE-SPECIAL
Change handling of backspaces.

-V, --version
Display the version number of "less".

-w, --hilite-unread
Highlight first new line after forward-screen.

Highlight first new line after any forward movement.

-x [N[,...]], --tabs=[N[,...]]
Set tab stops.

-X, --no-init
Don't use termcap init/deinit strings.
 Don't use termcap keypad init/deinit strings.

-y[N], --max-forw-scroll=[N]
Forward scroll limit.

-z[N], --window=[N]
Set size of window.

-" [c[c]], --quotes=[c[c]]
Set shell quote characters.

-~, --tilde
Don't display tildes after end of file.

-# [N], --shift=[N]
Horizontal scroll amount (0 = one half screen width)

Don't send keypad init/deinit sequence.

The F command changes files if the input file is renamed.

head – output the first part of files


head [OPTION]… [FILE]…Options:

-c, --bytes=[-]K
print the first K bytes of each file; with the leading `-', print all but the last K bytes of each file

-n, --lines=[-]K
print the first K lines instead of the first 10; with the leading `-', print all but the last K lines of each file

-q, --quiet, --silent
never print headers giving file names

-v, --verbose
always print headers giving file names

display this help and exit

output version information and exit

K may have a multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

tail – output the last part of files


tail [OPTION]... [FILE]...


-c, --bytes=K
output the last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file

-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent

same as --follow=name --retry

-n, --lines=K
output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth

with --follow=name, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful.

with -f, terminate after process ID, PID dies

-q, --quiet, --silent
never output headers giving file names

keep trying to open a file even when it is or becomes inaccessible; useful when following by name, i.e., with --follow=name

-s, --sleep-interval=N
with -f, sleep for approximately N seconds (default 1.0) between iterations. With inotify and --pid=P, check process P at least once every N seconds.

-v, --verbose
always output headers giving file names

pg – browse pagewise through text files


pg [-number] [-p string] [-cefnrs] [+line] [+/pattern/] [file...]


The number of lines per page. Usually, this is the number of CRT lines minus one.

Clear the screen before a page is displayed, if the terminfo entry for the terminal provides this capability.

Do not pause and display (EOF) at the end of a file.

Do not split long lines.

Without this option, commands must be terminated by a newline character. With this option, pg advances once a command letter is entered.

-p string
Instead of the normal prompt :, string is displayed. If string contains %d, its first occurrence is replaced by the number of the current page.

Disallow the shell escape.

Print messages in standout mode, if the terminfo entry for the terminal provides this capability.

Start at the given line.

Start at the line containing the Basic Regular Expression patâ tern given.
Filed under: Linux — Tags: , , , , , , — GG @ 3:55 pm

Linux command – 1.4 – File operation

cat – concatenate file(s) or standard input to standard output.


cat [option] [file]


-A, --show-all
equivalent to -vET-b, --number-nonblank
number nonempty output lines, overrides -n

equivalent to -vE

-E, --show-ends
display $ at end of each line

-n, --number
number all output lines

-s, --squeeze-blank
suppress repeated empty output lines

-T, --show-tabs
display TAB characters as ^I


-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB

Example: Combine 2 files

$ cat file1 file2 > newfile

Example: Append a file to another file

$ cat file1 >> file2

cp – copy / duplicate files and/or directories


cp [option] [source] [destination]


-a, --archive
same as -dR --preserve=all--attributes-only
don't copy the file data, just the attributes

make a backup of each existing destination file

-b like --backup but does not accept an argument

copy contents of special files when recursive

-d same as --no-dereference --preserve=links

-f, --force
if an existing destination file cannot be opened, remove it and try again (redundant if the -n option is used)

-i, --interactive
prompt before overwrite (overrides a previous -n option)

-H follow command-line symbolic links in SOURCE

-l, --link
hard link files instead of copying

-L, --dereference
always follow symbolic links in SOURCE

-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)

-P, --no-dereference
never follow symbolic links in SOURCE

-p same as --preserve=mode,ownership,timestamps

preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all

-c same as --preserve=context

don't preserve the specified attributes

use full source file name under DIRECTORY

-R, -r, --recursive
copy directories recursively

control clone/CoW copies. See below

remove each existing destination file before attempting to open it (contrast with --force)

control creation of sparse files. See below

remove any trailing slashes from each SOURCE argument

-s, --symbolic-link
make symbolic links instead of copying

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
copy all SOURCE arguments into DIRECTORY

-T, --no-target-directory
treat DEST as a normal file

-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing

-v, --verbose
explain what is being done

-x, --one-file-system
stay on this file system

-Z, --context=CONTEXT
set security context of copy to CONTEXT

Example: Copy file1 to file2

$ cp file1 file2

Example: Create a new symbolic link of file1 as file2

$ cp -s file1 file2

mv – move / rename files and/or directories


mv [option] [source] [destination]


make a backup of each existing destination file-b
like --backup but does not accept an argument

-f, --force
do not prompt before overwriting

-i, --interactive
prompt before overwrite

-n, --no-clobber
do not overwrite an existing file

remove any trailing slashes from each SOURCE argument

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY

-T, --no-target-directory
treat DEST as a normal file

-u, --update
move only when the SOURCE file is newer than the destination file or when the destination file is missing

-v, --verbose
explain what is being done

Example: Rename file1 to file2

$ mv file1 file2

Example: Move folder to a new destination

$ mv /path/to/source /path/to/destination

mkdir – make a new directory


mkdir [option] [dir]


-m, --mode=MODE
set file mode (as in chmod), not a=rwx - umask-p, --parents
no error if existing, make parent directories as needed

-v, --verbose
print a message for each created directory

-Z, --context=CTX
set the SELinux security context of each created directory to CTX

Example: Making a new directory and print a message explaining what is being done

$ mkdir -v NewFolder
mkdir: created directory `NewFolder'

rm – remove / delete a file


rm [option] [file]


-f, --force
ignore nonexistent files, never prompt-i
prompt before every removal

prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving protection against most mistakes

prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompt always

when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument

do not treat `/' specially

do not remove `/' (default)

-r, -R, --recursive
remove directories and their contents recursively

-v, --verbose
explain what is being done

Example: Remove a directory and print a message explaining what is being done

user@ubuntu:~$ rm -rv test2
removed directory: `test2'

ln – create symbolic link


ln [source] [destination](create a link to TARGET with the name LINK_NAME)

(create a link to TARGET in the current directory)

(create links to each TARGET in DIRECTORY)

Create hard links by default, symbolic links with --symbolic. When creating hard links, each TARGET must exist. Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted in relation to its parent directory.


make a backup of each existing destination file-b
like --backup but does not accept an argument

-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will probably fail due to system restrictions, even for the superuser)

-f, --force
remove existing destination files

-i, --interactive
prompt whether to remove destinations

-L, --logical
make hard links to symbolic link references

-n, --no-dereference
treat destination that is a symlink to a directory as if it were a normal file

-P, --physical
make hard links directly to symbolic links

-s, --symbolic
make symbolic links instead of hard links

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
specify the DIRECTORY in which to create the links

-T, --no-target-directory
treat LINK_NAME as a normal file

-v, --verbose
print name of each linked file

display this help and exit

output version information and exit

touch – update the access time and last modified date for a file to the current time and date


touch [option] [file]


change only the access time-c, --no-create
do not create any files

-d, --date=STRING
parse STRING and use it instead of current time


-h, --no-dereference
affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink)

change only the modification time

-r, --reference=FILE
use this file's times instead of current time

use [[CC]YY]MMDDhhmm[.ss] instead of current time

change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m

Example: Change the access time of a file to specified date

$ touch -t 199912131415 filename
Filed under: Linux — Tags: , , , , , , , — GG @ 3:37 pm

Linux command – 1.1 – Navigating file system

pwd – print the full pathname of the current working directory


pwd [-LP]


-L / --logical
use PWD from environment, even if it contains symlinks

-P / --physical
avoid all symlinks

Example: Print the current working directory

$ pwd

cd – change the current working directory


cd [-L|[-P [-e]]] [dir]


use PWD from environment, even if it contains symlinks

avoid all symlinks

return unsuccessful status if the current working directory cannot be successfully determined after a successful directory change

Example: Change working directory to file system root

[user@ubuntu ~]$ cd /
[user@ubuntu /]$

ls – list directory contents


ls [option] [file]


-a, --all
do not ignore entries starting with .

-A, --almost-all
do not list implied . and ..

with -l, print the author of each file

-b, --escape
print C-style escapes for nongraphic characters

scale sizes by SIZE before printing them. SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
`--block-size=K' prints sizes in units of 1,024 bytes.
`--block-size=M' prints sizes in units of 1,048,576 bytes.

-B, --ignore-backups
do not list implied entries ending with ~

with -lt: sort by, and show, ctime (time of last modification of file status information)
with -l: show ctime and sort by name otherwise: sort by ctime, newest first

list entries by columns

colorize the output. WHEN defaults to `always' or can be `never' or `auto'. Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.

-d, --directory
list directory entries instead of contents, and do not dereference symbolic links

-D, --dired
generate output designed for Emacs' dired mode

do not sort, enable -aU, disable -ls --color

-F, --classify
append indicator (one of */=>@|) to entries

likewise, except do not append `*'

across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C

like -l --time-style=full-iso

like -l, but do not list owner

group directories before files. augment with a --sort option, but any use of --sort=none (-U) disables grouping

-G, --no-group
in a long listing, don't print group names

-h, --human-readable
with -l, print sizes in human readable format (e.g., 1K 234M 2G)

likewise, but use powers of 1000 not 1024

-H, --dereference-command-line
follow symbolic links listed on the command line

follow each command line symbolic link that points to a directory

do not list implied entries matching shell PATTERN (overridden by -a or -A)

append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F)

-i, --inode
print the index number of each file

-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN

like --block-size=1K

use a long listing format

-L, --dereference
when showing file information for a symbolic link, show information for the file the link references rather than for the link itself

fill width with a comma separated list of entries

-n, --numeric-uid-gid
like -l, but list numeric user and group IDs

-N, --literal
print raw entry names (don't treat e.g. control characters specially)

like -l, but do not list group information

-p, --indicator-style=slash
append / indicator to directories

-q, --hide-control-chars
print ? instead of non graphic characters

show non graphic characters as-is (default unless program is `ls' and output is a terminal)

-Q, --quote-name
enclose entry names in double quotes

use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape

-r, --reverse
reverse order while sorting

-R, --recursive
list subdirectories recursively

-s, --size
print the allocated size of each file, in blocks

sort by file size

sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v

with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status -c; use specified time as sort key if --sort=time

with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like `date'; if FORMAT is FORMAT1<newline>FORMAT2, FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with `posix-', STYLE takes effect only outside the POSIX locale

sort by modification time, newest first

-T, --tabsize=COLS
assume tab stops at each COLS instead of 8

with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time

do not sort; list entries in directory order

natural sort of (version) numbers within text

-w, --width=COLS
assume screen width instead of current value

list entries by lines instead of by columns

sort alphabetically by entry extension

list one file per line

Example: List all files & directories in file system root

$ ls /
bin   dev   initrd.img  lost+found  opt   run      srv  usr
boot  etc   lib         media       proc  sbin     sys  var
data  home  lib64       mnt         root  selinux  tmp  vmlinuz

Example: List all contents exclude those with specified file extension.

$ ls --hide='*.bak'
Filed under: Linux — Tags: , , , , — GG @ 3:14 pm

March 24, 2012

Web Development Environment in Ubuntu Linux

PART 1 – Ubuntu
Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software, using its own desktop environment.

  1. Download & install Ubuntu Linux.
  2. Update package index and upgrade OS.
    To update package index
    sudo apt-get update

    To upgrade all installed packages

    sudo apt-get upgrade
  3. Installing software packages
    To install a package
    sudo apt-get install <package-name>

    To remove a package

    sudo apt-get remove <package-name>

LAMP is an acronym for a solution stack of free, open source software, referring to the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software) and PHP (or sometimes Perl or Python), principal components to build a viable general purpose web server.

  1. Install LAMP
    To install Apache 2, MySQL 5, PHP 5, Apache PHP5 module, PHP MySQL package.
    sudo apt-get install apache2
    sudo apt-get install mysql-server
    sudo apt-get install mysql-client
    sudo apt-get install php5
    sudo apt-get install libapache2-mod-php5
    sudo apt-get install php5-mysql 

    or simply

    sudo apt-get install lamp-server^

    to install all packages below:
    perl-modules apache2 mysql-server-core-5.1 mysql-client-core-5.1 perl libmysqlclient16 libdbi-perl apache2-mpm-prefork apache2.2-common apache2.2-bin apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcap2 ssl-cert libwrap0 mysql-server libapache2-mod-php5 php5-common php5-cli libclass-isa-perl libdbd-mysql-perl libplrpc-perl libhtml-template-perl mysql-common libnet-daemon-perl libpod-plainer-perl libswitch-perl tcpd mysql-client-5.1 mysql-server-5.1 php5-mysql

PART 3 – Optional Packages

  1. Zend Framework Zend Framework is an open source, object oriented web application framework for PHP 5.
    To install Zend Framwork CLI
    sudo apt-get install zend-framework-bin
  2. PHPUnit PHPUnit is a unit testing software framework for PHP.
    To install PHPUnit
    sudo apt-get install php-pear
    sudo pear channel-update
    sudo pear channel-discover
    sudo pear channel-discover
    sudo pear update-channels
    sudo pear upgrade-all
    sudo pear install --alldeps phpunit/PHPUnit
    sudo apt-get install phpunit


    sudo apt-get install php-pear
    sudo pear update-channels
    sudo pear config-set auto_discover 1
    sudo pear install --alldeps
    sudo apt-get install phpunit
  3. Xdebug
    Xdebug is a PHP extension which provides debugging and profiling capabilities.
    To install Xdebug
    sudo apt-get install php5-xdebug

    Add the following lines into etc/php5/conf.d/xdebug.ini if it does not exist.

    zend_extension = “/usr/lib/php5/20090626-lfs/”
  4. Optional PHP extensions
    To install PHP extensions
    sudo apt-get install php5-cgi php5-cli php5-curl php5-gd php5-idn php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-mysql php5-pgsql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

    * install only which needed.

  5. MySQL GUI tools
    1. Install MySQL Administrator and MySQL Query Browser
      sudo apt-get install mysql-admin
      sudo apt-get install mysql-query-browser


    2. Install MySQL Workbench
      sudo apt-get install mysql-workbench
      sudo apt-get install mysql-query-browser


    3. Install phpMyAdmin
      sudo apt-get install phpmyadmin

      Add the following line into /etc/apache2/apache2.conf

      Include /etc/phpmyadmin/apache.conf
  6. Integrated Development Environment
    1. Eclipse
      Install Eclipse IDE
      sudo apt-get install eclipse

      Install PHP Development Tools (PDT)

      sudo add-apt-repository ppa:yogarine/eclipse/ubuntu
      sudo apt-get update
      sudo apt-get install eclipse-pdt


    2. Netbeans IDE
      Download & install Netbeans IDE
      Install Java
      sudo apt-get install sun-java6-jdk sun-java6-jre

      Download & install Netbeans

      sudo sh ./

      Install Netbeans

      sudo apt-get install netbeans

      Or download & install the Java SE and NetBeans Cobundle

      sudo sh ./
  7. Web browser debugging tool
    1. Firebug Install Firebug. or
    2. Developer tools in Chromium Browser Install Chromium Browser
      sudo apt-get install chromium-browser

      Press Ctrl+Shift+I to open Developer Tools

  8. Install version control system
    1. Subversion
      Subversion (SVN) is a software versioning and revision control system distributed under an open source license.
      Install Subversion
      sudo apt-get install subversion
      sudo apt-get install libapache2-svn
    2. Git
      Git is a distributed revision control and source code management (SCM) system with an emphasis on speed.
      Install Git
      sudo apt-get install git-core
      sudo apt-get install git-doc
      sudo apt-get install git-svn
      sudo apt-get build-dep git-core git-doc git-svn

PART 4 – Packages version
To check installed packages version

apache2 -v
php -v
mysql -V
phpunit --version
git --version
svn --version
java -version
zf show version
Filed under: Linux,MySQL,PHP,Web,Zend Framework — Tags: , , , , , — GG @ 10:26 pm

January 15, 2012

Zend Framework Command Line Tool with administrator rights


  • Problem using Zend Framework zf.bat in Windows.
  • Unable to create project using zf Command Line Tool.
    C:\Program Files\Zend\ZendServer\share\ZendFramework\bin>zf create project mypro
    Warning: mkdir(): Permission denied in C:\Program Files\Zend\ZendServer\share\Ze
    ndFramework\library\Zend\Tool\Project\Provider\Project.php on line 55
                              An Error Has Occurred
     Could not create requested project directory 'myproject'
    Zend Framework Command Line Console Tool v1.11.11
    Details for action "Create" and provider "Project"
        zf create project path name-of-profile file-of-profile


  • Administrator rights are required to create folders and files into specified location.


  • Run the command as administrator To start command prompt as administrator, right click on the its shortcut, and choose run as administrator. You can also select the command prompt shortcut and press Ctrl + Shift + Enter.
    C:\Program Files\Zend\ZendServer\share\ZendFramework\bin>zf create project mypro
    Creating project at C:/Program Files/Zend/ZendServer/share/ZendFramework/bin/myp
    Note: This command created a web project, for more information setting up your V
    HOST, please see docs/README
  • For Zend Framework CLI in Linux, use sudo to execute
    sudo create project myproject
Filed under: Linux,PHP,Windows,Zend Framework — Tags: , , , — GG @ 1:12 am
« Newer Posts

© 2021 GGSHOW | Powered by WordPress