Beginners – How to get Help

Valic —  December 5, 2012 — Leave a comment

When you are stuck and need  help with a UNIX command the help is sometimes a few  keystrokes away! Help is typically built  into the commands themselves, available through online facilitate programs like man pages and info pages.

 1. Using the Help biult-in command:

Many commands and applications have simple help screens that can be displayed with special command flags. This flag usually is “-h” or “–help“.


cat –help

2. Using Man Pages

The best source of data for most commands is found within the manual pages. Theese are known asa man pages. To display a command’s man page  you need to type man command

Example: If you want to get help with the grep command just type man grep and the man page for the grep command will be displayed.

Continue Reading…

The Command PATH:

Most common commands are located in your shell’s “PATH” meaning that you can just type the name of the program to execute it.

Example:  Typing “ls” will execute the “ ls” command.

Your shell’s “PATH” variable includes the most common program locations, such as /bin, /usr/bin, /usr/X11R6/bin, and others.

To execute commands that are NOT in your current PATH, you have to give the complete location of the command.



./yourprogram  (This will execute the program in the current directory)


Command Syntax:

Commands can be run by themselves or you can pass in additional arguments to make them do different things. Typical command syntax can look something like this:

command [argument] [-argument] [--argument] [file]


  • ls –    List files in current directory
  • ls -l   Lists files in “long” format
  • ls -l –color As above, with colorized output
  • cat filename     Show contents of a file
  • cat -n filename Show contents of a file, with line numbers

Beginners – BASH Special Characters

Valic —  November 29, 2012 — 1 Comment

Before we continue to study about UNIX operating system shell commands, it is important to understand that there are several symbols and characters that the shell interprets in special ways called BASH Special Characters. This means that certain typed characters:

  • Cannot be used in certain situations
  • May be used to perform special operations
  • Must be “escaped” if you want to use them in a normal way.
Character Explanation


Escape character. If you want to reference a special character, you must “escape” it with a backslash.
Example: touch filename\* – This command will create the file filename*


Directory separator. It’s used to separate a string of directory names.
Example: /var/www/htdocs


Current directory


Parent directory


User’s home directory


Represents 0 or more characters in a filename or by itself, all files in a directory.
Example: sql*2012 can represent the files sql2012, sql-backup2012, sql29-11-2012 etc.


Represents a single character in a filename.
Example: filename?.txt can represent filename1.txt, filenamex.txt.


Can be used to represent a range of values,  [0-9], [A-Z], etc.
Example: filename[0-2].txt represents the names filename0.txt, filename1.txt, and filename2.txt


“Pipe” . It’s mostly used to redirect the output of one command into another command.
Example: ls | more


Redirects output of a command into a new file. If the file already exists will be over-writed.
Example: ls > listoffiles.txt


Redirects the output of a command onto the end of an existing file. If the file does not exist, will be created.
Example: echo “test ” >> testfile.txt


Redirects a file as input to a program.
Example: more < listoffiles.txt


Command separator. Allows you to execute multiple commands on a single line.
Example: cd /var/log ; less syslog


Command separator as above, but only runs the second command if the first one finished without errors.
Example: cd /var/logs && less syslog


Execute a command in the background, and immediately get your shell back.
Example: find / -name log > logfiles.txt &

What is a command shell:

Command shell is a program that interprets commands,
Allows a user to execute commands by typing them manually at a terminal or automatically in programs called shell scripts.
A shell is NOT an operating system.
It is a way to interface with the operating system and run commands.

What is BASH:

The name itself is an acronym, BASH = Bourne Again SHell
Bash is a shell written as a free replacement to the standard Bourne Shell /bin/sh originally written by Steve Bourne for UNIX systems.
BASH has all of the features of the original Bourne Shell plus additions that make it easier to program.
BASH is Free Software and was adopted as the default shell on most Linux distributions.

I always had problems when i upgraded my wordpress.
So I made ​one script that automatically does this for me and i’ll share that with you.
With this script you can install or upgrade your wordpress install.


# Homepage:
# Email: [email protected]
# Bash script to download and install or upgrade wordpress to specified directory.
install_wp ()
cd ~</pre>
mkdir wordpress
cd wordpress
wget –no-check-certificate;
echo "Where would you like your new WordPress install to be located? Please Type the location(Eg:/var/www/) and press [ENTER]: "
read wordpress_dir
echo "Installing WordPress to $wordpress_dir";
if [ ! -d "$wordpress_dir" ]; then
mkdir $wordpress_dir
tar -zxvf latest.tar.gz -C $wordpress_dir

clean_up ()
cd ~/wordpress
rm latest.tar.gz
cd ~
rmdir wordpress
cd $wordpress_dir/wordpress
mv *.* $wordpress_dir
mv wp-admin $wordpress_dir
mv wp-content $wordpress_dir
mv wp-includes $wordpress_dir/
rmdir $wordpress_dir/wordpress
cd $wordpress_dir/wp-content
mkdir uploads
chmod 777 uploads -R
cd $wordpress_dir
touch $wordpress_dir/.htaccess
chmod -v 666 .htaccess
echo "Wordpress is now Installed to" . $wordpress_dir . "Enjoy!"

update_wp ()
day=`date +%Y_%m_%d`
cd ~
mkdir wordpress_tmp
cd wordpress_tmp
wget –no-check-certificate;
echo "In what directory does WordPress already exist, that you would like updated? Please Type the location(Eg:/var/www/) and press [ENTER]: "
read update_dir
tar -zxvf latest.tar.gz -C $update_dir
cd ~/wordpress_tmp
rm latest.tar.gz
cd ~
rmdir wordpress_tmp

cd $update_dir
cp $update_dir/ $update_dir/../wordpress_backup_$day -R
cp $update_dir/../wordpress_backup_$day/wp-config.php $update_dir

# Go to backup directory and remove the new install of WP
cd $update_dir/../wordpress_backup_$day
rm wordpress -rf

# back to the update directory
cd $update_dir/wordpress

#remove wp-admin and wp-includes
cd $update_dir
rm wp-admin -rf
rm wp-includes -rf

cd $update_dir/wordpress
mv wp-admin $update_dir
mv wp-includes $update_dir
#remove the extra updated directoroies
rm $update_dir/wordpress/ -rf

echo "Upgrade complete! Backup can be found in $update_dir/../$update_dir_backup_$day"
if ["$(id -u)" = "0"]; then {
echo "You are root we will continue" 2>&1

read -p "If the location you want to install wordpress to requires Root access, Please press ‘N’ and run this script again as root, or ‘Y’ to run the script without root (y/n)? "
[ "$REPLY" == "n" ] & exit ||
[ "$REPLY" == "y" ] &
echo "Do you wish to install WordPress [Yes] or update [No]? Type 1 or 2 and press [ENTER]"
select yn in "Yes" "No"; do
case $yn in
Yes ) install_wp && clean_up && break;;
No ) update_wp && break;;
exit 1;


You can download the script from here: Install or Upgrade wordpress bash script


Page 3 of 41234