Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

101 Unix Commands

Objective

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

Commands No Commands No Commands


No

$ ssh $ pwd $ ls -l
username@servername it prints present working listing the files in present directory
2 3
1 command used to login to directory
server
$ cd.. $ mkdir <directory> $ mkdir -p /home/user1/d1/d2/d3
takes you to previous Dir 5 will create directory 6 will create all the non-existing Dir’s
4
$ vi <file_name> $ cat <file_name> $ more <file_name>
7 opens file for reading/editing 8 display contents of file 9 displays page by page contents of
file
$ grep <pattern> $ head <file_name> $ touch <file_name>
file_name shows first 10 lines of creates a zero/dummy file
10 checks pattern/word in file 11 file_name 12
name specified

$ ln file1 file2 $ cp <file1> <file2> $ mv <file1> <file2>


13 creates link of file1 to file2 14 Copy a file 15 Move/rename a file or folder

$ clear $ who $ file <file_name>


16 clears the scree 17 Displays logged in user to the 18 shows what type of file it is like
system.
$w $ ps -ef $ which <file_name>
19 will display more info abt the shows process shows if the file_name/command
20 21
users logged in exists and if exists display the path

$ rm <file_name> $ find . -type f -print -exec $ tail <file_name>


will delete file specified grep -i <type_ur_text_here> shows last 10 lines of file
$ rm * {} \; use tail -f for continous update of
22 Delete all the files in the this is recursive grep file_name
23 24
present directory (BE $ find / -name <file_name>
CAREFUL WHILE GIVING -print
THIS COMMAND)

$ chmod 777 <file_name> $ chown owner:group $ chgrp <groupname>


changes file_name/directory <file_name> <filename>
25 permissions 26 changes owner & group for 27 use –R for recursive
use –R switch for recursive the file_name

$ rsh -l <login_name> $ rcp file1 file2 $ gunzip <file_name>


<server_name> Copying file to remoter unzips file name
servers (This requires pre- $ gzip <file_name>
28 29 configuration on remote 30 zips file_name
servers like .rhosts &
hosts.equiv)

$uncompress <filename> $ compress <file_name> $ bc -l


31 uncompresses filename 32 compresses file_name 33 bench calculator

Page 1 of 4
101 Unix Commands
Commands No Commands No Commands
No

$ crontab -l $ at killing an unwanted process


Shows the cron jobs $ at -l will show the at jobs $ps –ef | grep <process_name>
running/scheduled for the scheduled (will show the PID of the process in
current user. the 2nd field)
-->$crontab -l > at – schedule a job to run later
present_cronjobs time $kill -9 <PID>
40 -->edit/add entries to 41 42
at <time> command/script (will
present_cronjobs
run the script at specified $ kill -3 <PID>
-->$crontab time)
present_cronjobs (This will Used to take threaddump of java
submit/resubmit the jobs in process
file presnt_cronjobs to
CRON)
$ nohup <cmd_name> & $ uptime $ last
nohup is very useful will show how long the system Will show the users logged in/out
command. it runs the has been up and also shows information
43 command even the telnet cpu load, number of users last <user_name> shows
44 45
connection is logged in etc. particular user logins/logouts
closed/broken. last reboot shows all the
& is used for running system boots
command in background.
$ id $ hostid $ uname -a
46 shows current user's UID, will show system name, solaris
47 48
username and GID and shows unique identifier of host version, platform and some more
group name information
$ isainfo -v $ hostname $ env
49 shows supported platforms will give your system name. List the environmental variables
50 51
(32-bit, 64-bit) set to your current session

$ rm - <-filename> $ useradd <username> $ echo $TERM


for deleting special files Adding a user to the system Shows terminal type like vt100,
52 $ rm "<file name>" $ userdel <username> vt220 etc.
53 54
delete file names with Deleting a user from the ($PATH, $ORACLE_HOME etc
spaces in between system can be used with echo)

$ du –sk <dir/file name> $ df -k $ mount


55 Display the size of the will show all the mounted will show all mounted file systems
56 57
files/folder filesystems. with additional info like large
filesystem support etc
$ pkginfo $ showrev –p $ init 0
58 Gives/shows info about shows all patches installed on will shutdown the system
59 60
installed packages/software system
on system
$ init 6 $ alias l='ls -l' tar -cvf allfile.tar
alias dir='ls -l|grep "^d"' /<directory_name>
will reboot the system (other alias p='pwd' copies all files under directory to
init options are 1, 2, 3, 5 alias c='clear' allfile.tar
61 and S) 62 63 $ tar -xvf allfile.tar /home
Short cuts for commonly used
commands retrieves tar files to /home
directory
$ tar -tvf allfile.tar
reads contents of allfile.tar

Page 2 of 4
101 Unix Commands
Commands No Commands No Commands
No

$ /usr/sbin/ifconfig -a $ ping <hostname> $ set -o vi


Will show the ip-address of will ping and test connectivity
the system. between your system and the While your shell is set to KSH use
64 lo0 : loopback interface hostname you give in the ping. this command to display history of
65 66
hme0 : hundred MBPS n/w you can also give ping <ip- commands you are typing
interface address> Press ESCAPE and k for showing
qfe0 : quad ehternet previous commands
interface
$ ifconfig unplumb hme0 $ ifconfig plumb hme0 $ mount
67 will disable ehternet 68 will enable hme0 69 will show the disks mounted and
interface hme0 all partitions
$ top $ prtconf $ cd
shows all process and shows h/w, cpu, memory conf /usr/platform/sun4u/sbin/prtdiag
70 memory, cpu etc utilisation 71 72 -v
shows additional configuration of
memory, cpu speed etc..
$ sysdef $ sar –A $ mpstat
shows system h/w, memory, system archive report, gives shows multi cpu statistics like load
73 and other internal 74 total system report for cpu, 75 on each cpu.
configurable/tunable memory, disk, etcc
paramters
$ iostat $ vmstat $ prstat
disk utilisation, cpu, io wait memory and virtual memory shows process related statistics
76 etc (iostat -xcM gives 77 utilization 78 (present from solaris 2.7 and
extented statistics of disk above)
activity, cpu etc)
$ netstat $ lsof -p <pid> $ psrinfo
79 shows network statistics 80 List the opened files for the 81 gives processor/s information
process (online/offline)
$ truss -p <PID> $ stty erase ^H $ strings <file_name>
82 shows system calls and sets backspace for deleting shows printable strings in any type
83 84
signals (useful when typed character of file (binary, object, text etc)
debugging process)
$ format $ prtvtoc $ uadmin 2 0
85 will show all the disks shows disk partition/geometry stops system immediately within 5
86 87
configuration and partitions info seconds(BE CAREFUL-- has to be
to root)
$ halt $ adb $ dos2unix <filename>
halts processor and reboots debugging tool (for Convert dos formatted file to unix
88 machine (BECAREFUL -- 89 reading/debugging corefiles) 90 format
has to be root)

$ mkfile 60m <swap file $ swap -a <swap file name> $ swap -l


name> attaches the 60mb file to swap lists the swap contents
91 creates a filename of size space (Very useful when swap
92 93
60mb which can be used for space is running out)
adding to swap space

94 $ sleep 5 95 $ cat <file_name> |awk 96 :1,$s/<old>/<new>/g


waits for 5 seconds (useful '{print $1}' use the above for global
in shell scripts) Prints the first field of the filed replacement of text in ascii files
($1, $2... can be used to using vi editor

Page 3 of 4
101 Unix Commands
Commands No Commands No Commands
No

display more fields)


:1,$s/^M//g $ ksh –x <file name.sh> PS1=[$
remove Ctrl M character in Will compile the shell file line (hostname)]'$ORACLE_SID@$PWD
97 text files using vi editor by line >'
98 99
Add this entry on .profile , you can
view the hostname ,
$VARIABLE,current directort path
$ipcs –mb $ mailx -s"<Subject Name>" user1@cognizant.com.com < file.txt
Will provide the shared Will send this file.txt to a mail
100 memory information 10
$ uuencode $file $file| mail -s "<Subject Name>" user1@domian.com
1
Will send the files as an attachment.

Important Directories to Remeber


/  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

You might also like