Thursday, August 6, 2009

Linux / Solaris Commands

Commads to use in Unix or Linux or Solaris

#to copy one location to another
scp -r jdk1.5.0_12.tar.gz root@<host-name/host-ip>:/opt/jdk1.5/

#log file
xtail -f /log/*.log

#log a user into a remote system
#Usage: ssh [options] host [command]
ssh -l root <servername>

#Display app name in the list
cd ~/
ln -s /<appname>/ .

#To create symlink
ln -s
/<appname>/ <linkname>

#To get size
du -ks <folder_name/file_name>

#To create tar
tar -cvf <file_name> <folder_name_to_create>
gzip <file_name>

#Removing folder
rm -r <folder_name>

#To edit scheduler
crontab -e

#To get checksum
wget <url(http://hostname/../../file_name)>
md5 <file_name>

#Server version
uname -a

#search
find . -name filename*
find . -name "*filename*" -exec <command> {} \;

#History cmd
~/.bash
~/.bash.profile

#
# The df command is used to display disk space. df stands for disk free.
# df with the -k option displays the output in kilobytes:
#
#
# df [-k] [-P|-t] [-del] [file...]
#
# -k
#
# Use 1024-byte units, instead of the default 512-byte units, when writing space figures.
#
# -P
#
# Use a standard, portable, output format
#
# -t
#
# If XSI compliant, show allocated space as well
#
# file
#
# Write the amount of free space of the file system containing the specified file
#
#
#
#
#
#
df -k *

crontab -l

#To execute cmd line in background

<command_line> &

#Diff b/w files
diff <new_file> <old_file>

#mail server
/etc/mail/aliases(mail ids)

#Server Alert msgs for monitoring the server
# Edit following files to change receivers for alert messages

# Monit - File .monitrc
# Lmon - File lmon_start.sh
# Nagios - on the web (as http://hostname:port/alerts/Config.do?mode=list&rid=10110&type=2&so=dec&sc=1)

#top provides an ongoing look at processor activity in real time.
top

#To get into the DB
/mysql -u root -p
Enter password:password
mysql> show databases;

#vi editor commands
#Search and Replace
# /the — Finds the next occurence of "the". This will also find "their", "them", "another", etc.
# ?the — Finds the previous occurence of "the".
# n — Repeats the last search command. Finds the Next occurence.
# d/the — Deletes until the next occurence of "the". This is to demonstrate how the delete prefix can be used with any cursor movement command.
# :g/oldword/s//newword/gc — This will find all occurences of "oldword" and replace them with "newword". The optional "c" at the end of the command tells vi that you would like to "confirm" each change. Vi will want you to type in "y" to make the change or "n" to skip that replacement. Great for spelling fixes.

#
# '&' - command runs in background
# nohup - nohup is a Unix command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in the background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.
#
nohup find ./ -name "*" -exec du -ks {} \; &
nohup find ../script -name "*" -exec du -ks {} \; &

#===Solaris===
#Hard disk information with filter (execpt declared directories)
df -lk | egrep -v "Filesystem|/proc|/dev/fd|swap" | awk '{ total_kbytes += $2 } { used_kbytes += $3 } END { printf "%d of %d kilobytes in use.\n", used_kbytes, total_kbytes }'

top | grep Memory
psrinfo -v | grep MHz
df -lk | awk '{ total_kbytes += $2 } { used_kbytes += $3 } END { printf "%d of %d kilobytes in use.\n", used_kbytes, total_kbytes }'

/usr/sbin/prtconf | grep Memory
/usr/sbin/psrinfo -v
iostat -E

#Number of processors:
/usr/sbin/psrinfo -p

#Processor:
isainfo -kv

#===Linux===
top | grep Mem
cat /proc/cpuinfo

#In linux you can see memoryinfo from
/proc/meminfo

#OS ->
cat /proc/version

#locate the path of running command
which java

# set the path
set JAVA_HOME= (Win)
export JAVA_HOME= (linux)

# Script to print user information who currently login, current date & time
clear
echo "Hello $USER"
echo -e "Today is \c";date
echo -e "Number of user login : \c" ; who | wc -l
echo "Calendar"
cal
exit

# Script to read your name from keyboard
echo "Your first name please:"
read fname
echo "Hello $fname, Lets be friend!"

No comments:

Post a Comment