Vous êtes sur la page 1sur 4

Objective

This document intends to provide the list of UNIX commands used by AIX/Solaris/Unix admins day to day operation.
No

Commands

$ ssh
username@servername
command used to login to
server
$ cd..
takes you to previous Dir

$ vi <file_name>
opens file for reading/editing

10

$ grep <pattern>
file_name
checks pattern/word in file
name specified

13

No

Commands
$ pwd
it prints present working
directory

No

Commands

$ ls -l
listing the files in present directory
$ mkdir -p /home/user1/d1/d2/d3
will create all the non-existing Dirs

$ mkdir <directory>
will create directory

$ cat <file_name>
display contents of file

11

$ head <file_name>
shows first 10 lines of
file_name

12

$ ln file1 file2
creates link of file1 to file2

14

$ cp <file1> <file2>
Copy a file

16

$ clear
clears the scree

17

19

$w
will display more info abt
the users logged in

22

$ rm <file_name>
will delete file specified
$ rm *
Delete all the files in the
present directory (BE
CAREFUL WHILE GIVING
THIS COMMAND)

25

$ chmod 777 <file_name>


changes file_name/directory
permissions
use R switch for recursive

20

23

26

$ rsh -l <login_name>
<server_name>
28

31

29

$uncompress <filename>
uncompresses filename

32

$ who
Displays logged in user to the
system.
$ ps -ef
shows process

$ find . -type f -print -exec


grep -i <type_ur_text_here>
{} \;
this is recursive grep
$ find / -name <file_name>
-print

$ chown owner:group
<file_name>
changes owner & group for
the file_name
$ rcp file1 file2
Copying file to remoter
servers (This requires preconfiguration on remote
servers like .rhosts &
hosts.equiv)
$ compress <file_name>
compresses file_name

Page 1 of 4

$ more <file_name>
displays page by page contents of
file
$ touch <file_name>
creates a zero/dummy file

15

$ mv <file1> <file2>
Move/rename a file or folder

18

$ file <file_name>
shows what type of file it is like

21

24

$ which <file_name>
shows if the file_name/command
exists and if exists display the path
$ tail <file_name>
shows last 10 lines of file
use tail -f for continous update of
file_name

27

$ chgrp <groupname>
<filename>
use R for recursive

30

$ gunzip <file_name>
unzips file name
$ gzip <file_name>
zips file_name

33

$ bc l
bench calculator

No

40

43

46

Commands
$ crontab -l
Shows the cron jobs
running/scheduled for the
current user.
-->$crontab -l >
present_cronjobs
-->edit/add entries to
present_cronjobs
-->$crontab
present_cronjobs (This will
submit/resubmit the jobs in
file presnt_cronjobs to
CRON)
$ nohup <cmd_name> &
nohup is very useful
command. it runs the
command even the telnet
connection is
closed/broken.
& is used for running
command in background.
$ id
shows current user's UID,
username and GID and
group name

49

$ isainfo -v
shows supported platforms
(32-bit, 64-bit)

52

$ rm - <-filename>
for deleting special files
$ rm "<file name>"
delete file names with
spaces in between

55

$ du sk <dir/file name>
Display the size of the
files/folder

58

$ pkginfo
Gives/shows info about
installed packages/software
on system
$ init 6

Commands

No

No

$ at
$ at -l will show the at jobs
scheduled

41

44

at schedule a job to run later


time
at <time> command/script (will
run the script at specified
time)

$ uptime
will show how long the system
has been up and also shows
cpu load, number of users
logged in etc.

killing an unwanted process


$ps ef | grep <process_name>
(will show the PID of the process in
the 2nd field)
42

50

53

56

59

61

will reboot the system (other


init options are 1, 2, 3, 5
and S)

62

64

$ /usr/sbin/ifconfig -a

65

shows unique identifier of host


$ hostname
will give your system name.

$ useradd <username>
Adding a user to the system
$ userdel <username>
Deleting a user from the
system
$ df -k
will show all the mounted
filesystems.
$ showrev p
shows all patches installed on
system
$ alias l='ls -l'
alias dir='ls -l|grep "^d"'
alias p='pwd'
alias c='clear'
Short cuts for commonly used
commands

$ ping <hostname>

Page 2 of 4

$kill -9 <PID>
$ kill -3 <PID>
Used to take threaddump of java
process

45

$ hostid
47

Commands

48

51

54

57

60

63

66

$ last
Will show the users logged in/out
information
last <user_name> shows
particular user logins/logouts
last reboot
shows all the
system boots
$ uname a
will show system name, solaris
version, platform and some more
information
$ env
List the environmental variables
set to your current session
$ echo $TERM
Shows terminal type like vt100,
vt220 etc.
($PATH, $ORACLE_HOME etc
can be used with echo)
$ mount
will show all mounted file systems
with additional info like large
filesystem support etc
$ init 0
will shutdown the system
tar -cvf allfile.tar
/<directory_name>
copies all files under directory to
allfile.tar
$ tar -xvf allfile.tar /home
retrieves tar files to /home
directory
$ tar -tvf allfile.tar
reads contents of allfile.tar
$ set -o vi

