Monday, April 9, 2012

Unix/Linux FAQs

Q: How to find if Operating system in 32 bit or 64 bit ?
For solaris use command
isainfo -v
If you see out put like
32-bit sparc applications
That means your O.S. is only 32 bit
but if you see output like
64-bit sparcv9 applications
32-bit sparc applications
above means your o.s. is 64 bit & can support both 32 & 64 bit applications
Q: How to find if any service is listening on particular port or not ?
netstat -an | grep {port no}
For example if you know that OID is running on 389 port so to check if OID services is listening or not then use
netstat -an | grep 389

Q: How to delete files older than N number of days ? (Useful in delete log, trace, tmp file )
find . -name ‘*.*’ -mtime +[N in days] -exec rm {} \; ( This command will delete files older then N days in that directory, always good to use it when you are in applcsf/ tmp,out,log directory)
Q: How to list files modified in last N days
find . -mtime - -exec ls -lt {} \;
So to find files modified in last 3 days
find . -mtime -3 -exec ls -lt {} \;
Q: How to sort files based on Size of file ? ( useful to find large files in log directory to delete in case disk is full )
ls -l | sort -nrk 5 | more
Q: How to find files changed in last N days (Solaris)
find -mtime -N -print
Q: How to extract cpio file
cpio -idmv < file_name (Don’t forget to use sign < before file name) Q: How to find CPU & Memory detail of linux cat /proc/cpuinfo (CPU) cat /proc/meminfo (Memory) Q: How to find Process ID (PID) associated with any port ? This command is useful if any service is running on a particular port (389, 1521..) and that is run away process which you wish to terminate using kill command lsof | grep {port no.} (lsof should be installed and in path) Q: How to change a particular pattern in a file ? Open file using vi or any other editor, go in escape mode (by pressing escape) and use :1,$s/old_pattern/new_parameter/gc ( g will change globally, c will ask for confirmation before changing ) Q: How to find a pattern in some file in a directory ? grep pattern file_name ( to find pattern in particular file ) grep pattern * ( in all files in that directory ) If you know how to find a pattern in files in that directory recursively please answer that as comment Q: How to create symbolic link to a file ? ln -s pointing_to symbolic_name e.g. If you want to create symbolic link from a -> b
ln -s b a
(Condition:you should have file b in that directory & there should not be any file with name a)
Q: How to setup cronjob (cronjob is used to schedule job in Unix at O.s. Level )
crontab -l( list current jobs in cron)
crontab -e ( edit current jobs in cron)
_1_ _2_ _3_ _4_ _5_ executable_or_job
Where
1 - Minutes (0-59)
2 - Hours ( 0-24)
3 - day of month ( 1- 31 )
4 - Month ( 1-12)
5 - A day of week ( 0- 6 ) 0 -> sunday 1-> monday
e.g. 0 3 * * 6 Means run job at 3AM every saturday
Apache Http Status Code
Similar to any other web server, Apache writes or records it`s activities into a Log File, where it logs every request it processes and the error messages or abnormal conditions during the request processing.
A user can look at the Http status code for the information about the activity in the logs files. In this section, we are going to see the list of "Http Status Code" with the information on what these status code means.
Status Code Information
100 To Continue
101 Protocol Switching
200 Things are "OK"
201 Created
202 Accepted
203 Information without authorization
204 No Content
205 Content Reset
206 Partial Content
300 Multiple Choices
301 Permanently Moved
302 Found
303 Look for Others
304 Not Modified
305 Use Proxy
307 Temporary Redirection
400 Bad Request
401 You are not Authorized.
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not acceptable
407 Proxy authentication required
408 Request Timeout
409 Conflict between requests
410 Gone
411 Length is Required
412 Pre-condition Failure
413 Request is Large
414 Request URI is Long
415 Media type is Unsupported
416 Range requested cannot be satisfied
417 Failed Expectations
500 Internal Server Error
501 Not implemented
502 Bad Gateway
503 Service unavailable
504 Gateway timeout
505 HTTP version not supported

No comments:

Post a Comment

kubernetes Pod Scheduling

 ===================   Deployment ================= 1.) Deployment without any nodeName or nodeSelector, pod will spread among all of the av...