Linux Advanced Commands
Linux Advanced Commands
This is the basic usage of grep command. It searches for the given string in the
specified file.
The below grep command searches for the words like “LINUX”, “Linux”, “linux” case
insensitively.
This command will search for "linux" string in multiple files at a time. It
searches in all files with file1.txt, file2.txt and along with different extensions
too like file1.html, file2.php and so on.
It is a very powerful feature and can use as a regular expression with much
effectively.
In the below example, it searches for all the pattern that starts with “fast” and
ends with “host” with anything in-between. i.e
To search “fast[anything in-between]host” in index.html file.
You can use this grep command to display the line number which contains the matched
string in a file using the -n option
If we use the –color option, our successful matches will be highlighted for us.
List all the lines of the file /etc/passwd that does not contain specific word
“string”.
3. top
top command gives you information on the processes that currently exist.
[root@localhost admin]# top
4. htop
It is similar to top, but allows you to scroll vertically and
horizontally, so you can see all the processes running on the
system, along with their full command lines, as well as view-
ing them as a process tree, selecting multiple processes and
acting on them all at once.
(Note: it works only in few distributions of linux)
[root@localhost admin]# htop
5.ps
Use the ps command to list running processes (top and htop list all processes
whether active or inactive).
[root@localhost admin]# ps
6.pstree
A step up from the simple ps command, pstree is used to display a tree diagram
of processes
that also shows relationships that exist between them.
[root@localhost admin]# pstree
7.kill
As its name suggests, kill can be used to terminate a process with
extreme prejudice.
[root@localhost admin]# kill -9 <processid>
=============================================================
#NetStat
netstat command allows you a simple way to review each of your network connections
and open sockets. netstat with head output is very helpful while performing web
server troubleshooting.
------------------------------
nslookup
A network utility program used to obtain information about Internet servers. As its
name suggests, the utility finds name server information for domains by querying
DNS.
[root@localhost home]# nslookup www.google.com
==================================================
Network commands
1.PING
PING(Packet Internet Groper) command sends packet requests to the address you
specify to test the connectivity between 2 nodes
ping IP/hostname
[root@localhost admin]# ping www.google.com
2.ifconfig
Ifconfig utility is used to configure network interface parameters.
Mostly we use this command to check the IP address assigned to the system
[root@localhost admin]#ifconfig -a
3.traceroute
traceroute print the route packets take to network host. Destination host or
IP is mandatory parameter to use this utility
[root@localhost admin]# traceroute www.google.com
4.route
route command is the tool used to display routeing table