No

67

70

73

76

79

82

85

88

91

94

Commands
Will show the ip-address of
the system.
lo0 : loopback interface
hme0 : hundred MBPS n/w
interface
qfe0 : quad ehternet
interface
$ ifconfig unplumb hme0
will disable ehternet
interface hme0
$ top
shows all process and
memory, cpu etc utilisation

$ sysdef
shows system h/w, memory,
and other internal
configurable/tunable
paramters
$ iostat
disk utilisation, cpu, io wait
etc (iostat -xcM gives
extented statistics of disk
activity, cpu etc)
$ netstat
shows network statistics
$ truss -p <PID>
shows system calls and
signals (useful when
debugging process)
$ format
will show all the disks
configuration and partitions
$ halt
halts processor and reboots
machine (BECAREFUL -has to be root)
$ mkfile 60m <swap file
name>
creates a filename of size
60mb which can be used for
adding to swap space

$ sleep 5
waits for 5 seconds (useful
in shell scripts)

No

Commands

No

will ping and test connectivity


between your system and the
hostname you give in the ping.
you can also give ping <ipaddress>

68

$ ifconfig plumb hme0


will enable hme0

While your shell is set to KSH use


this command to display history of
commands you are typing
Press ESCAPE and k for showing
previous commands

69

$ prtconf
shows h/w, cpu, memory conf
71

74

77

80

83

86

89

92

95

72

$ sar A
system archive report, gives
total system report for cpu,
memory, disk, etcc
$ vmstat
memory and virtual memory
utilization
$ lsof -p <pid>
List the opened files for the
process
$ stty erase ^H
sets backspace for deleting
typed character
$ prtvtoc
shows disk partition/geometry
info
$ adb
debugging tool (for
reading/debugging corefiles)
$ swap -a <swap file name>
attaches the 60mb file to swap
space (Very useful when swap
space is running out)

$ cat <file_name> |awk


'{print $1}'
Prints the first field of the filed
($1, $2... can be used to

Page 3 of 4

Commands

75

78

81

84

87

90

$ mount
will show the disks mounted and
all partitions
$ cd
/usr/platform/sun4u/sbin/prtdiag
-v
shows additional configuration of
memory, cpu speed etc..
$ mpstat
shows multi cpu statistics like load
on each cpu.
$ prstat
shows process related statistics
(present from solaris 2.7 and
above)
$ psrinfo
gives processor/s information
(online/offline)
$ strings <file_name>
shows printable strings in any type
of file (binary, object, text etc)
$ uadmin 2 0
stops system immediately within 5
seconds(BE CAREFUL-- has to be
to root)
$ dos2unix <filename>
Convert dos formatted file to unix
format

$ swap -l
lists the swap contents
93

96

:1,$s/<old>/<new>/g
use the above for global
replacement of text in ascii files
using vi editor

No

Commands

97

:1,$s/^M//g
remove Ctrl M character in
text files using vi editor

100

$ipcs mb
Will provide the shared
memory information

Commands

No

display more fields)


$ ksh x <file name.sh>
Will compile the shell file line
by line

98

No

Commands

99

PS1=[$
(hostname)]'$ORACLE_SID@$PWD
>'
Add this entry on .profile , you can
view the hostname ,
$VARIABLE,current directort path

$ mailx -s"<Subject Name>" user1@cognizant.com.com < file.txt


Will send this file.txt to a mail
$ uuencode $file $file| mail -s "<Subject Name>" user1@domian.com
Will send the files as an attachment.

10
1

Important Directories to Remember


/

Root Directiry of unix system

/usr/bin This directory cotains all user level unix commands


/usr/sbin This directory Contains administrative related commands
/usr/lib

This directory contains libraries

/etc

This directory contains system configuration files

/var/adm This directory contains system/application logs.


/etc/rc.d This directory Contains all startup scripts.There will be more of this kind rc2.d, rc3.d, rc0.d, rc5.d, rc6.d
each directory has scripts which will run in its own run level.
/opt

In general, this directory used to install the 3rd party optional packages.

/proc This contains the snapshot of the system process and memory status.
Important files to remember
/etc/passwd it will show all the logins, home directories of the users.
/etc/shadow shows password encryption info and other user related info (only root has access to this file)
/etc/system This file has all n/w, h/w, memory etc tunable parameters/values
/etc/inittab This file defines the default run level of the system.
/etc/hosts This file contains the list of hosts/IP address
/etc/services This file contains the port/service Name
/etc/nsswitch.conf This file is used to configure which services are to be used to determine information such as
hostnames, password files, and group
/etc/ntpd.conf This file is used to configure Network Time Deamon
/etc/inetd.conf This file tells which ports to listen to and what server to start for each port
/etc/syslog.conf This file have the configuration log file location and rotation sequence
/etc/sudoers contains the list of user names with the command allowed to execute by the user with additional privileges
/etc/fstab This file contains the list of file system and it mount points
/etc/resolv.conf contains the DNS server names for the name resolution

Page 4 of 4

Vous aimerez peut-être aussi