Sunday, January 23, 2011

New cursor_bind_capture_destination parameter in Oracle 11.2.0.2

January 19th, 2011

I just noticed that there’s a new cursor_bind_capture_destination parameter in Oracle 11.2.0.2 (which is really more like Oracle 11gR3 version because of the large amount of new features in it, as opposed to just bugfixes).

This parameter allows you to save some SYSAUX tablespace disk space – if the occasionally captured bind variable values (from V$SQL_BIND_DATA) take too much space. Normally these bind values (in a packed RAW form) are visible in DBA_HIST_SQLSTAT.BIND_DATA column, which can take up to 2kB per statement in a snapshot – it’s stored as RAW(2000). Of course a more convenient way to query the actual bind values is to use DBA_HIST_SQLBIND (you can also use DBMS_SQLTUNE.EXTRACT_BIND function for translating the raw payload to meaningful values).

So, if you choose to capture a lot of SQL statements per AWR snapshot (it’s configurable) and don’t really care about the sampled bind variable values and want to save the disk space, then you can set cursor_bind_capture_destination = MEMORY or OFF (if you don’t want to capture bind variable values at all).

I’m using my pvalid.sql script for checking its valid values (it’s based on the X$ table underlying V$PARAMETER_VALID_VALUES view, so I could see undocumented parameter valid values too):

SQL> @pvalid cursor_bind_capture_destination
Display valid values for multioption parameters matching “cursor_bind_capture_destination”…

PAR# PARAMETER ORD VALUE
—— ————————————————– ———- —————
2062 cursor_bind_capture_destination 2 MEMORY
cursor_bind_capture_destination 3 MEMORY+DISK
cursor_bind_capture_destination 1 OFF

The default is MEMORY+DISK (this is essentially what you get before 11.2.0.2 and you can’t turn it off unless you turn off the AWR flushing of the whole SQLSTATS metrics).

Saturday, January 22, 2011

shutdown /s /t 10000 --shutdown after appr. 3 hours(166minutes)

Full List of Windows 7 Shutdown Switches

Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

/i Display the graphical user interface (GUI). This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is rebooted, restart any registered applications.
/a Abort a system shutdown. This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning. Can be used with /d and /f options.
/h Hibernate the local computer. Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-315360000 (10 years), with a default of 30. If the timeout period is greater than 0, the /f parameter is implied.
/c "comment" Comment on the reason for the restart or shutdown. Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users. The /f parameter is implied when a value greater than 0 is specified for the /t parameter.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined. If neither p nor u is specified the restart or shutdown is unplanned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).

Tuesday, January 4, 2011

Boot process and init process on Linux


Init Process / PC Boot Procedure


PC Boot and Linux Init Process:

  1. BIOS: The Basic Input/Output System is the lowest level interface between the computer and peripherals.
    The BIOS performs integrity checks on memory and seeks instructions on the Master Boor Record (MBR) on the floppy drive or hard drive.
  2. The MBR points to the boot loader (GRUB or LILO: Linux boot loader).
  3. Boot loader (GRUB or LILO) will then ask for the OS label which will identify which kernel to run and where it is located (hard drive and partition specified). The installation process requires to creation/identification of partitions and where to install the OS. GRUB/LILO are also configured during this process. The boot loader then loads the Linux operating system.
    • See the YoLinux tutorial on creating a boot disk for more information on GRUB and LILO and also to learn how to put the MBR and boot loader on a floppy for system recovery.
  4. The first thing the kernel does is to execute init program. Init is the root/parent of all processes executing on Linux.
  5. The first processes that init starts is a script /etc/rc.d/rc.sysinit
  6. Based on the appropriate run-level, scripts are executed to start various processes to run the system and make it functional.

The Linux Init Processes:

The init process is the last step in the boot procedure and identified by process id "1". Init is responsible for starting system processes as defined in the /etc/inittab file. Init typically will start multiple instances of "getty" which waits for console logins which spawn one's user shell process. Upon shutdown, init controls the sequence and processes for shutdown. The init process is never shut down. It is a user process and not a kernel system process although it does run as root.

System Processes:

Process ID Description
0 The Scheduler
1 The init process
2 kflushd
3 kupdate
4 kpiod
5 kswapd
6 mdrecoveryd

Init config file (Red Hat 7.3-9.0, Fedora Core 1-3): /etc/inittab

# Author:       Miquel van Smoorenburg,
# Modified for RHS Linux by Marc Ewing and Donnie Barnes

