User Tools

Site Tools


user:dtubbs2:start

Introduction

My name is Devon, and I am in my second semester at CCC. I am a Computer Science major and when I am not at school, I am most likely working.

Unix Week 1 January 22, 2019 How to Join Class Chat: Step 1: Make sure your prompt says lab46:~$ Step 2: type into prompt “screen -ls” Step 3: It should say “no sockets found in …” Step 4: Type “screen” Step 5: A new screen should show up, hit enter Step 6: Type “who” Step 7: Hit “ctrl A ” release and then type “ctrl D” Step 8: Type “screen -r” Step 9: Type “irssi” Step 10: Type “/connect irc” (You won't see it being typed) Step 11: Type “/join unix” (You won't see it being typed) Step 12: Type “ctrl A” release and then type “ctrl D” to quit

How to Run Fix Repo: Step 1: Type “fixrepo” Step 2: Enter your Lab46 username Step 3: Enter your Lab46 password Step 4: Type “ls” Step 5: Type “pwd” Step 6: Type “cd src” Step 7: Type “hg status” Step 8: Type “hg add” Step 9: Type “hg status” Step 10: Type “hg commit -m 'Brief update of what you are doing'” Step 11: Type “hg push” Step 12: Enter Lab46 Password

Make Unix directory: Type “mkdir unix” Type “cd unix” Type “mkdir uxi0” Type “cd uxi0”

Submit Project Make sure you are in desired cd location, and type “submit unix uxi0 'File name'”

Homework: See if you can access class resources from home.


Unix Week 2 January 24, 2019 How to Open Lab46 from pod30: Type “ssh lab46”

How to Claim Participation Points: Type “wcp unix wcp(week number, i.e. wcp1)”

Try typing lab46.g7n.org into Putty hostname

Pod## is local host Lab46 is remote host

Typing “who” gives you a list of all users online at that time

Linux = kernel Debian = distribution

Unix is operating system; a multiuser, multitasking operating system

Unix can have multiple users open at the same time and also can have multiple terminals from the same user open therefore it is multitasking

Type pwd to see path to home - absolute path

Types of files when you type “ls”: Blue files are directories (metadata, contain information about other files), gray are regular files, and green are special files

Unix Philosophy: -everything is a file, -small is beautiful (don’t use more data than necessary), -do one thing, and do that one thing extremely well

File operations: delete, copy, move, edit, convert are all combinations of open, create, read, write, append

If you change your cd location, when you type in pwd, it will show you a different absolute path.

CD src is an example of relative path

Use an absolute path to get to a location that isn't directly in your home (type “cd /home/user/…/…

Use this hint for project

To go back ONE directory location type cd .. To go back TWO directory locations type cd ../.. And so on

To go to the next directory location type cd ./nextLocation

”~“ is used as abbreviation for home directory location.

Don't use this if you are having someone do something with your home directory, it won't work.

Typing “ls ~/src” will list you the files in src without going to that file directory.

command[option(s)] ls [option(s)] (doesn't need options to work) cp [option(s)] (needs options to work)

ls -l -d ~/src -l gives you a long listing about the files drwx is file permissions Typing “file ~/src” should tell you what type of file it is Typing ”(command) –help“ should give a list of additional info for the comman Typing “man [option]” opens manual page for that keyword Typing ”/(search word)“ will search through the manual to find certain things on a command

Typing “apropos (search word)” will bring up all of the commands related to the search word

Type “touch (file name)” to create a file

Type “echo (word)” to display something to your terminal

STDIN - Standard Input (keyboard) - <,«,«< STDOUT - Standard Output (terminal) - >,1>,»,1» STDERR - Standard Error (terminal) - 2>, 2» (the 2 is a file disruptor)

Type “echo ”(word))” > file to overwrite file Type “echo ”(word)“” » file to append a file Type “cat (file name)” to see inside of file

Only cat if it is a text file

CP command is used to copy Type “cp (file name) (path)“cp Type “cpp -v …” to get an output to show what was done

MV command is used to rename file or move file Type “mv (old file name or destination) (new file name or destination)”

RM command is used to remove files Type “rm (file name) (file name)” Type “rm -i…” to prompt you

CTRL D End of file CTRL C Signal Interrupt

”>” means continuation prompt # means comment out

-rw——- first spot file type “- = regular file” “d = directory” “l = link” “s = socket” “p = pipe” “b = block device” “c = character device” Next three spots user Second set of three spots group Last set of three spots other Symbols “- = nothing (value of 0)” “x = execute/search (value of 1)” “w = write (value = 2)” “r = read (value of 4)” First digit of octal value “Sticky = t (value of 1)” “setgid = S (value of 2)” “Setuid = S (value of 4)”

“chmod (octal value [i.e. (1)600]) (file name)” - changes permissions

Typing “wemux” brings you into a shared terminal

Using “| more” on commands that produce standard output shows a screen full of commands and then stops until the user gives input to continue showing commands such as hitting space-bar or enter

Example: “ls -l | more”

Using “| less” on commands does something similar to more

Example: “ls -l | less”

“wc” is used for word count

