Académique Documents
Professionnel Documents
Culture Documents
If you know the file name and file system but not sure the exact
folder path then you can use this syntax. In below example, I am
searching for messages file in /var file system.
/var/log/messages
[root@Chandan ~]#
Tips: if you dont know the file system name, you can search on /
level but keep in mind it may take time if you have a large number
of file systems.
/var/log/messages
[root@Chandan ~]#
If you dont know the exact file name, you can also use wildcard
pattern to search. For ex to search error_log you may try
/var/log/httpd/error_log
[root@Chandan ~]#
How about searching file name with lower or upper case in other
word ignoring case sensitive? Well, you can use iname instead
of name. For ex:-
[root@Chandan var]# find / -iname MESSAGES
/var/log/messages
[root@Chandan var]#
Lets take a look at one more real-time scenario. If you know the
file type and want to search all of them. For ex if you are working
on WebSphere, you may want to search all files ending with .out
then you can try
/opt/testing
/opt/SystemOut.log
[root@Chandan ~]#
Tips: how about printing file ownership, the time stamp in same
line command?
[root@Chandan ~]#
You may also change permission from 777 to 755 in single find
command syntax.
Obviously, you can adjust permission from 755 to any other you
may like.
Guess what will happen when you restart next time with
tomcatapp? It wont because some of the files ownership is
changed to root and now tomcatapp cant modify/delete those
files. So this becomes very handy in that situation. Here is how you
can search any file owned by root in specific file system.
Tips: if you decide to find and delete in same command line you
can do like below. This will find access.log older than 60 days in
/opt file system and delete it.
While this is very handy, you may want to list the files before you
delete them. To do so
Tips: If you know all files in /opt/ with more than 1 GB can be
deleted then you can just have find and delete in same line.
I hope above find commands are handy to you and help you in real-
time.
Middleware was second hottest skills of 2014 and there is no
reason to go down in coming years. If you recently started working
on WebSphere or any other product suite of Middleware then one
of the very first things to get familiar is widely used Linux
commands.
Finding SystemOut.log
Tips: if you are having multiple file system then it may take a time
to search. So best would be to replace / with actual file system
where you think the log would be. Lets say you believe log is in
/opt file system so you can do like this.
Quite often you will have to deal with port conflict issue, especially
on the shared environment. If there is a situation to find out which
process is holding port number then here is how you can know.
[root@Chandan ~]#
#who b
[root@Chandan ~]#
who -b command will give you exact date and time of server
reboot.
Alternatively, you may also use up time to check how long the
server is up.
[root@Chandan ~]#
Check CPU/Memory utilization in runtime
If you are having performance issue then you might want to know
the current CPU/Memory utilization. This will help you to find out
which process is taking high CPU/Memory in real-time.
#top
Tips: look for CPU/Memory section for first few PID to find out the
utilization.
Alternatively, you may also use free command to find out total
and free memory.
#free m
Swap: 0 0 0
[root@Chandan ~]#
As you can see above, there is 490 MB total memory and only 46
MB memory is available.
#sar
sar -r
#kill PID
If above doesnt help, you can use -9 to kill the process forcefully.
#kill -9 PID
Most often you will have to deal with compressing the files as
housekeeping activity for a file system.
Compression
#gzip filename
Extraction
#gunzip filename
Tips: you can use gunzip * which will help you to extract all gz file
in that working directory.
Total CPU, Memory, File System
CPU information
Find out CPU Cores, MHz, CPU manufacturer, Model Name and
much more by using
#cat /proc/cpuinfo
Memory information
To find out total available memory, you can use one of the
following commands.
First one.
#free G
Second one
#cat /proc/meminfo
This will show you much more information along with total
memory.
To find out file system size and usage, you can use df commands.
#df h
[root@Chandan tmp]# df -h
[root@Chandan tmp]#
collisions:0 txqueuelen:1000
[root@Chandan tmp]#
As you can see above, ifconfig will show the IP addresses, Ethernet
details, a hardware address (MAC), subnet mask, errors and other
details. This is the extremely useful handy command if you are
looking for this information.
Tips: you can use a with ifconfig to show all available Ethernet
details. Ex:
#ifconfig a
[
<=>
] 65,435 --.-K/s in 0.005s
[root@Chandan tmp]#
Tips: above you can see HTTP response code is 200 means
there is no issue in connectivity.
Connected to geekflare.com.
This may not be used all the times but extremely helpful when you
have latency issue or just want to find out the connection path
between your server to the destination. Below example is to show
the network path from my server to geekflare.com
[root@Chandan tmp]#
Ownership modification
If you are dealing with multiple users on a server and having root
permission too then most likely once in a while, you will screw with
permission/ownership. Well, not to worry its part of learning. Here
is the quick way to change the ownership or permission.
Change ownership