Important UNIX Commands!!
Please find below important UNIX commands which we generally use in our day to day activities.
du –kh
To get disk usage in Megabytes
du –k | sort –n | tail -10
Shows the ten largest files/directory
awk 'END{print NR}' file_name
To get number of lines in any file
awk '{print $1}' file_name
To print first column of the file
cat /dev/null > file_name or cp /dev/null file_name
Make content zero of the file
tar –cvf file_name.tar file_name
Make tar of any file or directory (tar – tape archive)
tar –xvf file_name.tar
Extract contents of any tar file or directory
lsof -i TCP|PORT_NUMBER or lsof –i | grep PORT_NUMBER
Mapping port with process
pargs PID
To know the process name by using PID
Glance or top or prstat –a or vmstat
To know memory utilization
prtconf | grep Mem
Display Memory Size of the machine
isainfo –bv
To check out whether machine is in 32 or 64 bit mode
last
To know who was or still is on the system
psrinfo
To know about the processors
psrinfo | wc –l
To know total number of processors
uname –a or uname -X
Display system information
who –b
To display the date and time of last reboot
grep PATTERN FILE_NAME
To print all the lines from file this is having this pattern like grep e-business SystemOut.log
gzip FILE_NAME
It will compress the file and save with .gz extension like file_name.gz
gunzip file_name.gz
It will decompress the file.
hostname
It will give you the name of machine which you are using.
netstat –an | grep PORT_NUMBER
To know port is listening or not
ps –ef | grep java
To get PID of all java process
lsof –i | grep PORT_NUMBER
To get PID of port number
pargs PID
To get process name corresponding to this PID
find DIRECTORY_PATH -name "*.*" | xargs grep "" PATTERN
To find out any particular pattern in all files inside any directory
find DIRECTORY_PATH -name 'FILE_NAME' | xargs perl -pi -e 's/SOURCE_PATTERN/DESTINATION_PATTERN /g'
To replace any particular pattern with new pattern in any file in specific directory
history
Display recent commands
who
shows who is logged into the local system
find DIRECTORY_PATH -name FILE_PATH -print
To find out any particular file inside any directory and its sub directory
No comments:
Post a Comment