Example output “140 1299 7454” 140 is number of lines, 1299 is number of words, 7454 is number of characters

Proper Pipe Usage 1: Non-interactive commands 2: Only commands that generate standard output 3: Only commands that take standard input

HINT ls z null zero tty 2» /dev/null » /dev/null Removes shown info from ls


Unix Week 3 January 31, 2019 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

\ 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


Unix Week 4 February 7, 2019 Head command Use head command to show you the beginning of a file Example: “/usr/bin/who | head -4” shows you the first four lines of who command

Tail command Use tail command to show you the end of a file Example: “usr/bin/who | tail -4” shows you the last 4 lines of who command

ls will ignore files that start with “.”

ls -a will show you all files, even those that start with “.” —————————————- A double pipe is an “or” operand

vi is text editor

vi .bashrc allows you to edit bash settings

CTRL Commands Pressing “CTRL D” will log you out Pressing “CTRL A” will bring you to the beginning of your command line Pressing “CTRL E” will bring you to the end of your command line Pressing “CTRL H” will backspace, can be used in place of backspace button Pressing “CTRL I” will tab, can be used in place of tab button Pressing “CTRL K” will delete from cursor to end of command line Pressing “CTRL L” will clear the screen Pressing “CTRL M” or “CTRL J” will act like an enter Pressing “CTRL N” will act like down button Pressing “CTRL P” will act like up button Pressing “CTRL S” will stop transmitting Pressing “CTRL Q” will continue transmitting Pressing “CTRL R” will reverse-i-search (history search)

Links2 is a text-based web browser Wget is a non-interactive network downloader curl transfers a URL (similar to Wget)

Start typing a file name or path and hitting tab with auto complete the word Example: “cat dat” then hit tab “cat datafile1” will come up as long as no other files start with dat

How to kill a process from another terminal ps command reports a snapshot of the current processes There are 64 ways to kill a process in Unix Type “kill -(kill number,i.e. 1) (process id [PID])” Kill -9 is the most powerful kill signal


Unix Week 5 February 14, 2019 UPF0

Hint Use the README file to figure out how to extract, compile, and install the numbers.tgz file

Make sure your steps file allows you to download the latest version of pipemath even if a new version is released.

use number tool instead of number

Example: nine | minus `five` Example: five | plus `nine` | minus `seven` | minus `three` output of 4

echo 'five | plus `nine` | minus `seven` | minus `three`' > task0.cli chmod 0700 task0.cli ./task0.cli

if [ “${USER}” = “youruser” ]; then

# stuff to do when it is you if

# stuff that happens any time for 2); dp

# thing you want to be looped done

VI VI stands for visual editor

Moded editing- 2 Types of Modes 1) Command Mode 2) Insert Mode

Start in command mode when first opening VI

Insert Mode Pressing “i” when vi first opens, switches to insert mode, will put stuff before current cursor location

Pressing “a” when in command mode, will put stuff after current cursor location

Pressing “I” inserts at the beginning of the line

Pressing “A” inserts at the end of the line

Pressing “o” inserts a new line underneath the current line

Pressing “O” inserts a new line above the current line

Command Mode escape key used to return to command mode

Command Mode Navigation h - left by char j - down by char k - up by char l - right by char “w” - moves by word forward “W” - moves by words separated by space forward “b” - moves backwards by word “B” - moves by words separated by space backwards “{,}” - moves by paragraph “{” goes up by 1, “}” goes down by 1 “# G” - go to line # (example “20 G” goes to line 20); “Number h,j,k, or l” moves cursor that many spaces in that direction Example: 8 h moves left by 8

Utility/Manipulation yy - yank line p,P = paste (p pasted below, P pasted above) dd - cut line cc - change line x,X - deletes by char (x under cursor, X to the right of cursor) . - repeats last command : - extended command mode v - visual mode s - substitute / - search u - undo e - goes to end of next word “b2dd - buffer b put in this “c3dd - buffer c put in this “c3dd


Unix Week 6 January 28, 2019 Extended VI Mode “:help” will bring up a help page

“:w” will save vi file “:q” will close vi and any sub-windows that are open

Settings “:set number” shows line numbers “:set nonumber” turns set number off

“:set tabstop=(some number)” will change the number characters a tab will take up

“:set smartindent” will auto-indent

“:set cursorcolumn” will highlight current column cursor is on

“:set cursorline” will highlight current line cursor is on

“:syntax on” will try to color is based off of the file extention “:syntax off” will turn syntax off

vi ~/.vimrc is a program that will set up default settings for vi

“:1co5” will copy line 1 paste it to after line 5

“:2m5” will move line 2 to line 5

5,7s/c/1234/g will search for all “c” characters from lines 5 through 7 and replace them with 1234

“:r (file name)” reads in file name into file

“vi (file name 1) (file name 2) (file name 3)” will queue up 3 files to edit

“:n” will go to next queued up file “:N” will go to previous queued file

“echo ${RANDOM}” outputs a random number in between 0 and 32767

echo “$1)” will print out a random number in between 1 and 100

grep stands for Global regular expression print, it searches for certain things in each file or standard input

number=“g” echo “${number}” | grep '^[0-9][0-9]*$' | wc -l will output 0 because nothing is found


Unix Week 7 March 7, 2019 UPF1 To find the options for each command use -h

Precision is decimal value

May need to specify to tool what precision is needed

Make sure to make steps file that produces output without error

Use ; to separate commands

Regular Expressions Share conceptual similarities to wildcards

Use some of the same symbols

Make sure to keep a distinction between regular expressions and wildcards

Two Types of Regular Expressions: 1) Basic Regular Expressions (Regex) 2) Extended Regex

Basic Regular Expressions:

$ will match end of line \? will match 0 or 1 of the previous . will match any single symbol * will match 0 or more of the previous [] (character class) will match any one of enclosed [^ ] (inverted character class) do not match any one of enclosed \< will match start of word \> will match end of word Will use mostly vim, grep, sed

Extended Regex + 1 or more of the previous (may need \)

() group \( \) regex group (used for remapping data)

will use mostly vim, egrep, sed

What was done in class today cd /usr/share/dict

cat words | grep 'regex' | wc -l

cat words | grep '^…..$' | wc -l gives you number of words that have 5 characters

cat words | grep '^.[aeiouy].[aeiouy].$' | wc -l gives you the number of words that have 5 characters where the even numbered places are lowercase vowels

cat words | grep '^..[^rstlne].' | wc -l gives you the numbers of words that have 4 or more characters where the third letter is not r, s, t, l, n, or e

cat words | grep '^…*[mMg]…$' | wc -l gives you words that have 6 or more characters with m, M, or g somewhere in middle

cat words | egrep '(ed|ing)$' | wc -l would give you all the words that end with ed or ing

cat words | egrep '^(..)+$' | wc -l gives you all the even-symboled words

Unix Week 9


March 26, 2019

ls -l /usr/local/bin/ gives all of the permissions for files in bin directory

urev is a tool that was created for this week's project

urev starts off with a welcome screen

need to get 144 problems correct in order to get 100% on this project

have to wait 2 hours until you can do the next set of problems

make sure to complete USR0 before the night that it is due because you won't have enough time to complete it

USR0 is a time management project so make sure to set time aside to complete it


Today we continue to work on our SPF0 project and it is the last day to work on it. So far we have completed pigen and we are working on pigrep. We believe that we have completed pigen to do exactly that is required.

Pigrep is designed to perform serches on pigen-generated pi.#.out files

So far I have added a ./pigen help page which prints out

pigrep - search available pi digits via regex for matches;

        must be part of pipeline (send PI digits in via STDIN)
 usage: pigrep [OPTION...] PATTERN
  note: if MAX variable is set, cap processing at that value

“ctrl insert” allows you to copy and paste from browser to a terminal

make sure to not “ctrl insert” into command line or it will run those commands

The next step is to create the actual pattern function I am creating an if statement that will read the user input and then search through the digits of pi to find patterns


Unix Week 10


April 9, 2019

PCT0 Info Do not need to turn in the practice puzzles but might consider doing them because they will help with the actual puzzle.

Goal is to solve and document the puzzle.

What was Done in Class First, went over the newest project, PCT0 and what needs to be done for that. Second, we did an example problem for the project PCT0. It was shown how to complete it and the work used to complete it.

This newest project is long division with letters that all contain different integer values from 0 through 9. The task is to figure out the key to the puzzle and what integer values each letter has. This project is due Wednesday the 17th. There is a bonus puzzle that if completed the same way that the actual puzzle is, will give bonus points on this project.

The trick to solving these puzzles is to look at the long division and seeing what kind of patterns present themselves. Each letter has its own value. The subtractions that are presented with the long division can be used in order to find patterns in order to get what the values are for each letter.

It took about an hour to find out the solution key for a puzzle and that was group effort. This puzzle may take a bit of work. May be a good idea to take a couple of breaks in creating it. Apparently the puzzle that was completed in class was classified as hard and the puzzle that is due will have more obvious solutions.


Unix Week 11


April 16, 2018

Processing Warranted Numbers The next project is called Processing Warranted Numbers

Objective of this Project To create a script that can, with or without information provided by the user, display useful reference data in various number bases

Knowing how to do number base conversions can be helpful in this project.

Script should take arguments using {$1} and there should be 6 arguments.

There are tools that will help remove unnecessary lines of code

The good programs that do well on this project are about 150 to 300 lines of code

Right justified for the table

Make sure everything for the most part is right justified

If a part of the project does not get finished, make a text file that explains what does not work so partial credit can be given

Quote all variables to be safe


What was Done in Class For the first hour or so off class, we went over the next project that is due next Wednesday. The goal of the project is to understand and work with number base. We have to create script that runs without any errors. A good script for this project will be around 150 to 300 lines of code. It seems like it could take a lot of thinking and poking at it. Being well rested will help creating this script similarly to how being well rested helped with the critical thinking project.


EoCE The EoCE is the end of course “final exam” that can be done whenever and does not need to be done in the final exam slot for the class. It can be done at any time and outside of class. Make sure to work on it before the last day it is due.

user/dtubbs2/start.txt · Last modified: 2019/04/16 15:27 by dtubbs2