Last active
April 30, 2024 10:34
-
-
Save yasaswi-24/07ec323617c458fff2d7ddec8136740a to your computer and use it in GitHub Desktop.
CLI Drills
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
curl -o "harrypotter-gobletoffire.txt" https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt | |
#to take the url of file given and storing as text file using curl -o | |
head -n 3 harrypotter-gobletoffire.txt | |
#to get first lines of code we use head command | |
head -n 5 | |
#harrypotter-gobletoffire.txt | |
tail -n 10 harrypotter-gobletoffire.txt | |
#this means last 10lines of code we use tail for it | |
cat harrypotter-gobletoffire.txt|grep -c Harry | |
cat harrypotter-gobletoffire.txt|grep Harry | |
#this one displays the text highlighting the given name here given harry | |
cat harrypotter-gobletoffire.txt|grep -c Ron | |
cat harrypotter-gobletoffire.txt|grep -c Hermione | |
cat harrypotter-gobletoffire.txt|grep -c Dumbledore | |
sed -n '100,200p' harrypotter-gobletoffire.txt -- to get 100 to 200 lines | |
tr -sc '[:alpha:]' '[\n*]' <harrypotter-gobletoffire.txt | tr '[:upper:]' '[:lower:]'|sort|uniq|wc -l | |
10219 | |
#to count unique characters first we are taking words in it and converting uppercase to lower case and removing duplicates and giving count | |
Processes and Ports | |
ps | |
# to get pids | |
ps -j | |
# to get ppids | |
ps -eo %cpu--sort=-%cpu | head -n 4 | |
#first 3 cpus in sorting order | |
ps -eo %mem--sort=-%mem | head -n 4 | |
#first 3 mem in sorting order | |
python3 -m http.server 8000 | |
s#tarted server on 8000 | |
python3 -m http.server 90 | |
#Started server 90 | |
netstat -tuln | |
#to know tcp and udp ports | |
netstat -tuln | grep 5432 | |
#to know on 5432 | |
#Managing software | |
sudo apt install htop | |
sudo apt install nginx | |
sudo apt install vim | |
sudo apt remove nginx --- it is to remove nginx | |
#Misc | |
curl ifconfig.me | |
#local ip address | |
nslookup google.com | |
#ip address of google.com | |
ping www.google.com | |
#to check if Internet is working using CLI | |
#Node can also be used in a terminal window as a Read-Evaluate-Print-Loop, or REPL. This functionality allows you execute JavaScript commands from the command line. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment