SlideShare una empresa de Scribd logo
1 de 16
Most Frequently Used UNIX Commands For DBAs
WHITE PAPER
Author: Suparna Chaudhuri
Table of Contents
Table of Contents.............................................................................................................................................1
Introduction......................................................................................................................3
File & Directory Navigation.............................................................................................4
..........................................................................................................................................4
File Permissions...............................................................................................................7
OS Users Management.....................................................................................................8
Most Frequently Used UNIX Commands For DBAs
Process Monitoring...........................................................................................................9
uname and hostname......................................................................................................10
Compress Files...............................................................................................................10
Performance Monitoring................................................................................................11
CPU Utilization..............................................................................................................11
Disk Space Usage...........................................................................................................13
CRON.............................................................................................................................14
References......................................................................................................................15
About the Authors..........................................................................................................15
Most Frequently Used UNIX Commands For DBAs
Introduction
This paper contains common UNIX commands for DBAs. This is not a complete but a compact
list of commands used on regular basis. This will give you a jumpstart on some of the common
Linux commands. All UNIX commands and filenames are case sensitive.
Most Frequently Used UNIX Commands For DBAs
File & Directory Navigation
cat
cat filename
Display a filename
cat /etc/passwd
cat bigfile | more
cd
cd dirname
Change from one directory to other directory.
cd /oraData
cp
cp file1 file2
Copies one file/directory to specified location.
cp data.txt /tmp
file
file filename
Identifies the type of file type like binary, text.
File /dev/wd0a
file compressed.gz
find
find filename/dir
Finds a file/directory.
find /usr –name *stat
Find every file under the directory /usr ending in "stat".
head
head filename
Shows the beginning of a file.
head –n 5 mydoc.txt
Most Frequently Used UNIX Commands For DBAs
To view the first n number of lines.
less
less filename
Allows you to quickly view the file.
less table1
It will display the top of the file, ‘table1’.
ls
ls dirname
List directory contents
ls /home/usr/doc/book
mkdir
mkdir dirname
Creates the specified directory.
mkdir mydir
more
more filename
The more command writes your file onto the screen one page at a time.
ls –a | more
mv
mv file1 file2
Moves the location of or renames a file/directory.
mv my_file.txt your_file.txt
pwd
Shows the current directory the user is in
root>pwd
/u01/app/oracleproduct/9.2.0.1.0
rm
rm filename
Removes a file.
Most Frequently Used UNIX Commands For DBAs
rm my_file.txt
rm –R /archievelog
rmdir
rmdir dirname
Removes a directory.
rmdir backup
tail
tail filename
Shows the end of a file.
tail dblog.txt
This command will print the last ten line of the file named dblog.txt.
tail dblog.txt –n 100
This command will print the last 100 lines of the file named dblog.txt.
touch
touch filename
Creates a blank file or modifies an existing file”s access and modification time.
touch newfile.log
Creates a file known as newfile.log, if it does not already exist. If the file already exists the
accessed and modification time will be updated for the file, newfile.log.
whereis
whereis filename
Shows the location of a file.
whereis –b ls
ls: /bin/ls
which
which filename
Shows the location of a file if it is in your PATH.
oracle> which sqlplus
The "which" command searches PATH setting for occurrences of the specified executable.
Most Frequently Used UNIX Commands For DBAs
File Permissions
umask
When user creates a file or directory under Linux or UNIX, he/she creates it with a default set of
permissions. The user file-creation mode mask (umask) is used to determine the file permission
for newly created files. It can be used to control the default file permission for new files. It is a
four-digit octal number.
You can setup umask in /etc/bashrc or /etc/profile file for all users.
The octal notations are as follows:
Octal value : Permission
0 : read, write and execute
1 : read and write
2 : read and execute
3 : read only
4 : write and execute
5 : write only
6 : execute only
7 : no permissions
root>umask 022
chmod
Changes the permission of a file.
Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.
root > chmod 644 file.htm
root> chmod o+rwx *.log
root> chmod g+r *.log
chown
chown command changes the user and/or group ownership for a given file.
chown owner-user file
chown owner-user:owner-group file
root> ls –l testjar.sh
Most Frequently Used UNIX Commands For DBAs
-rw-r--r-- 1 root root 0 Aug 31 05:48 testjar.sh
root> chown schau testjar.sh
root> ls –l testjar.sh
-rw-r--r-- 1 schau root 0 Aug 31 05:48 testjar.sh
chgrp
chgrp command changes group associated to a file/folder from one group to other.
Change group name:sales of a file to other group name:hrgroup
chgrp hrgroup file1
OS Users Management
useradd
This command is used to create new users and also update default new user information.
root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user
The "-G" flag specifies the primary group.
The "-g" flag specifies the secondary group.
The "-d" flag specifies the default directory.
The "-m" flag creates the default directory.
The "-s" flag specifies the default shell.
When a user account is created, some extra information is associated with account by default. To
view these default values, use the -D option along with this command.
[root@houora27 ~]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
usermod
The "usermod" command is used to modify the user settings after a user has been created:
root> usermod -s /bin/csh my_user
userdel
The "userdel" command is used to delete existing users:
root> userdel -r my_user
Most Frequently Used UNIX Commands For DBAs
The "-r" flag removes the default directory.
passwd
The "passwd" command is used to set, or reset, the users login password:
root> passwd my_user
who
The "who" command can be used to list all users who have OS connections:
root>who
root>who | head -5
root>who | tail -5
root>who | grep –I ora
root>who | wc -1
The "head -5" command restricts the output to the first 5 lines of the who command.
The "tail -5" command restricts the output to the last 5 lines of the who command.
The "grep -i ora" command restricts the output to lines containing "ora".
The "wc -l" command returns the number of lines from "who", and hence the number of
connected users.
groupadd
groupadd command is used to create group accounts. It updates the /etc/group file accordingly.
root> ls –l testjar.sh
If you want to create a group with a specific group id use below command.
root> groupadd dbgrp –g 9090
groupdel
This command will remove a group.
groupdel dbgrp
Process Monitoring
ps
This command lists current process information.
[oracle@houora27 oracleData]$ ps
PID TTY TIME CMD
Most Frequently Used UNIX Commands For DBAs
12326 pts/1 00:00:00 bash
12874 pts/1 00:00:00 ps
[oracle@houora27 oracleData]$ ps -ef|grep -i ora
oracle 11217 1 0 Jul22 ? 00:01:23
/opt/Oracle/DB10gR2/beta4/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 11226 1 0 Jul22 ? 00:03:52 ora_pmon_BETA4
oracle 11228 1 0 Jul22 ? 00:00:06 ora_psp0_BETA4
oracle 11230 1 0 Jul22 ? 00:02:07 ora_mman_BETA4
oracle 11232 1 0 Jul22 ? 00:05:34 ora_dbw0_BETA4
oracle 11234 1 0 Jul22 ? 02:13:47 ora_lgwr_BETA4
oracle 11236 1 0 Jul22 ? 00:03:43 ora_ckpt_BETA4
oracle 11238 1 0 Jul22 ? 00:04:32 ora_smon_BETA4
oracle 11240 1 0 Jul22 ? 00:00:00 ora_reco_BETA4
-e – to display all processes
-f – to display full format listing
uname and hostname
The "uname" and "hostname" commands can be used to get information about the host:
[oracle@houora27 oracleData]$ uname –a
Linux houora27 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386
GNU/Linux
[oracle@houora27 oracleData]$ hostname
houora27
Compress Files
To save space on the filesystem user can compress files such as archived redo logs. This can be
using gzip. The gzip command results in a compressed copy of the original file with a ".gz"
extension. The gunzip command reverses this process:
gzip
gzip myfile
Compresses the file myfile, making it myfile.gz. Note. When doing this the original file will no
longer exist on the drive.
gunzip
gunzip -f myfile.gz
Most Frequently Used UNIX Commands For DBAs
Uncompress the file myfile.gz and if the uncompressed file(s) already exist force an overwrite.
When doing this the file myfile.gz will no longer be on the drive.
gunzip -c myfile.gz > myfile.txt
Uncompress the file myfile.tz to the myfile.txt file, however, don't delete the .gz file. This is
useful if you don't want to delete the .gz and keep it with the uncompressed file.
Performance Monitoring
vmstat
vmstat will display the memory usage.
[oracle@houora27 oracleData]$ vmstat 5 3
Displays system statistics (5 seconds apart; 3 times)
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 21744 40832 78420 3535796 0 0 1 4 2 5 19 41 35 5
1 0 21744 40768 78440 3535776 0 0 0 188 1041 114 25 27 44 4
1 0 21744 40784 78460 3535756 0 0 0 160 1036 108 24 28 45 4
vmstat output contains the following fields:
Procs – r: Total number of processes waiting to run
Procs – b: Total number of busy processes
Memory – swpd: Used virtual memory
Memory – free: Free virtual memory
Memory – buff: Memory used as buffers
Memory – cache: Memory used as cache.
Swap – si: Memory swapped from disk (for every second)
Swap – so: Memory swapped to disk (for every second)
IO – bi: Blocks in. i.e blocks received from device (for every second)
IO – bo: Blocks out. i.e blocks sent to the device (for every second)
System – in: Interrupts per second
System – cs: Context switches
CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time
CPU Utilization
top
The top program provides a dynamic real-time view of a running system. It displays system
summary information; list of tasks currently being managed by the Linux kernel.
The top command monitors CPU utilization, process statistics, and memory utilization.
Most Frequently Used UNIX Commands For DBAs
root>top
top - 12:04:31 up 43 days, 18:31, 1 user, load average: 1.01, 1.20, 1.24
Tasks: 114 total, 2 running, 112 sleeping, 0 stopped, 0 zombie
Cpu(s): 24.8% us, 27.2% sy, 0.0% ni, 45.0% id, 3.0% wa, 0.0% hi, 0.0% si
Mem: 4148916k total, 4123052k used, 25864k free, 4136k buffers
Swap: 6289436k total, 21672k used, 6267764k free, 3631960k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2470 root 25 0 11464 4552 2584 R 99.9 0.1 3354:21 snmpd
11295 oracle 16 0 2340m 2.1g 2.1g S 0.7 53.1 1188:31 oracle
11299 oracle 16 0 2340m 2.1g 2.1g S 0.7 53.0 549:18.14 oracle
11301 oracle 16 0 2344m 2.1g 2.1g S 0.7 52.6 180:57.14 oracle
11303 oracle 16 0 2338m 2.1g 2.1g S 0.7 52.3 58:32.22 oracle
16366 root 17 0 3336 944 740 R 0.7 0.0 0:00.05 top
mpstat
For multiple CPU system mpstat command displays the utilization of each CPU individually. It
reports processors related statistics.
root>mpstat
Linux 2.6.9-34.ELsmp (houora27) 09/03/2013
12:07:09 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s
12:07:09 PM all 18.13 0.93 40.86 4.62 0.01 0.00 35.44 1065.19
sar
This command displays today’s cpu activity.
root>sar
Linux 2.6.9-34.ELsmp (houora27) 09/03/2013
12:00:01 AM CPU %user %nice %system %iowait %idle
12:10:01 AM all 24.42 0.00 28.04 4.67 42.87
12:20:01 AM all 24.60 0.00 28.10 4.57 42.73
12:30:01 AM all 24.36 0.00 28.12 4.69 42.84
12:40:01 AM all 24.89 0.00 28.18 3.09 43.85
12:50:02 AM all 24.42 0.00 28.03 2.95 44.60
01:00:01 AM all 24.51 0.00 28.09 3.18 44.22
01:10:01 AM all 24.33 0.00 28.10 3.11 44.46
01:20:01 AM all 24.43 0.00 28.05 2.97 44.55
Where,
%user: Percentage of CPU utilization that occurred while executing at the user level
(application).
Most Frequently Used UNIX Commands For DBAs
%nice: Percentage of CPU utilization that occurred while executing at the user level with nice
priority.
%system: Percentage of CPU utilization that occurred while executing at the system level
(kernel).
%iowait: Percentage of time that the CPU or CPUs were idle during which the system had an
outstanding disk I/O request.
%idle: Percentage of time that the CPU or CPUs were idle and the system did not have an
outstanding disk I/O request.
Disk Space Usage
df
This command displays the file system disk space usage.
root>df –k
displays output in bytes
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 20641788 9019860 10573288 47% /
/dev/sdb1 70557052 14689764 52283192 22% /Misc
/dev/sda1 101086 11506 84361 13% /boot
none 2063504 35880 1922804 2% /dev/shm
/dev/sda6 2063504 35880 1922804 2% /dev/shm
/dev/sda5 20641788 5846244 13746904 30% /opt
/dev/sdc1 288362876 171807444 101907368 63% /oracleBackup
/dev/sdd1 288362876 260358600 13356212 96% /oracleData
root>df –h
displays output in human readable form.
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 8.7G 11G 47% /
/dev/sdb1 68G 15G 50G 22% /Misc
/dev/sda1 99M 12M 83M 13% /boot
none 2.0G 36M 1.9G 2% /dev/shm
/dev/sda6 2.0G 36M 1.9G 2% /dev/shm
/dev/sda5 20G 5.6G 14G 30% /opt
/dev/sdc1 276G 164G 98G 63% /oracleBackup
/dev/sdd1 276G 249G 13G 96% /oracleData
root>df –T
displays what type of file system
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda2 ext3 20641788 9019860 10573288 47% /
Most Frequently Used UNIX Commands For DBAs
/dev/sdb1 ext3 70557052 14689764 52283192 22% /Misc
/dev/sda1 ext3 101086 11506 84361 13% /boot
none tmpfs 2063504 35880 1922804 2% /dev/shm
/dev/sda6 ext3 2063504 35880 1922804 2% /dev/shm
/dev/sda5 ext3 20641788 5846244 13746904 30% /opt
/dev/sdc1 ext3 288362876 171807444 101907368 63% /oracleBackup
/dev/sdd1 ext3 288362876 260358600 13356212 96% /oracleData
CRON
Crontab command is used to schedule commands to be executed periodically.
Using below command you can see what crontabs are currently running on your system.
root> crontab -1
There are two methods of editing the crontab file.
You can use the "crontab -l > filename" option to list the contents and pipe this to a file. After
editing the file you can apply it using the "crontab filename":
Login as root
crontab -l > newcrontabfile
Edit newcrontabfile file.
crontab newcrontabfile
You can use the "crontab -e" option to edit the crontab file directly.
root> crontab –e
* * * * * /bin/execute/test.sh
There are 5 stars which represent different date parts in the following order:
minute (from 0 to 59)
hour (from 0 to 23)
day of month (from 1 to 31)
month (from 1 to 12)
day of week (from 0 to 6) (0=Sunday)
Using below statement you can schedule the script to run at 1AM every Friday.
0 1 * * 5 /bin/execute/test.sh
Most Frequently Used UNIX Commands For DBAs
References
1. http://www.tjhsst.edu/~dhyatt/superap/unixcmd.html
2. http://kb.iu.edu/data/afsk.html
About the Authors
Name Suparna Chaudhuri
E-Mail suparna.chaudhuri@wipro.com
Expertise Oracle
Employee ID 142476
Most Frequently Used UNIX Commands For DBAs
About Wipro Technologies
Wipro is the first PCMM Level 5 and SEI CMMi Level 5 certified IT Services Company
globally. Wipro provides comprehensive IT solutions and services (including systems integration,
IS outsourcing, package implementation, software application development and maintenance) and
Research & Development services (hardware and software design, development and
implementation) to corporations globally.
Wipro's unique value proposition is further delivered through our pioneering Offshore
Outsourcing Model and stringent Quality Processes of SEI and Six Sigma.
© Copyright 2013. Wipro Technologies. All rights reserved. No part of this document may be reproduced, stored in a
retrieval system, transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without express written permission from Wipro Technologies. Specifications subject to change without
notice. All other trademarks mentioned herein are the property of their respective owners.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (18)

Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
Linux Common Command
Linux Common CommandLinux Common Command
Linux Common Command
 
Linux Security Quick Reference Guide
Linux Security Quick Reference GuideLinux Security Quick Reference Guide
Linux Security Quick Reference Guide
 
Linux midterm quiz
Linux midterm quizLinux midterm quiz
Linux midterm quiz
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Sudo
SudoSudo
Sudo
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Rhel1
Rhel1Rhel1
Rhel1
 
2009 cluster user training
2009 cluster user training2009 cluster user training
2009 cluster user training
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu Commands
 
Linux class 9 15 oct 2021-5
Linux class 9   15 oct 2021-5Linux class 9   15 oct 2021-5
Linux class 9 15 oct 2021-5
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manual
 
Linux class 10 15 oct 2021-6
Linux class 10   15 oct 2021-6Linux class 10   15 oct 2021-6
Linux class 10 15 oct 2021-6
 
Solaris_quickref.pdf
Solaris_quickref.pdfSolaris_quickref.pdf
Solaris_quickref.pdf
 
Clase4 (consola linux)
Clase4 (consola linux)Clase4 (consola linux)
Clase4 (consola linux)
 

Similar a Most frequently used unix commands for database administrator

Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1Lilesh Pathe
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overviewAmeer Sameer
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
Linux file system nevigation
Linux file system nevigationLinux file system nevigation
Linux file system nevigationhetaldobariya
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxRajesh Kumar
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manualSaikat Rakshit
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manualCraig Cannon
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to LinuxDimas Prasetyo
 
