Anda di halaman 1dari 5

Useful Linux Commands

General Commands
Command

Description

Sample usage

pwd

Displays current directory

root> pwd

Is
Is -al

Lists all the files in the current directory


Lists all hidden files with details

root> ls
root> ls -al

cd

Changes directory

root> cd /u01/app/oracle

touch

Creates new empty file

root> touch slx_01.log

rm

Deletes files

root> rm slx_01.log

mv

Moves / renames files

root> mv [from] [to]

cp

Copies files/ directories

root> cp [from] [to]

mkdir
find

Creates new directory


Locates specific files

root> mkdir slx_usr01


root> find / -n slx_sql01.sql
root>find / -print | grep -i
slx_sql01l.sql

which

Finds PATH settings of the executable

root> rmdir slx_usr01

User Management
Command
umask
chmod

Description
To set default File Permissions for current
User
To change the File Permissions after the
creation of the file

Sample usage
root> umask 022

root> chmod 777 .log root>


chmod o+rwx *.log root>
chmod g+r *.log root>
chmod -Rx *.log

chown

To reset the file ownership

root> chown -R oinstall.dba


*

useradd

To add user

root> useradd -G [primary


group] -g [secondary group]
-d [default directory] -m
[creates the default
directory] -s [the default
shell]

usermod

To modify user setting

root> usermod -s /bin /csh


slx_usr01

userdel

To drop existing user

root> userdel -r slx_usr01

passwd
who

To set the passwrod


To list current Oracle users

root> passwd m slx_usr01


root> who | grep -i ora

Performance Characteristics
Command
ps

Description

Sample usage

To list current Oracle processes

kill
uname
hostname
cat
alert_lin1.log

root> ps -ef | grep -i ora

To kill process based on process id

root> kill -9 12345

To get the user information

root> uname -a

To get host information


To return Oracle error lines

root> hostname
root> cat alert_LIN1.log |
grep -i ORA-

rm

To remove back up logs

gzip

To zip files

gzip myfile

gunzip

To uncompress

gunzip myfile.gz

compress

To Compress Files

compress myfile

uncompress

To uncompress

uncompress myfile

find /backup/logs/ -name


daily_backup* -mtime +21
-exec rm -f {} \;

CPU Performance
vmstat
To display system Statistics(for 5 seconds apart for 2 times):
root>$ vmstat 5 2
procs memory page disk faults
r b w Swap
Free re mf Pi
0

2 2 1 72 0 0

3 0 8 04

2 2 1 72 0 0

2 9 8 08

2
8

po fr

55

178

13 9

143

22 2
31 9

De

sr

s0 s1

in sy

112 4

251

14 3

257

44 9

19

2 17

263

25 1

procs.
This parameter gives information about the number of processes.
R: rocesses in the run queue.
B: processes blocked for resources.
W: Processes those are swapped.

cs

us

261

198

12

cpu
sy id
3
14

88
91

Memory
Reports the usage of the memory.
Swap: currently available swap space.
Free: size of free space.
Page
Reports the paging activities.
Re: pages that were reclaimed.
Mf: minor faults.
Pi: KB paged in.
Po: KB paged out.
Fr: free space.
De: short term memory short fall.
Sr: pages scanned.
Disk
Number of disk operations for the disk s0 and
s1. Faults.
The number of traps and interrupts.
Si: system calls.
Cs : context switches.
CPU
The use of the CPU time.
Us: user time.
Si: system time.
Cs: idle time
root>sar -u 5 2
02:50:51 PM
CP
%use
%nice %system %idle
U
r
02:50:56 PM
all
26.53
2.95 70.53
0.00
02:51:01 PM
all 26.13
2.32 71.55
0.00
Average:
all 26.33
2.63 71.05
0.00
user: CPU utilization that occurred during the execution at the user level.
nice: CPU utilization that occurred during the execution at the user level with
nice priority.
system: CPU utilization that occurred during the execution at the system level.
idle: Time that the CPU was idle
mpstat
Reports preprocessor statistics 5 Seconds apart for 2 times.
mpstat 5

02:51:56
PM
02:52:01
PM
02:52:06
PM
Average:

CPU %user %nice %system


all 27.57 0.00 2.56 69.8
all 26.32 0.05 2.59 771.0
all 26.94 0.03 2.57 470.4
6

%idle intr/s
246.52
233.27
239.86

ps
To display the top 10 CPU users.
02:51:56 PM
02:52:01 PM
02:52:06 PM
Average:

CPU %user %nice %system


all 27.57 0.00 2.56 69.87
all 26.32 0.05 2.59 71.04
all 26.94 0.03 2.57 70.46

%idle intr/s
246.52
233.27
239.86

$ ps -e -o pcpu -o pid -o user -o args j sort -k 1 j tail -21r

%CPU PID User Command


0.4 9510 oraprod ora_qmn0_PROD
0.6 17207 oracle /mnt/sdc1/ora10gAS/opmn/bin/opmn -d
0.6 17644 oracle /mnt/sdc1/ora10gAS/bin/emagent
1.4 20523 oracle /mnt/sdc1/ora10gAS/Apache/.. /Apache/Apache -U
185008166
Cron
To run jobs at regular intervals:
Login as root $
crontab -l> newjob
Edit newjob file.
$ crontab new job

Useful File Locations


Path

Contents

/etc/passwd

User settings

/etc/group

Group settings for users

/etc/hosts
/etc/system

Hostname lookup information


Kernel parameters

Anda mungkin juga menyukai