Linux Commands Network Engineers Should Know

Here I sampled a list of useful commands that you will encounter at least once, in your ilfe as a network engineer:

cd /tmp    :go to the /tmp folder

Commands related to storage and disks

df -h   : check available disk space

Commands related to network

ethtool -s eth0 speed 1000 autoneg off   : changes the speed and the autonegotiation mode of the Ethernet0 interface.

ifconfig eth0 192.168.1.252 netmask 255.255.255.0 up  sets the IP address of a NIC card Eth0 and brings it up.

ip route add default via 192.168.1.1 dev Eth0  sets the default gateway of 192.168.1.1 to interface Eth0.

ip route add 172.16.1.0/28 via 172.16.2.55 dev eth0   : adds a static route to network 172.16.1.0/28, using gateway 172.16.2.55, across the Ethernet0 interface.

 ip route del 172.16.1.0/28 via 172.16.2.55 dev eth0   : deletes the static route to network 172.16.1.0/28, using gateway 172.16.2.55, across the Ethernet0 interface.

Other commands

ls -alh /bin/ls   : displays permissions on a file. For example, this command gives the following output:

[highlight]-rwxr-xr-x 1 root root 75K Mar 27  2012 /bin/ls[/highlight]

rpm -ivh blabla.rpm   : installs the RPM package blabla.rpm

rpm -qa | grep XXX  : verifies if the RPM package XXX is installed or  not

rpm -qa | grep XXX | xargs rpm -e   : verifies if the RPM package XXX is installed or not, and if it is installed, tell the system to remove it. The xargs command takes the preceding output (result of grep XXX) as input and applies an instruction to it (rpm -e)

tcpdump -w MyFile.pcap -i eth0   : dumps the network packets on interface Ethernet0, and write the output in raw format to file MyFile.pcap. Note that MyFile.pcap must be created first.

unzip MyFile.zip    : this is straightforward. The command unzips the file in the current directory. Often the RPM files you download from the Internet are in Zip format. Use the unzip command for that purpose.

Leave a Comment