Sunday, April 30, 2017

Some Linux Commands

How to delete files older than 3 days:
find . -name ‘*.*’ -mtime +3 -exec rm {} \;

How to list files modified in last 3 days:
find . -mtime -3 -exec ls -lt {} \;

How to sort files based on Size of file:
ls -l | sort -nrk 5 | more

How to find CPU & Memory:
cat /proc/cpuinfo
cat /proc/meminfo

How to find if any service is listening on particular port or not:
netstat -an | grep (port no)
Example :
netstat -an | grep 7001

How to find Process ID (PID) associated with any port:
lsof | grep 7001

How to find a pattern in some file in a directory:
To find pattern in particular file :
grep pattern file_name
To find in all files in that directory
grep pattern * 

How to create symbolic link to a file:
ln -s target source

No comments:

Post a Comment

  Opatch reports 'Cyclic Dependency Detected' error when patching ODI   Issue: When applying a Patch Set Update (PSU) to WebLogic Se...