Skip to content

Instantly share code, notes, and snippets.

@vijoin
Created March 19, 2020 02:25
Show Gist options
  • Save vijoin/56a44b8d9aff2c4578886a5e1cc99ea5 to your computer and use it in GitHub Desktop.
Save vijoin/56a44b8d9aff2c4578886a5e1cc99ea5 to your computer and use it in GitHub Desktop.
Notes about Linux Terminal course at Platzi (Spanish Course)
Notes from https://platzi.com/clases/terminal/ (Spanish Course)
## Why:
Efficiency... Speed up your tasks
##Prompt and Cursor
## Command
Program + Parameters + Modifiers
`command arg -flag1`
## Utilities
* Wildcards
* Keyboard shortcuts
* commands sustitution
### Keyboard shortcuts
ma + tab
key arrow up
control + R
# useful commands
* history
### File commands
`ls` list files
`ls -a` list files, including hidden files
`ls -l` list files, including details about directories and files
`ls -lh` sames as above, but size in MB
`ls -R` show files recursively
`ls -t` order files by modification date
`ls -x` order files by extension
`ls -S` order by file size
`pwd` (print woriking directory) currrent directory
`cd` (change directory)
`cd ~` shortcut to go to home
`cd -` go to last visited directory
`mkdir` create directory
`cp` copy file
`cp -r` (recursive copy) used for directories
`rm` (remove) delete a file
`rmdir` remove a directory
`mv` move file or directory... or rename a file
### vim
`$ vim`
`i` Insert
`w` save
`q` quit
### nano
`control + o` save
`control + x` quit
### Batch utilities
`touch file.txt` create a file
`cat` show whole file content
`head` show first 10 lines
`head -n 5` show N first lines
`tail` show last 10 lines
`tail -n 5` show last N lines
`grep` filter a line by given word
`grep -i` case unsensitive
`grep -i "word$"` find a line that ends with `word`
`grep -i "^word"` find a line that starts with `word`
`sed 's/word/new_word/g'` (Stream Editor) find a word and replace it with new_word in every appearence
`sed '$d'` remove last line
- Mor about set https://likegeeks.com/es/sed-de-linux/.
`awk -F ';' '{ print $1 }' file.csv`
`awk -F ';' 'NR > 1 && $3 >0 { print $1, $3 * $4 }' file.csv`
### Stream modification
`command < fileinput.txt` insert all text as input to the command
`command > fileoutput.txt` save all the command output into the file (repplace all existing content)
`command >> fileoutput.txt` save all the output to the end of file (doesn't replace existing content)
`ls -l | more` use pipe ( | ) to redirect the output to the input of another command
### process administration (background and foreground)
`cmd1 &` allows me to keep working, even if the cmd1 hasn't finished yet
`cmd1 ... then control + z ` same as above
`fg` recover the background command
`ps aux` show all running commands
`ps aux | grep cmd1` shows if `cmd1` is running
`pkill -9 1234` stops the process id 1234
kills sends a signal, pkill stops it inmediatly
### permissions
r=4 w=2 x=1
d rwx rwx rwx (777)
d r-x r-x r-x (555)
`chmod o-w file.txt` remove write permission to others
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment