LinuxCommandsMaking HTTP RequestsAdvanced CommandsVimModesNormal ModeVisual ModeInsert ModeSpecials (Commands)
Linux
Commands
- Terminal is used to interact with our system with commands
- The other mode of interaction is called the GUI which is graphical
- Many dev tools are only command based and their GUIs don’t exist
ls # To list all the files & folders ls *.js # View all the js files in the folder pwd # tells Current Working Directory mkdir # Create a folder (directory) cd # Navigate to a folder cd ~ # Takes to home cd / # Takes to root head # first few lines from a file tail # last few lines from a file wc filename # view linecount, wordcount, charactercount of a file history # Tells history of commands touch # Create new file echo "Hi" > file.txt # Creates file.txt with "Hi" content rm file # Deletes the file rm -rf folder # Deletes the folder (rf: recursive force) cat file.txt # Concatenate, shows the file content man git # Used to show manual cp # To copy mv # To copy & move nano # Cli based text-editor vi # Cli based code-editor :wq! (To exit) open/start # To open a file # Tricks curl parrot.live # Dancing Parrot curl wttr.in # Weather info curl rate.sx # Crypto info
Making HTTP Requests
The
curl command can be used to make network requestscurl url # GET Request curl -X POST url -H "HEADERS" -d '{JSON}' curl -O url # Download wget url # Used for Downloading ping url # Used to check server latency
Advanced Commands
grep→ Searches for text or patterns in files.
chmod→ Changes file or folder permissions.
sed→ Edits text in a file (like find and replace).
awk→ Extracts and processes data from text (like columns).
chmod ugo-rwx # to add permissions to a file chmod -R ugo-rwx # to add permissions to a folder grep "one" filename # where "one" has been used in the file. sed -n '/ERROR/ p' filename # to print lines with ERROR text. awk '/ERROR/{print $0}' filename # to print lines with ERROR text.
Vim
- It is a full blown editor in terminal built in 1991 which was an improved version of another editor named Vi
- Some of the qualities of Vim are customization, performance and no-mouse control! 🔥
- To enter vim type
viin terminal
- Plain vim is not used alone, an improved version of vim called neovim is used instead
- Neovim can be made into a full blown IDE that uses Lua as it’s programming language 🤺
- Another alternative is NvChad that comes with all the good stuff out of the box on top of Neovim
Modes
- It is called a modal editor as with Vim we are always using some modes.
- There are three common modes in Vim:
- Normal: Navigate with the keyboard
- Visual: Used to select and delete text
- Insert: Used to insert and edit (much like what VS Code gives by default)
- Vim is notorious to exit, simply do
ESC + :wq!to write and quit
Normal Mode
- Normal mode is the default that is used to move in our code
- All these commands to move our cursor is called motion command
- Navigating using the
HLeftJDownKUpLRight
0to go at top and$to go at bottom
eto end of the current word,bto beginning of the previous word
ggto go at the top andGto go at the bottom
pto paste
yto copy (yank)
Visual Mode
- It is used to copy paste and delete text, much like what we do with our mouse
- All the same motion commands (cursor movement)
yto copy (yank)
dto cut (it deletes and also copies it to clipboard for pasting)
Insert Mode
- Type anything buddy!
- Used to type and edit text directly.
- Enter it with
i(insert before),a(after),o(open new line below), etc.
- Exit insert mode with
ESC.
Specials (Commands)
- Press
ESCto go in Normal Mode
:wto write
:qto quit
/to find
:line-numberto go to a line number
uto undo andctrl + rto redo
🐈 echo “Bye”