Skip to content

Instantly share code, notes, and snippets.

@singh011
Last active November 10, 2020 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singh011/40f6c56a52552d233517bc714b8ba517 to your computer and use it in GitHub Desktop.
Save singh011/40f6c56a52552d233517bc714b8ba517 to your computer and use it in GitHub Desktop.
Dharmendra_CLI_Drills_II
Pipes---
1.Download the contents of "Harry Potter and the Goblet of fire" using the command line from here
wget https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt
1. Print the first three lines in the book
head -3 harry.txt
2.Print the last 10 lines in the book
tail -10 harry.txt
3. How many times do the following words occur in the book?
  => grep -o Harry Harray.txt | wc -l
  =>grep -o Ron Harry.txt  | wc -l
=>grep -o Hermione Harry.txt | wc -l
4.Print lines from 100 through 200 in the book
head -200 Harry.txt | tail -101
5. How many unique words are present in the book?
tr ' ' '\n' < Harry.txt | sort|uniq|wc -l
Processes, ports------
1-List your browser's process ids (pid) and parent process ids(ppid)
ps -o pid,ppid -e
2-Stop the browser application from the command line
killall -q firefox
3- List the top 3 processes by CPU usage.
ps -eo pid,ppid,%cpu | head -n 4
4- List the top 3 processes by memory usage.
ps -eo pid,ppid,%mem | head -n 4
5-Start a Python HTTP server on port 8000
python -m SimpleHTTPServer 8000
6- Open another tab. Stop the process you started in the previous step
open another tab :- CTRL + ALT + T
stop process:- sudo kill pid
7-Start a Python HTTP server on port 90
sudo python -m SimpleHTTPServer 90
8- Display all active connections and the corresponding TCP / UDP ports.
netstat -a
9- Find the pid of the process that is listening on port 5432
start server:- sudo python -m SimpleHTTPServer 5432
find pid :- pidof python
stop server:- sudo kill pid
Managing software------
1- Install htop, vim and nginx
sudo apt-get install htop
sudo apt-get install vim
sudo apt-get install nginx
2- Uninstall nginx
sudo apt-get purge nginx nginx-common
Misc----------
1- What's your local IP address?
curl ifconfig.me
2- Find the IP address of google.com
ping google.com
3- How to check if Internet is working using CLI?
sudo nm-online
4- Where is the node command located? What about code?
node command is located in :- nvm and npm
npm install node
nvm install node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment