50 unix/linux commands for the new dba





These are the 50 linux/unix commands/terminologies that a new dba should know.
The list here will be updated regularly.. so even if it is not 50 at the moment … it will be soon:-)

1)Which tool do you use to connect to a unix environment?
putty(download it free from the internet) , winscp(free tool that can be used to copy files between a windows server and a unix server and back)

2)what is cd ?
use this command to change into a directory.

3)cd to current directory ,
cd .
cd .. goes to the parent directory

4)cd to a particular directory ,
cd /global/oracle/test means we are going into the /global
/oracle/test directory.

5)what is su ?
i log into a unix server as root.it asks me password and i enter the
root password.now i want to convert myself into a different user.
so i use the below command
su – username
immediately i get converted into a different user and my
environment is set with the proper privileges that were configured
by the unix sys admin for this user.

6)su to oracle user ,
su – oracle
remember that before you switch to a different user that user
should be already created on the server by the sysadmin.

7)su to any other user ,
su – username

8)what is root user ,
the main user who has complete admin privileges and owned by the
unix administrator.

9) what is env ,
after logging into the unix server type env . that will give the
environment variables that are defined on the server
HOME=/computerhope/public_html
PATH=/usr/local/bin:
LOGNAME=admin
HZ=100
TERM=vt100
TZ=MST7MDT
SHELL=/bin/csh
MAIL=/var/mail/computerhope
_INIT_UTS_PLATFORM=SUNW,SPARCstation-10
_INIT_UTS_RELEASE=5.7
_INIT_UTS_SYSNAME=SunOS
_INIT_UTS_VERSION=Generic_106541-08
EDITOR=pico -t
OPENWINHOME=/usr/openwin
MANPATH=/usr/man:/usr/local/man:/usr/openwin/man
LD_LIBRARY_PATH=/usr/local/lib:/usr/openwin/lib
PAGER=more

10)what is oraenv ,
this link has good information

11)what is .profile ,
.profile is the shell startup file, like autoexec.bat is the startup file
for DOS users; .profile will get executed whenever you login. It is
used to set environment variables and shell options such as $PATH

In ksh (Unix Korn shell) .profile will be in each home directory of
each user.

For example :
/home/dbuser/.profile
/home/joeuser/.profile

12)how do you see hidden files in a directory,
ls -la

13)what are unix environment variables ,
see point 9 to see some examples for environment variables.
these are variables that you define so you dont have to always
type the full information.

for example after i log into the unix server i define a variable like
this
export ORACLE_HOME=’/opt/oracle/product/10.2.0′

and when ever i want to go to this directory i will type
cd $ORACLE_HOME

note the $ sign above. you need that to refer a environment
variable that you have defined before.

as a oracle dba define your oracle specific environment variables in
your .profile file as explained in point 11 above.

14)how do you reference unix environment variables,

using a $ sign and the variable name
for example $ORACLE_HOME
see the example in point 13 above

15)how do you use the vi editor and open the file?,
we normally use the vi editor to open and modify files in the unix
environment.
vi file1

16)how do you start editing the file with vi?
press the letter i on your keyboard to start editing and release.
when you dont want to edit press the esc(escape) key on your
keyboard and release

17)how do you exit from a file after you opened with vi without saving your changes?

press esc key on your keyboard and release
press the : key on your key board
now type q! and then press the enter key on your keyboard

18)how do you exit from a file that you opened with vi after saving your changes?
press esc key on your key board and release
press the : key on your keyboard
type wq and then press enter key on your keyboard

19)how do you go to the end of the file after opening it with vi?
press esc key once and release
press the shift key and hold it
press the g key

20)how do you go to the beginning of the file after opening with vi?
press esc key once and release
press the : key on your keyboard
type the number 1 and click enter key

21)how do you delete characters in a file after opening it with vi?
press esc key once and release
scroll down to the character that you want to delete and keep the
cursor before the character and press the x key.

22)how do you delete lines in a file after opening it with vi?
press esc key once and release
if you want to delete one line on which your cursor is present –
then press 1 key and then press the d key twice..
similarly if you want to delete 2 lines – then press 2 and then press
d key twice

23)how can you select a big block of text in a file when you open the
file using vi and if you are using putty to connect to the unix server?

if you are using putty then you can use your left mouse button and
press the key and drag it along the section of text that you want to
copy and release the mouse key and it will automatically be copied.
then use your right mouse key to paste it whereever you want after
positioning your cursor at the right position.

24)How to copy a file called file1 to another file called file2?
cp file1 file2

25)How to delete a file called file1?
rm file1

26)How to delete a directory called dir1?
rm -r dir1

27)how do you create a directory dir1?
mkdir dir1

28)how do you delete all files in a directory?
rm *

29)how do you delete 2 files in a directory at once if you know the file names?
rm file1 file2

30)what is the touch command?
if you want to create a file called file1 then use
touch file1

31)how do you see the list of all files in a directory?
ls -l

32)how do you see the list of files in a directory and order the files in ascending order so the last modified file is observed at the bottom of the list?
ls -ltr

33)how do you see if oracle is running on the server?
ps -ef | grep ora_pmon
the ora_pmon is a oracle process and the ps -ef command lists all processes in the server and we use the grep command to search just for the process we mentioned above(ora_pmon)

34)what is ps command?
use this link to find out about the ps command.

35)what is man command?
man command is used to find out about a command.
use the man utility on the unix server.
example man cp
this will give you explanation about what cp is

36)why do you write #!bin/ksh in the first line of your shell script?

go to this link for more info

37)how do you execute a shell script from your command line?
./filename.sh

38)what is meant by command line?
the place where you type your command in the unix environment
as soon as you log into the unix server you see a prompt like # or $ .
this is where you type your commands .you can even configure the prompt that you would like to see.

39)which character do you use to comment lines in a shell script?
#

40)what is grep command?
grep unix filename1
will search for the word unix in the file
type man grep page for more information

41)what is cat command?
append to file cat >> file1
combine 2 files cat file1 file2 > file3

42)what is cut command?
we can use the cut command to take certain fields in a line and
for all lines.
you can see more in this link

43)how do you find and delete specific files in your current directory and subdirectories? for example below command deletes all files in the current directory and subdirectories and having .log at the end.
find . \( -name ‘*.log’ \) -exec ls {} \;

44)how do you turn on line numbers in a file?
While editing a document (and not inserting text), type the
following to turn on line numbers:
:set number
If you tire of the line numbers, enter the following command to
turn them off:
:set nonumber

45)As a dba you saw that the listener.log or alert.log is quite huge and you want to delete all the lines in the file but you dont want to delete the file. how do you do it?
> listener.log

46)how do you exit from an unix environment?
using the exit command

47)what is pwd command?
shows your current directory

48)what is export command in unix?( this is different from the oracle export command)

i can say for example
export ORACLE_HOME=’/opt/oracle/product/10.2.0′ so i can define the
the variable ORACLE_HOME.

so export command is used to define variables.
read more on

49)what is awk and what is sed?
these are two scripting languages used to write scripts in the unix environment. as a new dba it is useful to know the basics of these languages.

Author: admin