Featured Post

The great debacle of healthcare.gov

This is the first time in history when the president of the United States of America, or probably for any head of state around the world,...

Friday, November 30, 2007

Useful UNIX Commands

Command: grep
Description: finds text within file
Options:
-n - prepend line number into the output file
Example:
grep searches for the into the file
Variation: all

Command: ifconfig
Description: to set network connection
Options:
a - to show all options
Example:
Variation: all

Command: stty
Description: To set the terminal setting.
Options:
a - to show all options
Example: stty erase to set the backspace key to erase command line text.
Variation: all

command: uname
Description: To show the system information
Options: -snrvmapiX
-a - to show system detail
-X - to show detail
Example:
Variation: all

command: Get release version
Description:
cat /var/sadm/softinfo/INST_RELEASE OR cat /etc/release

Command:
sar
Description: Memory usage
Variation:
Solaris

Command:
psrinfo -v
Description: CPU specification
Variation: Solaris

Command:
mpstat
Description: Process Usage
Variation:
Solaris


Command:
prstat
Description: process detail
Options:
-s size
Variations: Solaris

Command:
/usr/sbin/prtconf | grep size
Description: Memory available
Variation: Solaris

Command:
swap
Description: Swap space
Options:
ls
Variations: Solaris


Command:
find /usr/local/web -size +20000 -print
Description: Find the files with minimum given size: it prints file names more than 10MB of sizes
Options:
find
-size
-print
Example: find /usr/local/web -size +20000 -print


Command:
> find . -name file-name
Description: Find a file
Options:

-name
Variation: Solaris
Example:
find . -name file-name

Command: du
Description: Disk usage
Options:
. : current directory
-s: sum of disk usage
-k: in Kilobytes
-h: human readable format
Example: du -sh *
Variation: All

Command: df
Description: Disc space occupied by the filesystem directory/files
Options:
-k: in Kilobytes
Example: du -k | grep /usr/local would show you the size and percentage of usage

Setting environment variable
C Shell
:
Setting environment: setenv PATH "${PATH}:/usr/local:/usr/local/bin"
Unsetting environment: unsetenv PATH


Re-executing the changed shell file
C-Shell: source .cshrc
Korn Shell: . .profile
Bash-Shell: . .bashrc

Check if a process is running:
ps -ef | grep
e.g. to check if apache webserver is running
ps -ef | grep httpd


Change permission and ownership of file
chmod 777 file_name/dir_name
chmod o+rwx file_name/dir_name

chown user_name file_name

Command: checkuser -n netgroup
checkuser -u username
get the detail of the user id

Resourceful Unix command site:

http://www.computerhope.com/unix.htm
http://sysunconfig.net/unixtips/solaris.html
http://www.panix.com/~elflord/unix/grep.html - Grep tutorial

No comments: