BYU-Broadcast/Bi-Weekly Training

Shell Training

brightlightkim 2022. 5. 6. 04:05

Unix Shell

 

Path && Moving

  • . means current directory
  • .. means parent directory
  • ../.. goes to two directories
  • '$PATH' means all the environment variables.
    • it will direct to all possible commands that are in $PATHs
  • ~ is short for '$HOME'
    • $ >> Environment variable starts with this

 

Useful Commands

  • env command: show all possible environment variables
  • | pipe oerator: Take output to the input of the next
  • grep command: show only that thing
  • export [env variable] = ['Something']
    • Setting env variables
vim foo
foo
//This command does not work
chmod u+x foo
foo
// This command works

 

//foo
#!/user/bin/env node
echo 'bar'

 

Shell Configuration

  • bash
    • ~/.bashrc
    • ~/.bash_profile
    • ~/.profile
  • zsh
    • ~/.zshrc
  • fish
  • .bashrc

 

. means it's hidden files

ls -l
//l list files
ls -la
//a shows hidden files

 

ln : unlink
# Create Symbolic links
# File short cut
# You can use this to make it to locate in any place
# npm link command

ln -s ~/.local/bin/foo ./foo
ll | grep foo

# You can still use it

htop
# shos a bunch of process that is going now 
# useful when trying to take it and use process id and kill it manually

 

Posix (Portable Operating System Interface)

  • Posix is a set of standard operating system interfaces based on the Unix operating system
  • Usually accopmlished via the pipe '|' operator

 

Echo ['string'] > foo.txt

  • make file

Echo ['string'] >> foo.txt

  • append it to file

 

Riggrep (RUST)

  • Regular Expressions with Riggrep
  • grep 
  • rg -L'(const|let) foo
  • finding command very fast

 

FZF

  • Fuzzy finder
  • try to match other things in the file

 

man

  • Manual Pages
  • search by typing / and include commands
  • shift n  goes backward
  • shift g >> bottom
  • shift gg >> top
  • k j >> moving up and down
    • j goes down
    • k goes up
  • q || ctrl+C || esc
    • to get out

FONTS = 

  • Use in the bash script

&>

  • prevents error to stop the shell

figlet

  • make words 
  • figlet ('hello world')
  • fast work typing 
  • figlet -I2
    • location for the figlet fonts
    • ls -1 (figlet -I2) | grep .flf
      • shows all figlet fonts

less

  • lot of output >> not completing all things >> shows less

 

Directories

  • /opt
    • optional
  • /bin 
    • Contain binaries such as commands
  • /bin

 

System Interrupts

  • ctrl + c : kill programs
  • ctrl + d : Close to the string and go back >> background
    • fg: bring back the froeground and run it
    • bg: process continues running
    • kill: kill the process
      • kill -9 %2 (kill the second process

 

Fun packages:

- hollywood

 

Use the pipelines