id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Things to run in every runlevel. This line is only in Red Hat 7.X Used to flush disk buffers.
ud::once:/sbin/update

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, schedule a shutdown for 2 minutes from now.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Canceled"

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon

Note that this config file directs the init process to run the shell script /etc/rc.d/rc.sysinit. This script should be used as is and NOT changed. Extend rc.local and NOT this script. This will (not in exact order):

  • Run /sbin/initlog
  • Run devfs to generate/manage system devices
  • Run network scripts: /etc/sysconfig/network
  • Start graphical boot (If so configured): rhgb
  • Start console terminals, load keymap, system fonts and print console greeting: mingetty, setsysfonts
    The various virtual console sessions can be viewed with the key-stroke: ctrl-alt-F1 through F6. F7 is reserved for the GUI screen invoked in run level 5.
  • Mount /proc and start device controllers.
  • Done with boot configuration for root drive. (initrd) Unmount root drive.
  • Re-mount root file system as read/write
  • Direct kernel to load kernel parameters and modules: sysctl, depmod, modprobe
  • Set up clock: /etc/sysconfig/clock
  • Perform disk operations based on fsck configuration
  • Check/mount/check/enable quotas non-root file systems: fsck, mount, quotacheck, quotaon
  • Initialize logical volume management: vgscan, /etc/lvmtab
  • Activate syslog, write to log files: dmesg
  • Configure sound: sndconfig
  • Activate PAM
  • Activate swapping: swapon

Local system boot processes can be placed in file: /etc/rc.d/rc.local

The system will then boot to the runlevel set by the directive initdefault.

Also see:


Linux init Run Levels:

The Linux boot process has six states of operation of which "0" is the shutdown state and "3" and above are fully operational with all essential processes running for user interaction. Upon system boot the LINUX system /sbin/init program starts other processes by performing the following:

  • Init will bring up the machine by starting processes as defined in the /etc/inittab file.

  • The computer will be booted to the runlevel as defined by the initdefault directive in the /etc/inittab file.
        id:5:initdefault:
    In this example a runlevel of "5" is chosen. Runlevel "5" will boot the system into GUI mode using XDM and X-Windows. Booting to runlevel "3" (often called console mode) is often used by servers which do not need a graphical user interface. If booted to init level "3" one can promote the run level with the command [root prompt]# init 5. See the more detailed explanation of run levels below.

    The inittab file will allow you to capture key sequences (ctrl-alt-del), start dial in internet connections etc.

  • One of these process started by init is /sbin/rc. This script runs a series of scripts in the directories /etc/rc.d/rc0.d/, /etc/rc.d/rc1.d/, /etc/rc.d/rc2.d/, etc

  • Scripts in these directories are executed for each boot state of operation until it becomes fully operational. Scripts beginning with S denote startup scripts while scripts beginning with K denote shutdown (kill) scripts. Numbers follow these letters to denote the order of execution. (lowest to highest)


Runlevel "3" will boot to text or console mode and "5" will boot to the graphical login mode ( "4" for slackware)

Runlevel Scripts Directory
(Red Hat/Fedora Core)
State
0 /etc/rc.d/rc0.d/ shutdown/halt system
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services exported
3 /etc/rc.d/rc3.d/ Default text/console only start. Full multiuser
4 /etc/rc.d/rc4.d/ Reserved for local use. Also X-windows (Slackware/BSD)
5 /etc/rc.d/rc5.d/ XDM X-windows GUI mode (Redhat/System V)
6 /etc/rc.d/rc6.d/ Reboot
s or S
Single user/Maintenance mode (Slackware)
M
Multiuser mode (Slackware)

One may switch init levels by issuing the init command with the appropriate runlevel. Use the command "init #" where # is one of s,S,0,1,3,5,6. The command telinit does the same.

The scripts for a given run level are run during boot and shutdown. The scripts are found in the directory /etc/rc.d/rc#.d/ where the symbol # represents the run level. i.e. the run level "3" will run all the scripts in the directory /etc/rc.d/rc3.d/ which start with the letter "S" during system boot. This starts the background processes required by the system. During shutdown all scripts in the directory which begin with the letter "K" will be executed. This system provides an orderly way to bring the system to different states for production and maintenance modes.

If you installed all demons (background processes), Linux will run them all. To avoid slowing down your machine, remove unneeded services from the start-up procedure. You can start/stop individual demons by running service init scripts located in the /etc/init.d/ directory:

  • /etc/rc.d/init.d/ (Red Hat/Fedora) Also /etc/init.d/ which is linked to /etc/rc.d/init.d/
  • /etc/init.d/ (S.u.s.e.)
  • /etc/init.d/ (Ubuntu / Debian)
and issuing the command and either the start, stop, status, restart or reload option i.e. to stop the web server:
  • /etc/init.d/httpd stop

Use the command ps -aux to view all process on your machine.

TIP: List state and run level of all services which can be started by init: chkconfig --list
or
service --status-all | grep running (Red Hat/Fedora Core based systems)

GUI tool: /usr/X11R6/bin/tksysv


Run Level Commands:

Init Script Activation:

Adding a script to the /etc/rc.d/rc#.d/ directory with either an S or K prefix, adds the script to the boot or shutdown process. The scripts are run in numerical order. S20abc is run before S30xyz. The extensibility to the boot and shutdown procedures of the operating system is one of the strengths of UNIX. The orderly sequential initiation of processes can be coordinated for dependent processes. The orderly shutdown of processes is often required of complex programs such as databases. This is how it is done. Individual processes may be monitored, shutdown and started at any time using these scripts. i.e. /etc/rc.d/rc2.d/httpd start. The modifiers start, stop or status may be used.

The start/stop/status scripts actually reside in the directory:

  • /etc/rc.d/init.d/ (Red Hat/Fedora) Also /etc/init.d/ which is linked to /etc/rc.d/init.d/
  • /etc/init.d/ (S.u.s.e. and Ubuntu / Debian)
and are linked to the appropriate directories. These links may be created or destroyed using the chkconfig command. i.e. chkconfig --del httpd will remove the web server from the startup and shutdown process. Inversely chkconfig --add httpd will add it to the startup/shutdown process by generating links from the script in /etc/rc.d/init.d/ to the appropriate /etc/rc.d/rc#.d/ directory. For more information see the LINUX manual page on init.

Basic services include:

System Service Description
anacron Run jobs which were scheduled for execution while computer was turned off. Catch up with system duties.
arpwatch Keeps track of IP address to MAC address pairings
atd Run scheduled batch jobs.
autofs automounts file systems on demand.
bluetooth, pand, hidd, dund Bluetooth netwoork support.
crond Job sheduler for periodic tasks.
gpm Allows console terminal cut and paste. (Non X-window consoles)
https Apache web server.
iptables Firewall rules interface to kernel.
keytable Loads selected keyboard map as set in /etc/sysconfig/keyboard
kudzu New hardware probe/detection during system boot.
lpd or cups Network printer services.
microcode_ctl Uploads microcode to kernel and ultimately to the Intle Pentium processor. (Hardware specific.)
mysqld Database services
named DNS name services (Bind)
network Active network services during system boot. Required for network connectivity.
nfs Network file system. Unix file sharing services. Also uses services: nfslock, portmap, rpcgssd, rpcidmapd, rpcsvcgssd
nscd Password and group lookup services for use with network authentication (NIS, LDAP,...).
ntpd Network Time Protocol time synchronization services.
random Random number generation tool used for encryption.
rawdevices Enables raw IO. Useful for Oracle and software which utilizes this for high speed disk access.
smb SAMBA: MS/Windows PC file sharing services
syslog System log file facility.
ypbind NIS file sharing/authentication infrastructure service.
yppasswd NIS file sharing/authentication infrastructure service.
ypserv NIS file sharing/authentication infrastructure service.
xfs X-Windows font server.

Recommended basic services: anacron, ard, autofs, crond, gpm, iptables, keytable, kudzu, microcode_ctl (Intel32 hardware only), network, random. syslog
Graphics Workstation - add: xfs
File Server for PC clients - add: smb
Print Server - add: lpd or cups (hplip - HP Linux Imaging and Printing)
File server Linux/Unix clients - add: nfs, netfs, nfslock, portmap, ypbind, yppasswd, ypserv; NFSv4 add: rpcgssd, rpcidmapd, rpcsvcgssd
Web Server - add: httpd, tux, xinetdi, sshd


GUI configuration tools:

GUI tools can help you configure the appropriate services to start and provide a description of each service available:
  • Fedora/RHEL: /usr/bin/system-config-services
    (Also /usr/sbin/serviceconf)
  • Red Hat 8.0/9.0: /usr/bin/redhat-config-services
  • Ubuntu / Debian:
    • bum (Boot Up Manager) (GUI image)
    • /usr/bin/services-admin (GUI image)
    • /usr/sbin/sysv-rc-conf (console program - see below)
Red Hat / Fedora Core GUI: system-config-services (and redhat-config-services)

Red Hat/Fedora Core text console services selection tool: /usr/sbin/ntsysv

Debian/Ubuntu: sysv-rc-conf
(Install: aptget install sysv-rc-conf)

Init Script:

A single copy of the script is located in the directory: /etc/rc.d/init.d/script-name (Red Hat/Fedora) or /etc/init.d/script-name (Ubuntu / Debian).
Use the command chkconfig to generate soft links to the appropriate directories for the various run levels.

#!/bin/sh
#
# Startup script for program
#
# chkconfig: 345 85 15 - start or stop process definition within the boot process
# description: Description of program
# processname: process-name
# pidfile: /var/run/process-name.pid

# Source function library. This creates the operating environment for the process to be started
. /etc/rc.d/init.d/functions

case "$1" in
start)
echo -n "Starting process-name: "
daemon process-name - Starts only one process of a given name.
echo
touch /var/lock/subsys/process-name
;;
stop)
echo -n "Shutting down process-name: "
killproc process-name
echo
rm -f /var/lock/subsys/process-name
rm -f /var/run/process-name.pid - Only if process generates this file
;;
status)
status process-name
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading process-name: "
killproc process-name -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0

The bash script functions daemon, killproc and status can all be found in the script /etc/rc.d/init.d/functions. (Red Hat/Fedora distributions)


The script must be executable to work. (chmod +x script-name).

The script may be used to start and stop processes. i.e.:

  • /etc/rc.d/init.d/httpd restart
    (Ubuntu / Debian / S.u.s.e.: /etc/init.d/apache2 restart)
  • /etc/rc.d/init.d/httpd stop
  • /etc/rc.d/init.d/httpd start
OR use the Red Hat/Fedora core based service command:
  • service httpd restart
  • service httpd stop
  • service httpd start

Note that two lines in the script enable the chkconfig command to control the script for the boot and shutdown process.

# chkconfig: 345 85 15
# description: Description of program

When added to the boot process using the "chkconfig --add script-name" command the start order/priority will be set to 80 while the stop/shutdown order will be set to 15. The process will be added to runlevels 3, 4 and 5. This is enabled by generating links from the location of the script (/etc/rc.d/init.d/) to the directory for the appropriate run level: /etc/rc.d/rc#.d/. The file name in the run level directory will reflect if it is used for boot (starts with an "S") or shutdown (starts with a "K")

chkconfig:

The (Red Hat/Fedora/IRIX) chkconfig command generates and breaks links between the directory /etc/rc.d/init.d/ and the appropriate run level directory: /etc/rc.d/rc[0-6].d/ to control boot process initiation and process shutdown.

     chkconfig [--level ]  on | off | reset >
chkconfig --list
chkconfig --list
chkconfig --add

chkconfig --del
chkconfig --level 0123456 off

Examples:

  • chkconfig --level 345 httpd on - forces apache to be invoked for run levels 3, 4 and 5.
  • chkconfig --add httpd - Start the web server daemon upon system boot.
  • chkconfig --del sendmail - Do not start the sendmail daemon upon system boot.
  • chkconfig --list - List all services and init levels.
  • chkconfig --list | grep on - List all services to be started upon system boot.

Using chkconfig to administer xinetd processes.

  • chkconfig wu-ftpd on - Turn on FTP service managed by xinetd.
  • chkconfig ipop3 off - Turn off POP3 service managed by xinetd.
This will reconfigure the appropriate xinetd file (in directory /etc/xinetd.d/) and restart the xinetdprocess.

Also see: chkconfig - Linux man page.

Related Commands:

service Display status of system services.
Example: service --status-all
Help: service --help

Also see: service - Linux man page.

Links and resources:

unix windows command conversion


DOS Command UNIX or Bash Command Action
DIR ls -l (or use ls -lF)(-a all files)
(df -k Space remaining on filesystem)
List directory contents
DIR *.* /o-d
DIR *.* /v /os
DIR /s
DIR /aa
ls -tr
ls -ls
ls -R
ls -a
List directory contents by reverse time of modification/creation.
List files and size
List directory/sub-directory contents recursively.
List hidden files.
TREE ls -R List directory recursivly
CD cd Change directory
MKDIR
MD
mkdir Make a new directory
ASSIGN ln Create a file or directory link
RMDIR
RD
rmdir Remove a directory
CHDIR pwd Display directory location
DEL
ERASE
rm -iv Remove a file
RMDIR /S (NT)
DELTREE (Win 95...)
rm -R Remove all directories and files below given directory
COPY cp -piv Copy a file
XCOPY cp -R Copy all file of directory recursivly
RENAME or MOVE mv -iv Rename/move a file
TYPE cat Dump contents of a file to users screen
MORE more Pipe output a single page at a time
HELP or COMMAND /? man Online manuals
CLS clear
ctrl-l
Clear screen
EXIT
EXIT0
exit
exit 0
Exit a shell
FIND
FINDSTR
grep Look for a word in files given in command line
COMP diff Compare two files and show differences. Also see comm, cmp, mgdiff and tkdiff.
FC diff Compare two files and show differences. Also see comm, cmp, mgdiff and tkdiff.
SET set and env List all environment variables
SET variable=value
echo %variable%
set

export variable=value
echo $variable

Set environment variables
Show environment variables
ECHO text echo text Echo text to screen
SET variable setenv (for C shell) or export VAR=val (for Korn shell. Also VAR=val) Set environment variables
PATH
PATH %PATH%;C:\DIR
echo $PATH
PATH=$PATH:/dir
Display search path for executables.
Set PATH environment variable.
PROMPT $p$g export PS1='\h(\u)\W> ' Set user command prompt.
DATE or TIME date Show date. (also set date - DOS only)
DOSKEY /h history List command history
DOSKEY NAME=command alias NAME=command Set command alias
BREAK ON trap Trap ctrl-break / Trap signals.
SORT sort Sort data alphabetically/numerically
EDLIN ed Line mode editor
EDIT filename.txt pico, gnp, vi, xedit, xemacs,dtpad Edit a file. The Linux editor which looks most like DOS edit is probably Pico. (Not a recomendation!)
BACKUP files A:\ tar -cvf /dev/fd0 files
mdir, mcopy
doswrite -a file (AIX only)
Save files to floppy.
See Using DOS floppies
RESTORE A:\ files tar -xvf /dev/fd0 files
mdir, mcopy
dosread -a file (AIX only)
Read files from floppy.
See Using DOS floppies
ATTRIB [+r|-r] [+a|-a] [+s|-s] [path\file] /s chmod Change file permissions. DOS: +:set to -:remove r:Read only a:Archive s:System /s:recursively
ATTRIB +h or -h mv file .file Change file to a hidden file - rename file with prefix "."
PRINT lpr Print a file
CALL
COMMAND /C (DOS), CMD (NT)
source script (cshrc)
. script (bash)
sh script
Execute script from within batch shell.
MEM free
top
Show free memory on system
TASKLIST (WIN2K, XP) ps -aux
top
List executable name, process ID number and memory usage of active processes
MSD lsdev Show system info (Command borrowed from AIX)
SCANDISK
DEFRAG C:
fsck
debugfs
Check and repair hard drive file system
CHDISK du -s Disk usage.
FDISK fdisk Tool to partition a hard drive.
SUBST V: C:\directory\path mount Mount a drive letter to a folder/directory on your hard drive.
FORMAT mke2fs
See: fdformat and mformat for floppies
Format drive file system.
For floppy drive use see YoLinux Tutorial Using DOS Floppies with Linux
VER uname -a
echo $SHELL
cat /etc/issue
Operating system/shell version
pkzip tar and zip Compress and uncompress files/directories. Use tar to create compilation of a directory before compressing. Linux also has compress, gzip
HOSTNAME hostname Print host name of computer
PING ping Send packets to a network host
TRACERT traceroute Show routes and router hops to given network destination.
IPCONFIG (NT)
WINIPCFG (Win 95...)
ifconfig Display/configure network interface
NBTSTAT (Netbios info: -n, -c)
NBTSTAT -A IP-address
nslookup host-name
host host-name
Print DNS info for host.
NBTSTAT -a hostname nmblookup -A hostname lookup NetBIOS names.
ROUTE PRINT route -n Print routing table.
NET HELP START chkconfig --list |grep on List services.
NET STARTservice-name
NET STOPservice-name
service service-name start
service service-name stop
Start/stop service/daemon.
NET SHARES df Show mounted shares/filesystems.
NET SEND (NT) smbclient -M MS-Windows-host-name
talk
Send pop-up to a MS/Windows PC
Send message to another Unix/Linux user. See YoLinux tutorial
WIN startx Start X-Windows.
REBOOT shutdown -r now Reboot system.

