User Tools

Site Tools


journal:spring2019:dtubbs2:week3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
journal:spring2019:dtubbs2:week3 [2019/01/31 16:02]
dtubbs2
journal:spring2019:dtubbs2:week3 [2019/02/05 16:02] (current)
dtubbs2
Line 14: Line 14:
 ------------------------------------------- -------------------------------------------
 w command and who command lets you know who is on lab46 and what they are doing (i.e. w | more) w command and who command lets you know who is on lab46 and what they are doing (i.e. w | more)
 +-------------------------------------------
 +Typing "​status unix" allows you to check your grade
 +It gives you a live tally of your points and tells you where you rank with the rest of the class.
 +-------------------------------------------
 +Puzzle box 2 is similar to pbx0 but will need more patience
 +-------------------------------------------
 +**UNIX Quotes**
 +1) " " half quotes - allow for expansion especially variable expansion
 +2) ' ' full quotes - literal quote NO expansion
 +3) ` ` (classic way) or $() (newer way) back quote/back tick - perform command expansion
  
 +**Variables** ​
 +name is a variable
 +**Two types of variables**
 +1) declaring <- setting
 +2) accessing <- expanding
 +
 +var1="​stuff"​
 +(Bash can be picky about spacing)
 +
 +Variables are unique to each shell session, if created in one terminal, it won't be in another one
 +
 +"echo $var1" is used to print out contents of var1
 +
 +echo $var1 **# display the contents of var1** allows a comment. the comment starts after #
 +
 +any variable that doesn'​t exist is just an empty variable
 +
 +if you create another variable with the same name as an older variable, the new variable contents replace the old variable contents
 +
 +good practice to put " " around echo command
 +example: echo "​$var1" ​
 +This can be used to create a sentence ​
 +example: echo "The contents of var1 is $var1"
 +
 +can use variable with other commands
 +var is: mypath=/​home/​dtubbs2
 +Type "cd $mypath"​
 +
 +echo "​${mypath}a"​ is used to print variable contents with some string at the end of output
 +
 +\ in echo command will toggle the next character ​
 +Example "echo \${mypath}"​ prints out "​${mypath}"​
 +
 +printenv prints out the variables already created when you log onto a terminal
 +
 +use "​$USER"​ in steps file for projects so it uses the user of that terminal that the command is used
 +
 +use command with absolutely path to avoid headers and what not
 +
 +type /​usr/​bin/​who to find out who is on the system
 +type /​usr/​bin/​who | wc -l to find out how many people are on the system
 +**wc -l gives you a number of lines**
 +type numlogins=`/​usr/​bin/​who | wc -l` to create a variable with the contents being how many users are on the system
 +
 +type echo "​number of users is `/​usr/​bin/​who | wc -l`" gives you an updated number of users on the system every time that command is used
 + ​-------------------------------------------
 +**Types of shells**
 +zsh -> ksh bash (named bourne again shell) -> sh (named bourne after creator)
 +Typing "cat motd" gives you the message of the day that shows up when you log into lab46
 +
 +Typing "cat timezone"​ gives you the time zone (i.e. America/​New_York)
 +-------------------------------------------
 +**DO NOT USE THE "​YES"​ COMMAND UNLESS ABSOLUTELY NECESSARY**
 +-------------------------------------------
 +cowsay -f (animal).cow "​(Message)"​ gives you different types of cows
 +
 +/user/games gets you into the game folder and then type ls. It gives you a list of the games on lab46
 +-------------------------------------------
 +w command and who command lets you know who is on lab46 and what they are doing (i.e. w | more)
 +-------------------------------------------
 +Typing "​status unix" allows you to check your grade
 +It gives you a live tally of your points and tells you where you rank with the rest of the class.
 +-------------------------------------------
 +Puzzle box 2 is similar to pbx0 but will need more patience
 +-------------------------------------------
 +**UNIX Quotes**
 +1) " " half quotes - allow for expansion especially variable expansion
 +2) ' ' full quotes - literal quote NO expansion
 +3) ` ` (classic way) or $() (newer way) back quote/back tick - perform command expansion
 +
 +**Variables** ​
 +name is a variable
 +**Two types of variables**
 +1) declaring <- setting
 +2) accessing <- expanding
 +
 +var1="​stuff"​
 +(Bash can be picky about spacing)
 +
 +Variables are unique to each shell session, if created in one terminal, it won't be in another one
 +
 +"echo $var1" is used to print out contents of var1
 +
 +echo $var1 **# display the contents of var1** allows a comment. the comment starts after #
 +
 +any variable that doesn'​t exist is just an empty variable
 +
 +if you create another variable with the same name as an older variable, the new variable contents replace the old variable contents
 +
 +good practice to put " " around echo command
 +example: echo "​$var1" ​
 +This can be used to create a sentence ​
 +example: echo "The contents of var1 is $var1"
 +
 +can use variable with other commands
 +var is: mypath=/​home/​dtubbs2
 +Type "cd $mypath"​
 +
 +echo "​${mypath}a"​ is used to print variable contents with some string at the end of output
 +-------------------------------------------
 +**Types of shells**
 +zsh -> ksh bash (named bourne again shell) -> sh (named bourne after creator)Typing "cat motd" gives you the message of the day that shows up when you log into lab46
 +
 +Typing "cat timezone"​ gives you the time zone (i.e. America/​New_York)
 +-------------------------------------------
 +**DO NOT USE THE "​YES"​ COMMAND UNLESS ABSOLUTELY NECESSARY**
 +-------------------------------------------
 +cowsay -f (animal).cow "​(Message)"​ gives you different types of cows
 +
 +/user/games gets you into the game folder and then type ls. It gives you a list of the games on lab46
 +-------------------------------------------
 +w command and who command lets you know who is on lab46 and what they are doing (i.e. w | more)
 +-------------------------------------------
 +Typing "​status unix" allows you to check your grade
 +It gives you a live tally of your points and tells you where you rank with the rest of the class.
 +-------------------------------------------
 +Puzzle box 2 is similar to pbx0 but will need more patience
 +-------------------------------------------
 +**UNIX Quotes**
 +1) " " half quotes - allow for expansion especially variable expansion
 +2) ' ' full quotes - literal quote NO expansion
 +3) ` ` (classic way) or $() (newer way) back quote/back tick - perform command expansion
 +
 +**Variables** ​
 +name is a variable
 +**Two types of variables**
 +1) declaring <- setting
 +2) accessing <- expanding
 +
 +var1="​stuff"​
 +(Bash can be picky about spacing)
 +
 +Variables are unique to each shell session, if created in one terminal, it won't be in another one
 +
 +"echo $var1" is used to print out contents of var1
 +
 +echo $var1 **# display the contents of var1** allows a comment. the comment starts after #
 +
 +any variable that doesn'​t exist is just an empty variable
 +
 +if you create another variable with the same name as an older variable, the new variable contents replace the old variable contents
 +
 +good practice to put " " around echo command
 +example: echo "​$var1" ​
 +This can be used to create a sentence ​
 +example: echo "The contents of var1 is $var1"
 +
 +can use variable with other commands
 +var is: mypath=/​home/​dtubbs2
 +Type "cd $mypath"​
 +
 +echo "​${mypath}a"​ is used to print variable contents with some string at the end of output
 +-------------------------------------------
 +**Types of shells**
 +zsh -> ksh bash (named bourne again shell) -> sh (named bourne after creator)
 +-------------------------------------------
 +**Wildcards**
 +1) ? - match 1 of any character
 +2) * - match 0 or more of any character ​
 +3) [] - character class - match 1 of any of enclosed characters
 +4) [^ ] - inverted character class- do not match 1 of any of enclosed characters ​
 +
 +Wildcards are used with __files__
 +
 +Type ls ??? - used for sorting the number of files with that number of characters
 +Type ls ??? | wc -w to give you a number of files with that number of chracters
 +
 +Type ls c* to give you a list of files that start with c
 +Type ls c* | wc -w to give you a number of files that start with c
 +Type ls *c* to give you a list of files that have a c in it
 +Type ls *c*c* to give you a list of files that have 2 or more c's in it
 +
 +Type ls [ct]* to give you a list of files that start with c or t
 +Type ls [c-h]* to give you a list of files that start with c,d,e,f,g or h
 +Type ls [c-h]??? to give you a list of files that start with c,d,e,f,g or h that have 4 characters in length
 + 
journal/spring2019/dtubbs2/week3.txt · Last modified: 2019/02/05 16:02 by dtubbs2