pradeep_CLI_Drills_II

Home   »   pradeep_CLI_Drills_II

1. PIPES :
----------
# Downloading the file
    wget https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt
# printing first 3 lines in the book
    head -3 'Harry Potter and the Goblet of Fire.txt'
# printing last 10 lines in the book
    tail -10 'Harry Potter and the Goblet of Fire.txt' 
# Harry word count
    grep -o -i Harry 'Harry Potter and the Goblet of Fire.txt'|wc -w
# Ron word count
    grep -o -i Ron 'Harry Potter and the Goblet of Fire.txt'|wc -w
# Hermione word count
    grep -o -i Hermione 'Harry Potter and the Goblet of Fire.txt'|wc -w
# Dumbledore word count
    grep -o -i Dumbledore 'Harry Potter and the Goblet of Fire.txt'|wc -w
# printing lines from 100 through 200
    awk 'NR>99&&NR<201' 'Harry Potter and the Goblet of Fire.txt' 
# number of unique words
    tr ' ' '\n' < 'Harry Potter and the Goblet of Fire.txt' | sort | uniq | wc -l
    
2. PROCESSES, PORTS :
---------------------
# listing PID and PPID
    ps -ejf
# stops the browser application from the command line
    kill -9 2306
# listing the top 3 processes by CPU usage.
    ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 4
# listing the top 3 processes by memory usage.
    ps -eo pid,comm,%cpu,%mem --sort=-%mem | head -n 4
# Starting a Python HTTP server on port 8000
    python3 -m http.server 8000
# stopping the process in the previous step
    kill -9  #(example: PID = 8691)
# starting a Python HTTP server on port 90
    sudo python3 -m http.server 90
# displaying all connections and corresponding TCP/UDP ports
    sudo apt-get install net-tools
    netstat -a
# Finding the pid of the process that is listening on port 5432
    sudo netstat -nlp | grep 5432
    
3. MANAGING SOFTWARE :
----------------------
# Installing htop, vim and nginx
    sudo apt-get install htop vim nginx
# Uninstalling nginx
    sudo apt-get remove nginx

4. MISC :
---------
# finding local IP address
    ifconfig
# finding IP address of google.com
    nslookup google.com
# for checking the internet connection
    ping google.com
# location of node and uasge of code
    which node #(/usr/bin/node) and code is the command used for Visual Studio Code 



    
    
    
    

Leave a Reply

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