Ref : B32068-01 (B15697-01), Oracle on Solaris Cheat Sheet (by James L.

Colestock), Sun Documentation ***Very helpful to know how to edit configure files vi terminal session using vi commands - see Appendix 1*** Step 1 - Verify OS

Step 2 - verify exectables are present --> /usr/ccs/bin: make, ar, ld, nm Step 3

Logging In to the System as root Check 1 - Checking the Hardware Requirements - Memory Requirements At least 1 GB of RAM --> /usr/sbin/prtconf | grep "Memory size" or

Step 4 - relationship between installed RAM and the configured swap space


Swap Space 1.5 times the size of RAM Equal to the size of RAM 0.75 times the size of RAM

Between 1024 MB and 2048 MB Between 2049 MB and 8192 MB More than 8192 MB

To determine the size of the configured swap space --> /usr/sbin/swap -s

The following examples shows how to create a 24 Mbyte swap file called /files/swapfiles.
# # # # mkdir /files mkfile 24m /files/swapfile (***wait - time delay***) swap -a /files/swapfile vi /etc/vfstab

(An entry is added for the swap file): /files/swapfile swap # swap -l swapfile dev swaplo blocks free /dev/dsk/c0t2d0s1 32,17 8 205624 192704 /files/swapfile 8 40952 40952



The following examples shows how to delete the /files/swapfile swap file.
# swap -d /files/swapfile # (Remove the deleted swap entry from the /etc/vfstab file) # rm /files/swapfile # swap -l swapfile dev swaplo blocks free /dev/dsk/c0t2d0s1 32,17 8 205624 192720

Adding a Swap File on Solaris Use mkfile to create a file suitable for a local swap area. For example, to create a 1GB swap file:
/usr/sbin/mkfile 1024m /swap

where /swap is the name of the file to be used as swap space. Units for the size can be kilobytes (k), blocks (b), or megabytes (m). Tell the system to start using the file as swap:
/usr/sbin/swap -a /swap

Use swap -l to verify that the swap file has been activated

Step 4 - Disk space requirements - 225-275 mb space / tmp dir

Between 225 and 275 MB of disk space in the /tmp directory To determine the amount of disk space available in the /tmp directory, enter the following command: On Solaris 10:
# df -h /tmp # df -k /tmp Size Swap 2.0G Used 52K Avail 2.00G Capacity 1% Mounted On /tmp

Other Solaris operating systems:

Step 5 - Disk space requirements - free space

To determine the amount of free disk space on the system, enter the following command: On Solaris 10:
# df -h # df -k

Other Solaris operating systems:

The following table shows the approximate disk space requirements for software files for each installation type:
Installation Type Enterprise Edition Standard Edition Custom (maximum) Requirement for Software Files (GB) 4.68 4.62 4.71

Between 1.5 GB and 2 GB of disk space is required for preconfigured database that uses file system storage (optional)
Step 6 - Insufficent space..need to create additional space via new disk.

Steps Involved

- Create a VM Virtual Disk (IDx) - Create a partition format disk

Disk 0

Disk 1

Disk 2

should appear, if not try ...touch /reconfigure; init 6 or devfsadm -v reboot create partition --> p (run fdisk first) (be extra careful - with regard cylinders !!!) (configuration below, not best pratice) save --> within partition>label Disk 0

Disk 1

Disk 2


- Create a file system. # newfs /dev/dsk/cod1s0 (*** note 0 - root, 1 - swap) - Create a mount point (, if it does not already exist) (need be called /u0X - X=1,2,3..) mkdir /oracle (empty dir) mount /dev/dsk/cod1s0 /oracle enter path in /etc/vfstab


Step 7 - Software Requirements - OS

The following are the operating sytem requirements for Oracle Database 11g Release1:
■ ■

Solaris 9 Update 7 Solaris 10

To determine the distribution and version of Solaris installed, enter the following command:
# uname -r 5.10

Step 8 - Software Requirements - Package Requirements
Item Requirement


The following packages (or later versions) must be installed: SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt SUNWsprox Note: The SUNWsprox package is not supported on Solaris 10. You may also require additional font packages for Java, depending on your locale. Refer to the following Web site for more information: 4.2/font-requirements.html