Linux for CS Majors
Linux for CS MajorsLinux for CS Majors
Linux for CS Majorsworr1244
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0venkatakrishnan k
 

Similar a Most frequently used unix commands for database administrator (20)

Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Solaris basics
Solaris basicsSolaris basics
Solaris basics
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux file system nevigation
Linux file system nevigationLinux file system nevigation
Linux file system nevigation
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Linux for CS Majors
Linux for CS MajorsLinux for CS Majors
Linux for CS Majors
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0
 

Último

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Último (20)

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Most frequently used unix commands for database administrator

  • 1. Most Frequently Used UNIX Commands For DBAs WHITE PAPER Author: Suparna Chaudhuri Table of Contents Table of Contents.............................................................................................................................................1 Introduction......................................................................................................................3 File & Directory Navigation.............................................................................................4 ..........................................................................................................................................4 File Permissions...............................................................................................................7 OS Users Management.....................................................................................................8
  • 2. Most Frequently Used UNIX Commands For DBAs Process Monitoring...........................................................................................................9 uname and hostname......................................................................................................10 Compress Files...............................................................................................................10 Performance Monitoring................................................................................................11 CPU Utilization..............................................................................................................11 Disk Space Usage...........................................................................................................13 CRON.............................................................................................................................14 References......................................................................................................................15 About the Authors..........................................................................................................15
  • 3. Most Frequently Used UNIX Commands For DBAs Introduction This paper contains common UNIX commands for DBAs. This is not a complete but a compact list of commands used on regular basis. This will give you a jumpstart on some of the common Linux commands. All UNIX commands and filenames are case sensitive.
  • 4. Most Frequently Used UNIX Commands For DBAs File & Directory Navigation cat cat filename Display a filename cat /etc/passwd cat bigfile | more cd cd dirname Change from one directory to other directory. cd /oraData cp cp file1 file2 Copies one file/directory to specified location. cp data.txt /tmp file file filename Identifies the type of file type like binary, text. File /dev/wd0a file compressed.gz find find filename/dir Finds a file/directory. find /usr –name *stat Find every file under the directory /usr ending in "stat". head head filename Shows the beginning of a file. head –n 5 mydoc.txt
  • 5. Most Frequently Used UNIX Commands For DBAs To view the first n number of lines. less less filename Allows you to quickly view the file. less table1 It will display the top of the file, ‘table1’. ls ls dirname List directory contents ls /home/usr/doc/book mkdir mkdir dirname Creates the specified directory. mkdir mydir more more filename The more command writes your file onto the screen one page at a time. ls –a | more mv mv file1 file2 Moves the location of or renames a file/directory. mv my_file.txt your_file.txt pwd Shows the current directory the user is in root>pwd /u01/app/oracleproduct/9.2.0.1.0 rm rm filename Removes a file.
  • 6. Most Frequently Used UNIX Commands For DBAs rm my_file.txt rm –R /archievelog rmdir rmdir dirname Removes a directory. rmdir backup tail tail filename Shows the end of a file. tail dblog.txt This command will print the last ten line of the file named dblog.txt. tail dblog.txt –n 100 This command will print the last 100 lines of the file named dblog.txt. touch touch filename Creates a blank file or modifies an existing file”s access and modification time. touch newfile.log Creates a file known as newfile.log, if it does not already exist. If the file already exists the accessed and modification time will be updated for the file, newfile.log. whereis whereis filename Shows the location of a file. whereis –b ls ls: /bin/ls which which filename Shows the location of a file if it is in your PATH. oracle> which sqlplus The "which" command searches PATH setting for occurrences of the specified executable.
  • 7. Most Frequently Used UNIX Commands For DBAs File Permissions umask When user creates a file or directory under Linux or UNIX, he/she creates it with a default set of permissions. The user file-creation mode mask (umask) is used to determine the file permission for newly created files. It can be used to control the default file permission for new files. It is a four-digit octal number. You can setup umask in /etc/bashrc or /etc/profile file for all users. The octal notations are as follows: Octal value : Permission 0 : read, write and execute 1 : read and write 2 : read and execute 3 : read only 4 : write and execute 5 : write only 6 : execute only 7 : no permissions root>umask 022 chmod Changes the permission of a file. Permissions u - User who owns the file. g - Group that owns the file. o - Other. a - All. r - Read the file. w - Write or edit the file. x - Execute or run the file as a program. root > chmod 644 file.htm root> chmod o+rwx *.log root> chmod g+r *.log chown chown command changes the user and/or group ownership for a given file. chown owner-user file chown owner-user:owner-group file root> ls –l testjar.sh
  • 8. Most Frequently Used UNIX Commands For DBAs -rw-r--r-- 1 root root 0 Aug 31 05:48 testjar.sh root> chown schau testjar.sh root> ls –l testjar.sh -rw-r--r-- 1 schau root 0 Aug 31 05:48 testjar.sh chgrp chgrp command changes group associated to a file/folder from one group to other. Change group name:sales of a file to other group name:hrgroup chgrp hrgroup file1 OS Users Management useradd This command is used to create new users and also update default new user information. root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user The "-G" flag specifies the primary group. The "-g" flag specifies the secondary group. The "-d" flag specifies the default directory. The "-m" flag creates the default directory. The "-s" flag specifies the default shell. When a user account is created, some extra information is associated with account by default. To view these default values, use the -D option along with this command. [root@houora27 ~]# useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel usermod The "usermod" command is used to modify the user settings after a user has been created: root> usermod -s /bin/csh my_user userdel The "userdel" command is used to delete existing users: root> userdel -r my_user
  • 9. Most Frequently Used UNIX Commands For DBAs The "-r" flag removes the default directory. passwd The "passwd" command is used to set, or reset, the users login password: root> passwd my_user who The "who" command can be used to list all users who have OS connections: root>who root>who | head -5 root>who | tail -5 root>who | grep –I ora root>who | wc -1 The "head -5" command restricts the output to the first 5 lines of the who command. The "tail -5" command restricts the output to the last 5 lines of the who command. The "grep -i ora" command restricts the output to lines containing "ora". The "wc -l" command returns the number of lines from "who", and hence the number of connected users. groupadd groupadd command is used to create group accounts. It updates the /etc/group file accordingly. root> ls –l testjar.sh If you want to create a group with a specific group id use below command. root> groupadd dbgrp –g 9090 groupdel This command will remove a group. groupdel dbgrp Process Monitoring ps This command lists current process information. [oracle@houora27 oracleData]$ ps PID TTY TIME CMD
  • 10. Most Frequently Used UNIX Commands For DBAs 12326 pts/1 00:00:00 bash 12874 pts/1 00:00:00 ps [oracle@houora27 oracleData]$ ps -ef|grep -i ora oracle 11217 1 0 Jul22 ? 00:01:23 /opt/Oracle/DB10gR2/beta4/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit oracle 11226 1 0 Jul22 ? 00:03:52 ora_pmon_BETA4 oracle 11228 1 0 Jul22 ? 00:00:06 ora_psp0_BETA4 oracle 11230 1 0 Jul22 ? 00:02:07 ora_mman_BETA4 oracle 11232 1 0 Jul22 ? 00:05:34 ora_dbw0_BETA4 oracle 11234 1 0 Jul22 ? 02:13:47 ora_lgwr_BETA4 oracle 11236 1 0 Jul22 ? 00:03:43 ora_ckpt_BETA4 oracle 11238 1 0 Jul22 ? 00:04:32 ora_smon_BETA4 oracle 11240 1 0 Jul22 ? 00:00:00 ora_reco_BETA4 -e – to display all processes -f – to display full format listing uname and hostname The "uname" and "hostname" commands can be used to get information about the host: [oracle@houora27 oracleData]$ uname –a Linux houora27 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386 GNU/Linux [oracle@houora27 oracleData]$ hostname houora27 Compress Files To save space on the filesystem user can compress files such as archived redo logs. This can be using gzip. The gzip command results in a compressed copy of the original file with a ".gz" extension. The gunzip command reverses this process: gzip gzip myfile Compresses the file myfile, making it myfile.gz. Note. When doing this the original file will no longer exist on the drive. gunzip gunzip -f myfile.gz
  • 11. Most Frequently Used UNIX Commands For DBAs Uncompress the file myfile.gz and if the uncompressed file(s) already exist force an overwrite. When doing this the file myfile.gz will no longer be on the drive. gunzip -c myfile.gz > myfile.txt Uncompress the file myfile.tz to the myfile.txt file, however, don't delete the .gz file. This is useful if you don't want to delete the .gz and keep it with the uncompressed file. Performance Monitoring vmstat vmstat will display the memory usage. [oracle@houora27 oracleData]$ vmstat 5 3 Displays system statistics (5 seconds apart; 3 times) procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 1 0 21744 40832 78420 3535796 0 0 1 4 2 5 19 41 35 5 1 0 21744 40768 78440 3535776 0 0 0 188 1041 114 25 27 44 4 1 0 21744 40784 78460 3535756 0 0 0 160 1036 108 24 28 45 4 vmstat output contains the following fields: Procs – r: Total number of processes waiting to run Procs – b: Total number of busy processes Memory – swpd: Used virtual memory Memory – free: Free virtual memory Memory – buff: Memory used as buffers Memory – cache: Memory used as cache. Swap – si: Memory swapped from disk (for every second) Swap – so: Memory swapped to disk (for every second) IO – bi: Blocks in. i.e blocks received from device (for every second) IO – bo: Blocks out. i.e blocks sent to the device (for every second) System – in: Interrupts per second System – cs: Context switches CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time CPU Utilization top The top program provides a dynamic real-time view of a running system. It displays system summary information; list of tasks currently being managed by the Linux kernel. The top command monitors CPU utilization, process statistics, and memory utilization.
  • 12. Most Frequently Used UNIX Commands For DBAs root>top top - 12:04:31 up 43 days, 18:31, 1 user, load average: 1.01, 1.20, 1.24 Tasks: 114 total, 2 running, 112 sleeping, 0 stopped, 0 zombie Cpu(s): 24.8% us, 27.2% sy, 0.0% ni, 45.0% id, 3.0% wa, 0.0% hi, 0.0% si Mem: 4148916k total, 4123052k used, 25864k free, 4136k buffers Swap: 6289436k total, 21672k used, 6267764k free, 3631960k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2470 root 25 0 11464 4552 2584 R 99.9 0.1 3354:21 snmpd 11295 oracle 16 0 2340m 2.1g 2.1g S 0.7 53.1 1188:31 oracle 11299 oracle 16 0 2340m 2.1g 2.1g S 0.7 53.0 549:18.14 oracle 11301 oracle 16 0 2344m 2.1g 2.1g S 0.7 52.6 180:57.14 oracle 11303 oracle 16 0 2338m 2.1g 2.1g S 0.7 52.3 58:32.22 oracle 16366 root 17 0 3336 944 740 R 0.7 0.0 0:00.05 top mpstat For multiple CPU system mpstat command displays the utilization of each CPU individually. It reports processors related statistics. root>mpstat Linux 2.6.9-34.ELsmp (houora27) 09/03/2013 12:07:09 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s 12:07:09 PM all 18.13 0.93 40.86 4.62 0.01 0.00 35.44 1065.19 sar This command displays today’s cpu activity. root>sar Linux 2.6.9-34.ELsmp (houora27) 09/03/2013 12:00:01 AM CPU %user %nice %system %iowait %idle 12:10:01 AM all 24.42 0.00 28.04 4.67 42.87 12:20:01 AM all 24.60 0.00 28.10 4.57 42.73 12:30:01 AM all 24.36 0.00 28.12 4.69 42.84 12:40:01 AM all 24.89 0.00 28.18 3.09 43.85 12:50:02 AM all 24.42 0.00 28.03 2.95 44.60 01:00:01 AM all 24.51 0.00 28.09 3.18 44.22 01:10:01 AM all 24.33 0.00 28.10 3.11 44.46 01:20:01 AM all 24.43 0.00 28.05 2.97 44.55 Where, %user: Percentage of CPU utilization that occurred while executing at the user level (application).
  • 13. Most Frequently Used UNIX Commands For DBAs %nice: Percentage of CPU utilization that occurred while executing at the user level with nice priority. %system: Percentage of CPU utilization that occurred while executing at the system level (kernel). %iowait: Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request. %idle: Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request. Disk Space Usage df This command displays the file system disk space usage. root>df –k displays output in bytes Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 20641788 9019860 10573288 47% / /dev/sdb1 70557052 14689764 52283192 22% /Misc /dev/sda1 101086 11506 84361 13% /boot none 2063504 35880 1922804 2% /dev/shm /dev/sda6 2063504 35880 1922804 2% /dev/shm /dev/sda5 20641788 5846244 13746904 30% /opt /dev/sdc1 288362876 171807444 101907368 63% /oracleBackup /dev/sdd1 288362876 260358600 13356212 96% /oracleData root>df –h displays output in human readable form. Filesystem Size Used Avail Use% Mounted on /dev/sda2 20G 8.7G 11G 47% / /dev/sdb1 68G 15G 50G 22% /Misc /dev/sda1 99M 12M 83M 13% /boot none 2.0G 36M 1.9G 2% /dev/shm /dev/sda6 2.0G 36M 1.9G 2% /dev/shm /dev/sda5 20G 5.6G 14G 30% /opt /dev/sdc1 276G 164G 98G 63% /oracleBackup /dev/sdd1 276G 249G 13G 96% /oracleData root>df –T displays what type of file system Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda2 ext3 20641788 9019860 10573288 47% /
  • 14. Most Frequently Used UNIX Commands For DBAs /dev/sdb1 ext3 70557052 14689764 52283192 22% /Misc /dev/sda1 ext3 101086 11506 84361 13% /boot none tmpfs 2063504 35880 1922804 2% /dev/shm /dev/sda6 ext3 2063504 35880 1922804 2% /dev/shm /dev/sda5 ext3 20641788 5846244 13746904 30% /opt /dev/sdc1 ext3 288362876 171807444 101907368 63% /oracleBackup /dev/sdd1 ext3 288362876 260358600 13356212 96% /oracleData CRON Crontab command is used to schedule commands to be executed periodically. Using below command you can see what crontabs are currently running on your system. root> crontab -1 There are two methods of editing the crontab file. You can use the "crontab -l > filename" option to list the contents and pipe this to a file. After editing the file you can apply it using the "crontab filename": Login as root crontab -l > newcrontabfile Edit newcrontabfile file. crontab newcrontabfile You can use the "crontab -e" option to edit the crontab file directly. root> crontab –e * * * * * /bin/execute/test.sh There are 5 stars which represent different date parts in the following order: minute (from 0 to 59) hour (from 0 to 23) day of month (from 1 to 31) month (from 1 to 12) day of week (from 0 to 6) (0=Sunday) Using below statement you can schedule the script to run at 1AM every Friday. 0 1 * * 5 /bin/execute/test.sh
  • 15. Most Frequently Used UNIX Commands For DBAs References 1. http://www.tjhsst.edu/~dhyatt/superap/unixcmd.html 2. http://kb.iu.edu/data/afsk.html About the Authors Name Suparna Chaudhuri E-Mail suparna.chaudhuri@wipro.com Expertise Oracle Employee ID 142476
  • 16. Most Frequently Used UNIX Commands For DBAs About Wipro Technologies Wipro is the first PCMM Level 5 and SEI CMMi Level 5 certified IT Services Company globally. Wipro provides comprehensive IT solutions and services (including systems integration, IS outsourcing, package implementation, software application development and maintenance) and Research & Development services (hardware and software design, development and implementation) to corporations globally. Wipro's unique value proposition is further delivered through our pioneering Offshore Outsourcing Model and stringent Quality Processes of SEI and Six Sigma. © Copyright 2013. Wipro Technologies. All rights reserved. No part of this document may be reproduced, stored in a retrieval system, transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without express written permission from Wipro Technologies. Specifications subject to change without notice. All other trademarks mentioned herein are the property of their respective owners.