To find out how to do something on UNIX simply type "man -k subject_matter". This will do a key word search for all commands dealing with the subject matter. Then use the appropriate command. Online manuals are available on all the commands by typing "man command_name".

MS/Windows info:


Shell Descriptor/Operators:

DOS Descriptor/Operator UNIX or Bash Descriptor/Operator Description
\ / Directory path delimiter
.\ ./ Current directory
..\ ../ Parent directory
ctrl-z ctrl-d End of file/close shell
ctrl-c ctrl-c Interrupt/process break
* * file name wild card
? ? Single character wild card
%VAR% $VAR Variable prefix
%1 %2 %3 $1 $2 $3 First, second and third shell command line arguments.
/ - Command line option flag prefix
| | Pipe
> > stdout redirection
>> >> stdout redirection overwrite
< < stdin redirection


Shell Script Operators:

DOS Operator UNIX or Bash Operator Description
@
ECHO OFF
set +v Set verbose mode off. -v: Echo each line of shell script as it is executed.
% $ command line argument prefix. DOS: %1 Bash: $1 for firs argument.
REM # Comment. (Not processed.)
== = string "equal to" comparison
!==! != string "not equal to" comparison
NOT ! negative of test expression
CHOICE case case/switch statement
IF

IF EXIST C:\filename

IF NOT EXIST C:\filename

if [[ test-resulting-in-bool ]];
then
...
elif ...;
then
...
else
...
fi

if [ -e /dir/filename ];
then

if [ ! -e /dir/filename ];
then

if-test

If file exists

If file does not exist.

GOTO ABC
...
:ABC
goto ABC
...
:ABC
Branch
FOR ... IN ... DO

FOR %%fff IN (C:\dir\*.*)
DO echo %%fff

for ffiillee in lliisstt;
do ...;
done

for (( expr1; expr2; expr3; ))
do ...;
done

For loop
ERRORLEVEL $? exit status/return code
PAUSE sleep sleep for specified interval


Bash shell aliases for DOS users:

The following are bash shell aliases which can be added to the system profile or the user's personal profile ($HOME/.bashrc) to correct and help DOS users on Linux.

alias dir="echo 'Use the command: ls -lF'"

alias tree="echo 'Use the command: ls -R'"
alias del="echo 'Use the command: rm -iv'"
alias move="echo 'Use the command: mv -iv'"
alias rename="echo 'Use the command: mv -iv'"
alias copy="echo 'Use the command: cp -piv'"
alias type="echo 'Use the command: cat'"
alias cls="echo 'Use the command: clear'"
alias mem="echo 'Use the command: free'"
alias ver="echo 'Use the command: uname -a'"
alias A:="echo 'Use the command: mdir a:'"
alias a:="A:"
alias C:="echo 'No C drive in Linux. Go to your home directory with the command: cd'"
alias c:="C:"


Devices:

DOS Device Linux Device Description
NUL /dev/null Send into nothingness
CON stdin stdin from console
PRN
LPT1
/dev/lp0 First printer device
COM1 /dev/ttyS0 Firsst serial port


Equivalent Linux and MS/Windows GUI Applications:

MS/Windows Command Linux Command Description
C:\WINDOWS\cmd gnome-terminal
konsole
Command Text Terminal
C:\WINDOWS\explorer nautilus --no-desktop File browser
c:\Program Files\Internet Explorer\iexplore firefox
mozilla
Web browser
C:\WINDOWS\notepad
C:\Program Files\Windows NT\Accessories\wordpad
gedit Text editor
C:\Program Files\Microsoft Office\Office10\winword
excel
powerpnt
oowriter
oocalc
ooimpress
MS/Office and Open Office suites (ooffice)
C:\Program Files\Adobe\Acrobat 7.0\Reader\acrord32 acroread Adobe PDF viewer
mspaint tuxpaint
xfig
gimp
Graphics and painting program
C:\Program Files\WinZip\winzip32 file-roller File compress / decompress / pack / unpack
taskmgr ksysguard
qps
gnome-system-monitor
xosview
Process and system load monitor


YoLinux Tutorials:

Links: