Last active
November 22, 2024 14:01
-
-
Save abid019/85e815782daa2369c5e95d1e7dea40eb to your computer and use it in GitHub Desktop.
CLI commands drill 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################ PIPES ############################################################# | |
# Printing all the data from the url | |
curl https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt | |
# Save all the data from the url to the file harry_potter | |
curl -o harry_potter https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt | |
# Print first three line of the file harry_potter | |
head -n 3 harry_potter | |
# Print last 10 line of the file harry_potter | |
tail -n 10 harry_potter | |
# find the counts of the Harry in harry_potter -> total words = 2591 | |
grep Harry harry_potter | |
# find the counts of the Ron in harry_potter -> total words = 947 | |
grep Ron harry_potter | |
# find the counts of the Hermione in harry_potter -> total words = 822 | |
grep Hermione harry_potter | |
# find the counts of the Dumbledore in harry_potter -> total words = 507 | |
grep Dumbledore harry_potter | |
# to get the line from 100 to 200 form harry_potter using sed command | |
sed -n '100,200p' harry_potter | |
# to get the line from 100 to 200 form harry_potter using awk command | |
awk 'NR>=100 && NR<=200' harry_potter | |
# to get the line from 100 to 200 form harry_potter using head pipe tail command | |
head -n 200 harry_potter | tail -n 101 | |
# to get the number of unique words -> total uniq word = 11577 | |
tr -c '[:alnum:]' '\n' < harry_potter | sort | uniq | wc -l | |
############################ Processes, ports ############################################################# | |
pgrep chrome # get the PID of chrome browser -> PID = 1049 | |
ps -ef | grep chrome # get the PPID of chrome browser. -> PPID = 1 PID = 1049 | |
killall "Google Chrome" # kill the chrome browser from command line | |
top -l 1 -o cpu | head -n 15 # run the top 3 cpu process using top command | |
top -l 1 -o mem | head -n 15 # run the top 3 mem process using top command | |
cd ~/desktop/linuxlesson # move to linuxlesson to run the python script | |
python3 -m http.server 8000 # run the python script on port 8000 | |
pkill -f http.server # to kill the http server from different terminal | |
sudo python3 -m http.server 90 # run the python script on port 90 | |
netstat -an | grep -E 'tcp|udp' # connection of TCP and UDP simultaneously | |
cd ~/desktop/linuxlesson # move to linuxlesson to run the python script | |
python3 -m http.server 5432 # run the python script on port 5432 | |
sudo netstat -anp tcp | grep 5432 # find the PID of localhost 5432 using netstat PID - 5432 | |
sudo lsof -i :5432 # this gives me the PID of localhost 5432 -> PID - 10779 | |
############################ Managing software ############################################################# | |
brew install htop # to install htop from brew | |
brew install vim # to install vim from brew | |
brew install nginx # to install nginx from brew | |
brew uninstall nginx # to uninstall nginx from brew | |
############################################################# Misc ############################################################ | |
ifconfig | grep "inet" # gives inet(ipv4) as well as inet6(ipv6) | |
ping google.com # gives the ping of the google.com which include ip address | |
ping google.com # gives the ping of the google.com which shows my internet is working | |
which node # gives the path of the node | |
which code # gives the path of the code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment