Working With Linux, Basic Commands

Recently I was working on a Nokia’s LTE & UMTS Automated Operations and Recovery (AOR), a product which simplifies service operations by automating network supervisory activities .  I had a team from diverse background like transmission,RF,Core,Networks,Java developers,Database and our task was to test Linux based opensource application which obviously needed good knowledge of Linux CLI.

Linux Command-Line provides a richer experience in terms of speed and expressiveness. Linux Operating system is most popular operating systems to run server-side applications,telecom NFV, Openstack, Dockers,Kubernetes,Database and Web based applications.In fact  almost all Java applications are running on Linux.The telecom equipment’s uses Linux as Network operating system, as an example Juniper routers running JUNOS which runs Linux natively. Linux is very popular on embedded platforms too. So lets get on to the Linux commands compilation .

  1. Working with the file

    Search And Replace in the file :s/raga/namo/g
    Find each occurrence of ‘raga’ (in the current line only), and replace it with ‘namo’.
    Find each occurrence of ‘raga’ (in all lines), and replace it with ‘namo’.
    Change each ‘raga’ to ‘namo’, but get the confirmation first.
    Change only whole words exactly matching ‘raga’ to ‘namo’; ask for confirmation.
    Change each ‘raga’ (case insensitive due to the i flag) to ‘namo’; ask for confirmation.
    :%s/raga\c/namo/gc is the same because \c makes the search case insensitive.
    This may be wanted after using :set noignorecase to make searches case sensitive (the default). To remove all the lines above the current cursor position use command dgg where d is the deletion command, and gg is a movement command that says go to the top of the file, so when used together, it means delete from my current position to the top of the file. Similarly dG will delete all lines at or below the current one . In summary dgg and dG are the commands to use.

Command Summary

 vi filename    edit a file named "filename"
 vi newfile     create a new file named "newfile"


 i            insert text left of cursor
 a            append text right of cursor


 h            left one space
 j            down one line
 k            up one line
 l            right one space


 x         delete character
 nx        delete n characters
 X         delete character before cursor
 dw        delete word
 ndw       delete n words
 dd        delete line
 ndd       delete n lines
 D         delete characters from cursor to end of line
 r         replace character under cursor
 cw        replace a word
 ncw       replace n words
 C         change text from cursor to end of line
 o         insert blank line below cursor
              (ready for insertion)
 O         insert blank line above cursor
              (ready for insertion)
 J         join succeeding line to current cursor line
 nJ        join n succeeding lines to current cursor line
 u         undo last change
 U         restore current line


 w            forward word by word
 b            backward word by word
 $            to end of line
 0 (zero)     to beginning of line
 H            to top line of screen
 M            to middle line of screen
 L            to last line of screen
 G            to last line of file
 1G           to first line of file
 <Control>f   scroll forward one screen
 <Control>b   scroll backward one screen
 <Control>d   scroll down one-half screen
 <Control>u   scroll up one-half screen
 n            repeat last search in same direction
 N            repeat last search in opposite direction


 ZZ            save file and then quit
 :w            save file
 :q!            discard changes and quit file

To empty the file use “> file.txt” in command mode, where file.txt is your file name

2) Commands to gather system and Hardware information

cat /proc/meminfo
cat /proc/cpuinfo
dmidecode Command – Shows Linux Hardware Info
dmidecode –type processor
inxi -C
lshw Tool – List Hardware Configuration
lshw -C CPU
hwinfo –cpu

You may need additional packages to run the above commands.
yum install inxi
yum install cpuid

3) Networking commands.

# ifconfig
# ifconfig eth0
Assigning IP Address and Gateway
# ifconfig eth0 netmask
Enable or Disable Specific Interface
# ifup eth0
#ifdown eth0
Setting MTU Size
# ifconfig eth0 mtu <1234>
Set Interface in Promiscuous mode
# ifconfig eth0 – promisc
ARP Command,To view / add the contents of the kernel’s ARP tables.
#arp -e
test connectivity between two nodes
# ping -c 5
shows number of hops taken to reach destination
Netstat (Network Statistic) command display connection, routing table information
#netstat -r
Dig (domain information groper) query DNS related information like A Record, CNAME, MX Record
#host -t CNAME
Route command to display and manipulate ip routing table
Route Adding
#route add -net gw
#route del -net gw

Leave a Reply

Your email address will not be published. Required fields are marked *