To determine whether the required packages are installed, enter commands similar to the following:
# pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWsprot \ SUNWsprox SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt

If a package is not installed, then install it. (All packages are on Solaris CD which you can buy £20+)

# pkgadd -d /cdrom/name_of_disk/solaris_10/product SUNWi1cs NB Configure VW Ware CD point to correct CD ! ***

Step 9 - Software Requirements - Compiler Requirements Step 9A

gcc 3.4.2 (Solaris

package name is SUNWgcc)

Sun ONE Studio 8 (C and C++ 5.5) --both not on web --> gcc 3.4.6 gcc already installed, part of Solaris 10 !!! (learnt hard way(dont ask....)) appears in directory -->


Thus, need to add to $PATH (add it..) -------------------------------------------------------------------------------

Quick Notes on Packages in Solaris
--> Don't create any target directory. --> The pkgadd command will do it for you. --> And don't create temporary directories in locations that belong to the OS, like /usr. --> Use /tmp, /var/tmp, your home directory or top level non standard directories (eg: /software) for your temporary files. Create folder/subfolders -->/usr/local/bin & /usr/ccs/bin (if they don't exist) Unzip file and copy to /tmp or burn to cd (VM Ware)

After that I installed the libiconv package first, since that is a requirement.
pkgadd -d /(location)/libiconv-1.9.2-sol10-sparc-local
if it asks to overwrite any files -

n (y most times), then continue

Then I installed gcc (already installed)

pkgadd -d /(location)/gcc-346-sol10-x86-local

To remove the installed package SMCgcc from a system, run this command as root: pkgrm SMCgcc Need to update $PATH I do "echo $PATH" and get the following: /usr/sbin:/usr/bin:/usrdt/bin:/usr/opwnwin/bin/usr/ucb There's an existing file /etc/.profile on my Solaris 10 system, so I added the following to that file: (ref : PATH=$PATH:/usr/local/bin:/usr/ccs/bin/:/usr/local/bin/gcc; export PATH

Save and restart (terminal) gcc - version (cannot execute)

using gcc from os (plus set $PATH to executable) --> gcc : no input file ignore

Quick Notes on Compressed Applications in Solaris unzip using gzip -d lsof-4.77-sol10-sparc-local.gz in the same dir you unzzipped it, then execute pkgadd -d . pkg name or gunzip package-file.gz # equivalent to "gzip -d" pkgadd -d package-file or download bunzip2 from web and use or use file roller application (already installed) to extract file manually, not terminal session

Step 9B

--> Install Sun Studio 12 Copy file to /tmp (when you restart file disappears !) So, copied file to /Oracle/downloads/SunStudio12 (make sure plenty space > .5gb size) use file roller to unzip or
# /usr/local/bin/bunzip2 studio11 -sol-sparc.tar.bz2 # tar -xvf studio11-sol-sparc.tar

Then, terminal , root /(location)/Installer (it worked for me, without changing anything in environment) Location install --> /opt (changed to /oracle/opt plus created sub-folder opt) Selected pre-requirements, install patches & fixes.

You will have to make sure your environment has all the appropriate references to java in it; here is my environment before launching the installer:
# env CLASSPATH=/usr/j2se/jre/lib:/usr/j2se/lib DISPLAY= HOME=/ JAVA_HOME=/usr/j2se/jre LOGNAME=root PATH=/usr/j2se/jre/bin:/usr/bin:/bin:/usr/sbin:/sbin SHELL=/sbin/sh SSH_CLIENT= 2746 22 SSH_TTY=/dev/pts/1 TERM=vt100 TZ=US/Pacific USER=root # ./installer Aug 11, 2006 1:52:58 PM java.util.prefs.FileSystemPreferences$2 run INFO: Created user preferences directory.

but I add after install complete
# PATH=/oracle/opt/SUNWspro/bin:$PATH; export PATH (/etc/profile) restart

Afterwards, I check to see if sunstudio launches without fail via:
# sunstudio
Step 10 - Patch Requirements - Compiler Requirements
Orginial Requirements 127111-02 SunOS 5.10: libc patch For Solaris 10: 117837-05: C++ compiler optimizer patch 117846-08: C++ compiler Optimization patch 118682-01 Patch Site 127111-02 117837-05 117846-08 118682-01 Obsolete Obsolete Obsolete Latest Latest Latest Latest 118682-01 127127-11 117837-08 117846-19

Copy Patch to required location (if using CD burn using Nero) /oracle/downloads/patches/

terminal cd /oracle/downloads/patches/patch_number unzip reload rm patchadd patch_number patchadd -p patchadd -p | grep 111713 (without rev no) --> /usr/sbin/patchadd.... showrev -p | grep 111713 reboot ********* (after each patch...............)
Step 11 - Checking the Network Setup - Configuring Name Resolution

VMWare server - Solaris Name IP Address gwwpcSOLARIS

The following command should yield an entry for ‘files’:
# cat /etc/nsswitch.conf | grep hosts # "hosts:" and "services:" in this file are used only if the hosts: files

Oracle recommends that the following command return a fully-qualified hostname, however, mine does not:
# hostname gwwpcSOLARIS

Oracle recommends that the following command return nothing:
# domainname

Here is the contents of my /etc/hosts file:
# more /etc/hosts # # Internet host table # gwwpcSOLARIS localhost ----------------------------------------------------------------------Future Reference Virtual Network IP Address of Host

Virtual Network - Summary



----------------------------------------------------------------------Step 12 - Creating Required Operating System Groups and Users

--Create OSDBA group (dba) groupadd dba (or /usr/sbin/groupadd dba) --Create Oracle Inventory Group Check if exists #more /var/opt/oracle/oraInst.loc groupadd oinstall --Create OSOPER group (optional) groupadd oper (or /usr/sbin/groupadd oper) --Create Directory mkdir /home/oracle (assume u have space) mkdir /oracle/home/oracle

--Check Oracle software owner user exists Check if exists id -a oracle --Create Oracle software owner user useradd -g oinstall -G dba,oper oracle usermod -g oinstall -G dba,oper -d /oracle/home/oracle -s /bin/bash -c "Oracle Software Owner" oracle usermod -g dba -G oinstall,oper -d /oracle/home/oracle -s /bin/bash -c "Oracle Software Owner" oracle id -a oracle chown oracle:dba /oracle/home/oracle passwd -r files oracle

(change pwd)

Modify is the similar command...usermod -g oinstall -G dba,oper oracle
--Check User nobody exists id -a nobody if not, create useradd -g nobody
Step 13 - Configuring Kernel Parameters on Solaris 10

Parameter noexec_user_stack semsys:seminfo_semmni semsys:seminfo_semmn s

Replaced by Resource Control NA 2. project.maxsem-ids NA

Recom mende d Value 1 100 1024

semsys:seminfo_semmsl semsys:seminfo_semvm x shmsys:shminfo_shmma x shmsys:shminfo_shmmn i

project.maxsem-nsems NA 1. project.maxshm-memory project.maxshm-ids

256 32767 429496 7296 100


When you use the prctl command (Resource Control) to change system parameters, you do not need to restart the system for these parameter changes to take effect. However, the changed parameters do not persist after a system restart. To view current values

Resource Control Temp
1. (assume ram 2g - half that) Before


2. Before



purgatorio# projadd -p 10000 -c 'test project' -U jqpublic test purgatorio# grep ^test: /etc/project test:10000:test project:jqpublic::

(Note that projadd and projmod won't let you change the resource-control field.) This project is named "test" and has a project ID of "10000". Membership is restricted to the user "jqpublic," and any project running in the test project will not be allowed to create a file greater than 16MB (16MB = 16,777,216 bytes). projadd -p 100 -c "Oracle default" -g dba

By default, Oracle instances are run as the oracle user of the dba group. A project with the name group.dba is created to serve as the default project for the oracle user. Run the command id to verify the default project for the oracle user: su - oracle id -p

# projmod -sK "project.max-shm-memory=(privileged,4g,deny)" group.dba

Parameter noexec_user_stack semsys:seminfo_semmni semsys:seminfo_semmns semsys:seminfo_semmsl semsys:seminfo_semvmx shmsys:shminfo_shmmax shmsys:shminfo_shmmni

Replaced by Resource Control NA project.max-sem-ids NA project.max-sem-nsems NA project.max-shm-memory project.max-shm-ids

Recommended Value 1 100 1024 256 32767 4294967296 100

Projmod Command projmod -sK "project.max-sem-ids=(privileged,100,deny)" group.dba projmod -sK "project.max-sem-nsems=(privileged,256,deny)" group.dba projmod -sK "project.max-shm-memory=(privileged,4g,deny)" group.dba projmod -sK "project.max-shm-ids=(privileged,100,deny)" group.dba

Check the values

or su - oracle id -p prctl -n project.max-shm-memory -i process $$ (run command su - oracle) set set set set semsys:seminfo_semmni=100 semsys:seminfo_semmsl=256 shmsys:shminfo_shmmax=4294967295 shmsys:shminfo_shmmni=100

The Oracle installer recognizes kernel parameters set using this method, but it is now deprecated in favour of resource control projects, explained below. As the root user, issue the following command.
projadd oracle

Append the following line to the "/etc/user_attr" file.

If you've performed a default installation, it is likely that the only kernel parameter you need to alter is "max-shm-memory". To check the current value issue the following command.
# prctl -n project.max-shm-memory -i project oracle project: 100: oracle NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 254MB deny -






To reset this value, make sure at least one session is logged in as the oracle user, then from the root user issue the following commands.
# prctl -n project.max-shm-memory -v 4gb -r -i project oracle # projmod -s -K "project.max-shm-memory=(priv,4gb,deny)" oracle

The first dynamically resets the value, while the second makes changes to the "/etc/project" file so the value is persistent between reboots.
# cat /etc/project system:0:::: user.root:1:::: noproject:2:::: default:3:::: group.staff:10:::: oracle:100::::project.max-shm-memory=(priv,4294967296,deny) #

The Oracle installer seems incapable of recognising kernel parameter set using resource control projects, but if you ignore the warnings the installation completes successfully.
Step 14 - Identifying Required Software Directories
--> --> --> Oracle Base Directory Oracle Inventory Directory Oracle Home Directory

Oracle Base Directory (ORACLE_BASE)
top-level c:\oracle e.g. /mount_point/app/oracle_sw_owner - mount_point - oracle_sw_owner - Oracle - Oracle

Oracle Inventory Directory
ORACLE_BASE/oraInventory (installer creates it..)

Oracle Home Directory
ORACLE_BASE/product/11.1.0/db_1 (installer creates it..)

Creating an Oracle Base Directory From Scrath
Check free disk space # df -h /tmp or # df -k /tmp # df -h /oracle 1.

# mkdir -p /mount_point/app/oracle_sw+owner # mkdir -p /oracle/app/oracle 2. # chown -R oracle:oinstall /mount_point/app/oracle_sw+owner # chown -R oracle:oinstall /oracle/app/oracle 3. # chmod -R 775 /mount_point/app/oracle_sw_owner # chmod -R 775 /oracle/app/oracle

Identify Oracle Inventory Directory # more /var/opt/oracle/oraInst.loc Identify Oracle Home Directory # more /var/opt/oracle/oratab

Creating Directories for Oracle Database or Recovery File
Check free disk space # df -h /tmp or # df -k /tmp # df -h /oracle

File System Requirements for 11g
Datafile Files Recovery Files > 1.2 GB of free disk space > 2.4 GB of free disk space

ORACLE_BASE --> /oracle/app/oracle (/mount_point/app/oracle_sw_owner) (windows d:\app\Ackers) 4. Database File & # mkdir -p /mount_point/app/oracle_sw_owner/oradata # mkdir -p /oracle/app/oracle/oradata 5. # chown -R oracle:oinstall /mount_point/app/oracle_sw_owner/oradata # chown -R oracle:oinstall /oracle/app/oracle/oradata 6. # cdmod -R 775 /mount_point/app/oracle_sw_owner/oradata # chmod -R 775 /oracle/app/oracle/oradata 7. Recovery File Directory # mkdir -p /mount_point/flash_recovery_area # mkdir -p /oracle/app/oracle/flash_recovery_area 8. # chown -R oracle:oinstall /mount_point/flash_recovery_area

# chown -R oracle:oinstall /oracle/app/oracle/flash_recovery_area 9. # chmod -R 775 /mount_point/flash_recovery_area # chmod -R 775 /oracle/app/oracle/flash_recovery_area 10. (oracle 1g) # mkdir /var/opt/oracle # chown oracle:oinstall /var/opt/oracle # chmod 755 /var/opt/orac;e
Step 15 - Configuring Oracle User's environment
Clear as mud !!!!! SUMMARY --> su - oracle

Set default file mode creation mask (unmask) to 022 in shell startup file. Set DISPLAY environment variable

$ su - oracle $ echo $SHELL (default shell) $ vi .bash_profile unmask 022 remove any environment variables for ORACLE. save and exit . ./.bash_profile (run shell startup script) # df -h /tmp or df -k /tmp (optional) $ sudo mkdir /mount_point/tmp $ sudo chmod a+wr /mount_point/tmp $ exit next, $ TMP=/mount_point/tmp $ TMPDIR=/mount_point/tmp $ export TMP TMPDIR next, $ ORACLE_BASE=/Oracle/app/oracle $ ORACLE_SID=VWS01 $ export ORACLE_BASE ORACLE_SID next, $ unset ORACLE_HOME $ unset TNS_ADMIN verify $ umask $ env | more If you get DISPLAY errors, check root ***** DISPLAY= export DISPLAY xhost + Result

su - oracle cd .. . /runInstaller Custom No database created

Need to run script as root. Install installs cluster services daemon.
Step 16 - Install Latest Patch Set
If 64 bit, sparc.

The script that you ran as root during the installation process started a cluster services daemon that runs as the root user. We will need to stop this daemon before we can apply the Oracle patch set. Oracle only needs the cluster services daemon on database servers that use Oracle’s Automatic Storage Management (ASM) or Real Application Clusters (RAC). Since we will not be using either of these facilities, there will be no need to have this daemon run at all. We cannot simply kill the daemon, because the script added a “respawn” entry to the inittab. (If we kill the daemon, the operating system will restart it.) To stop the cluster services daemon and prevent it from restarting immediately or when the server is rebooted in the future, we will need to restore the inittab to is previous state. Luckily, the script preserved a backup copy before editing the inittab. First, doublecheck that the backup copy of inittab is identical to the real inittab except for the one entry added by the script:
$ diff /etc/inittab.orig /etc/inittab

Next, run the following commands very carefully as root:
$ $ $ $ mv /etc/inittab.orig /etc/inittab /etc/init.d/init.cssd stop mv /etc/rc3.d/S96init.cssd /etc/rc3.d/_S96init.cssd mv /etc/rc3.d/K96init.cssd /etc/rc3.d/_K96init.cssd

But, 32 bit

Generates cannot execute - 64bit, not 32 bit.

Step 17 - Update oraenv script
ORACLE_BASE=/Oracle/app/oracle ORACLE_HOME=/Oracle/app/oracle/product/10.2.0/db_1

Where are oraenv and coraenv found and how do they get created on various Unix platforms? These scripts are used to allow the DBA to set a common environment for all users and make it easier for users to move between databases. By setting the variable "ORAENV_ASK" to yes, the user will be prompted to enter the <SID> value of the database they would like to access. If "ORAENV_ASK" is set to no, the current value of "ORACLE_SID" will be used. Next, the script 'dbhome' is called to determine the "$ORACLE_HOME" for that SID and set "$ORACLE_HOME" to the corresponding value. 'dbhome' will also add "$ORACLE_HOME/bin" to the user's PATH and on some platforms (such as Digital UNIX), it will run "ULIMIT". These scripts can usually be found in: /usr/local/bin, $ORACLE_HOME/bin HP-UX /usr/bin, $ORACLE_HOME/bin Solaris, AIX Both oraenv and coraenv are created during install and copied to your "/usr/local/bin" when "" is run during post installation steps. Use oraenv when you are using the Bourne and Korne Shells. Use coraenv when you are using the C shell. These scripts perform the same functions, but are designed for the different shells.

Step 18 - Create Database
root DISPLAY= export DISPLAY xhost + su - oracle check variables ORACLE_BASE, ORACLE_HOME, ORACLE_SID cd $ORACLE_HOME/bin ./dbca create database.... ORACLE_SID not picked up but ORACLE_BASE, ORACLE_HOME is.

Configure Database Listener NetManager SQLPlus
create pfile from spfile; Check Oracle environment ORACLE_SID ORAENV_ASK=NO export ORAENV_ASK Check --> /var/opt/oracle/oratab

--> lsnrctl start, status --> netmgr


Step 18 - Startup and shutdown

To make the database and listeners start up automatically when the server reboots and shut down automatically when the server shuts down, you’ll need to create a dbora file in /etc/init.d and link it to /etc/rc2.d and /etc/rc0.d. You’ll need to do this as the root user. First create a file called dbora in /etc/init.d as follows:
#!/bin/sh ORA_HOME=/u01/app/oracle/product/10.1.0/db_1 ORA_OWNER=oracle if [ ! -f $ORA_HOME/bin/dbstart ]

then echo "Oracle startup: cannot start" exit fi case "$1" in 'start') # Start the Oracle databases and listeners su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole" su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl start" ;; 'stop') # Stop the Oracle databases and listeners su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl stop" su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" ;; esac

rc2.d means the directory which contains scripts which will be executed in run-level 2 and so on. S99dbora means S-start script 99-unique number K10dbora means K-kill (stop) script 10-unique number After creating the dbora file, you need to link it to /etc/rc2.d and /etc/rc0.d:

ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora

l -- l (next 2 k)
Appendix - 1 Summary of Basic vi Commands

The following table provides a convenient reference for basic vi commands. Table 6-1 Basic vi Commands

Command Starting vi
vi vi vi -r view



Open or create file Open new file to be named later

filename filename

Recover crashed file Open file read-only

Cursor Commands
h j k l w W b B e Return Back Space Space Bar H M

Move left one character Move down one line Move up one line Move right one character Move right one word Move right one word (past punctuation) Move left one word Move left one word (past punctuation) Move to end of current word Move down one line Move left one character Move right one character Move to top of screen Move to middle of screen

L Ctrl-F Ctrl-D Ctrl-B Ctrl-U

Move to bottom of screen Page forward one screen Scroll forward one-half screen Page backward one screen Scroll backward one-half screen

Inserting Characters and Lines
a A i I o O

Insert characters to right of cursor Insert characters at end of line Insert characters to left of cursor Insert characters at beginning of line Insert line below cursor Insert line above cursor

Changing Text
cw cc C s r r Return J xp ~ u U :u

Change word (or part of word) to right of cursor Change line Change from cursor to end of line Substitute string for character(s) from cursor forward Replace character at cursor with one other character Break line Join current line and line below Transpose character at cursor and character to right Change case of letter (upper or lower) Undo previous command Undo all changes to current line Undo previous last-line command

Deleting Text

x X dw dd D dG d1G :5,10 d

Delete character at the cursor Delete character to the left of the cursor Delete word (or part of word to right of cursor) Delete line containing the cursor Delete part of line to right of cursor Delete to end of file Delete from beginning of file to cursor Delete lines 5-10

Copying and Moving Text
yy Y p P :1,2 co 3 :4,5 m 6

Yank or copy line Yank or copy line Put yanked or deleted line below current line Put yanked or deleted line above current line Copy lines 1-2 and put after line 3 Move lines 4-5 and put after line 6

Setting Line Numbers
:set nu :set nonu

Show line numbers Hide line numbers Setting Case-sensitivity

:set ic :set noic

Searches should ignore case Searches should be case-sensitive

Finding a Line
G 1G 21G

Go to last line of file Go to first line of file Go to line 21

Searching and Replacing

Search for string

?string n N

Search backward for string Find next occurrence of string in search direction Find previous occurrence of string in search direction Search and replace

:g/search/s//replace/g Clearing the Screen

Clear (refresh) scrambled screen

Inserting a File into a File

filename filename

Insert (read) file after cursor Insert file after line 34

:34 r

Saving and Quitting
:w :w

Save changes (write buffer) filename Write buffer to named file Save changes and quit vi Save changes and quit vi Quit without saving changes

:wq ZZ :q!

Appendix - 2 Commands 1.Copy file cp /location/orig_file /location/new_file 2.Changing

File Ownership

chown user:group /location 3. . --> means hidden 4. # --> root 5. $ --> user 29.html 56472554+28353475&threadId=32769

Sign up to vote on this title
UsefulNot useful