Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Monday, December 5, 2011

Day To Day UNIX Commands


1. $ ssh username@servername command used to login to server
2$ pwd it prints present working directory
3$ ls -l listing the files in present directory
4$ cd..takes you to previous Dir
5$ mkdir <directory>will create directory
6$ mkdir -p /home/user1/d1/d2/d3will create all the non-existing Dir’s
7$ vi <file_name>opens file for reading/editing
8$ cat <file_name>display contents of file
9$ more <file_name>displays page by page contents of file
10$ grep <pattern> file_namechecks pattern/word in file name specified
11$ head <file_name>shows first 10 lines of file_name
12$ touch <file_name>creates a zero/dummy file
13$ ln file1 file2 creates link of file1 to file2
14$ cp <file1> <file2>Copy a file
15$ mv <file1> <file2>Move/rename a file or folder
16$ clearclears the scree
17$ whoDisplays logged in user to the system.
18$ file <file_name>shows what type of file it is like
19$wwill display more info abt the users logged in
20$ ps -efshows process
21$ which <file_name>shows if the file_name/command exists and if exists display the path
22$ rm <file_name>will delete file specified$ rm * Delete all the files in the present directory (BE CAREFUL WHILE GIVING THIS COMMAND)
23$ find . -type f -print -exec grep -i <type_ur_text_here> {} \;this is recursive grep$ find / -name <file_name> -print
24$ tail <file_name>shows last 10 lines of fileuse tail -f for continous update of file_name
25$ chmod 777 <file_name>changes file_name/directory permissions use –R switch for recursive
26$ chown owner:group <file_name>changes owner & group for the file_name
27$ chgrp <groupname> <filename>use –R for recursive
28$ rsh -l <login_name> <server_name>
29$ rcp file1 file2Copying file to remoter servers (This requires pre-configuration on remote servers like .rhosts & hosts.equiv)
30$ gunzip <file_name>unzips file name$ gzip <file_name>zips file_name
31$uncompress <filename>uncompresses filename
32$ compress <file_name>compresses file_name
33$ bc -lbench calculator
40$ crontab -lShows 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)
41$ at$ at -l will show the at jobs scheduledat – schedule a job to run later timeat <time> command/script (will run the script at specified time)
42killing an unwanted process$ps –ef | grep <process_name> (will show the PID of the process in the 2nd field)$kill -9 <PID>$ kill -3 <PID>Used to take threaddump of java process
43$ 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.
44$ uptimewill show how long the system has been up and also shows cpu load, number of users logged in etc.
45$ lastWill show the users logged in/out informationlast <user_name> shows particular user logins/logoutslast reboot shows all the system boots
46$ idshows current user's UID, username and GID and group name
47$ hostidshows unique identifier of host
48$ uname -awill show system name, solaris version, platform and some more information
49$ isainfo -vshows supported platforms (32-bit, 64-bit)
50$ hostnamewill give your system name.
51$ envList the environmental variables set to your current session
52$ rm - <-filename>for deleting special files$ rm "<file name>"delete file names with spaces in between
53$ useradd <username>Adding a user to the system$ userdel <username>Deleting a user from the system
54$ echo $TERMShows terminal type like vt100, vt220 etc.($PATH, $ORACLE_HOME etc can be used with echo)
55$ du –sk <dir/file name>Display the size of the files/folder
56$ df -kwill show all the mounted filesystems.
57$ mountwill show all mounted file systems with additional info like large filesystem support etc
58$ pkginfo Gives/shows info about installed packages/software on system
59$ showrev –pshows all patches installed on system
60$ init 0will shutdown the system
61$ init 6will reboot the system (other init options are 1, 2, 3, 5 and S)
62$ alias l='ls -l'alias dir='ls -l|grep "^d"'alias p='pwd'alias c='clear'Short cuts for commonly used commands
63tar -cvf allfile.tar /<directory_name> copies all files under directory to allfile.tar$ tar -xvf allfile.tar /homeretrieves tar files to /home directory$ tar -tvf allfile.tar reads contents of allfile.tar
64$ /usr/sbin/ifconfig -aWill show the ip-address of the system.lo0 : loopback interfacehme0 : hundred MBPS n/w interfaceqfe0 : quad ehternet interface
65$ ping <hostname>will ping and test connectivity between your system and the hostname you give in the ping.you can also give ping <ip-address>
66$ set -o viWhile your shell is set to KSH use this command to display history of commands you are typingPress ESCAPE and k for showing previous commands
67$ ifconfig unplumb hme0 will disable ehternet interface hme0
68$ ifconfig plumb hme0 will enable hme
069$ mount will show the disks mounted and all partitions
70$ top shows all process and memory, cpu etc utilisation
71$ prtconf shows h/w, cpu, memory conf
72$ cd /usr/platform/sun4u/sbin/prtdiag -v shows additional configuration of memory, cpu speed etc..
73$ sysdef shows system h/w, memory, and other internal configurable/tunable paramters
74$ sar –A system archive report, gives total system report for cpu, memory, disk, etcc
75$ mpstat shows multi cpu statistics like load on each cpu.
76$ iostat disk utilisation, cpu, io wait etc (iostat -xcM gives extented statistics of disk activity, cpu etc)
77$ vmstat memory and virtual memory utilization
78$ prstat shows process related statistics (present from solaris 2.7 and above)
79$ netstat shows network statistics
80$ lsof -p <pid>List the opened files for the process
81$ psrinfo gives processor/s information (online/offline)
82$ truss -p <PID>shows system calls and signals (useful when debugging process)
83$ stty erase ^Hsets backspace for deleting typed character
84$ strings <file_name>shows printable strings in any type of file (binary, object, text etc)
85$ formatwill show all the disks configuration and partitions
86$ prtvtoc shows disk partition/geometry info
87$ uadmin 2 0 stops system immediately within 5 seconds(BE CAREFUL-- has to be to root)
88$ halthalts processor and reboots machine (BECAREFUL -- has to be root)
89$ adb debugging tool (for reading/debugging corefiles)
90$ dos2unix <filename>Convert dos formatted file to unix format
91$ mkfile 60m <swap file name>creates a filename of size 60mb which can be used for adding to swap space
92$ swap -a <swap file name>attaches the 60mb file to swap space (Very useful when swap space is running out)
93$ swap -l lists the swap contents
94$ sleep 5waits for 5 seconds (useful in shell scripts)
95$ cat <file_name> |awk '{print $1}'Prints the first field of the filed ($1, $2... can be used to display more fields)
96:1,$s/<old>/<new>/guse the above for global replacement of text in ascii files using vi editor
97:1,$s/^M//gremove Ctrl M character in text files using vi editor
98$ ksh –x <file name.sh>Will compile the shell file line by line
99PS1=[$(hostname)]'$ORACLE_SID@$PWD>'Add this entry on .profile , you can view the hostname , $VARIABLE,current directort path
100$ipcs –mbWill provide the shared memory information
101$ mailx -s"<Subject Name>" user1@cognizant.com.com < file.txtWill send this file.txt to a mail$ uuencode $file $file| mail -s "<Subject Name>" user1@domian.comWill 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

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect