CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1 Prof. Michael J. Reale Fall 2014
COMMAND KATA 0
Command Kata 0: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata0 and go to it mkdir dkata0; cd dkata0 Make a script called kata0 script kata0 When we re done: exit
Command Kata 0 Where am I? pwd Create directory kata mkdir kata What is in my current location? ls Go to directory kata cd kata Where am I? pwd Go to parent directory cd.. Where am I? pwd Remove directory kata rmdir kata What is in my current location? ls
COMMAND KATA 1
Command Kata 1: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata1 and go to it mkdir dkata1; cd dkata1 Make a script called kata1 script kata1 When we re done: exit
Command Kata 1 Create file abc What is in this folder? Copy abc to def What is in this folder? Rename abc to ghi What is in this folder? Remove def and ghi files What is in this folder? touch abc ls cp abc def ls mv abc ghi ls rm def ghi ls
COMMAND KATA 2
Command Kata 2: Preparation First, go to ~/cs307 Create folder called dkata2 and go to it mkdir dkata2; cd dkata2 Create a script called kata2 script kata2 When we re done, we ll type exit Exit ^ = CTRL key
Command Kata 2 Type abc ; DON T hit Enter abc Hit ^A and type begin begin abc Hit ^E and type end begin abc end Hit ^U and type erase erase Hit Enter; ignore error Hit ^L and type clear clear Hit Enter (also does clear) Send me a message! write realemj Type some message Hi there! Hit ^D (EOF)
COMMAND KATA 3: Crouching Directory, Hidden Files
Command Kata 3: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata3 and go to it mkdir dkata3; cd dkata3 Make a script called kata3 script kata3 When we re done: exit
Command Kata 3 Create directory path mkdir p foo/bar/fudge Go to path cd foo/bar/fudge Make file abc touch abc Make file HIDDEN.dragon touch.dragon List contents ls List ALL contents ls a Make file excellent touch excellent List long format ls l List ALL, 1 column, sorted by modified date ls ta1 Remove all files rm excellent abc.dragon List ALL ls -a Go to ~cs307 cd ~/cs307 Remove directory path rmdir p foo/bar/fudge
COMMAND KATA 4: WILDCARD STRIKE
Command Kata 4: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata4 and go to it mkdir dkata4; cd dkata4 Make a script called kata4 script kata4 When we re done: exit
Command Kata 4 Create directory dkata4 and go to it mkdir dkata4; cd dkata4 Make many files touch a ab ac abc bc d de def List files beginning with a ls a* List files beginning with a and one character ls a? List files beginning with a through c ls [a-c]* List files with b in the name ls *b* List files beginning with ab OR de ls {ab,de}* Go to parent directory cd.. Delete dkata4 and all its content rm rf dkata4
COMMAND KATA 5: PERMISSION QUEST
Command Kata 5: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata5 and go to it mkdir dkata5; cd dkata5 Make a script called kata5 script kata5 When we re done: exit
Command Kata 5 Create file yeflask echo You cannot get ye flask > yeflask Check permissions ls l Change permissions to 200 chmod 200 yeflask Check permissions ls -l Try to read file cat yeflask Change permissions to 400 chmod 400 yeflask Check permissions ls l Try to read file cat yeflask Try to append to file echo Again >> yeflask Change permissions to 100 chmod 100 yeflask Check permissions ls -l Try to delete file (say y ) rm yeflask
COMMAND KATA 6: THE LEGEND OF ZELDA
Command Kata 6: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata6 and go to it mkdir dkata6; cd dkata6 Make a script called kata6 script kata6 When we re done: exit
Command Kata 6: Part 1 Create directory hyrule and go to it mkdir hyrule; cd hyrule Create file zelda touch zelda See how many links to zelda ls l Create hard link sheik ln zelda sheik See how many links to zelda ls l Remove zelda rm zelda See how many links to sheik ls l
Command Kata 6: Part 2 Create soft link to hyrule called overworld ln s hyrule overworld Look at links ls -l Go to overworld (logically) and pwd (physical) cd overworld; pwd Go to parent and remove hyrule cd.. ; rm rf hyrule Try to go to overworld cd overworld Remove overworld rm overworld
COMMAND KATA 7: VARIABLES
Command Kata 6: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata7 and go to it mkdir dkata7; cd dkata7 Make a script called kata7 script kata7 When we re done: exit
Command Kata 7: The Way of Bourne Start a Bash shell bash Create a shell variable BESTMOVIE= Supremacy Print value of variable echo ${BESTMOVIE} Start a new bash shell bash Print value of variable echo ${BESTMOVIE} Exit shell exit Make variable an environment variable export BESTMOVIE Start a new bash shell bash Print value of variable echo ${BESTMOVIE} Exit shell exit Exit shell again exit
Command Kata 7: The Way of the C (Shell) Start tcsh tcsh Create shell variable set ocean= Atlantic Print value of variable echo ${ocean} Create environment variable setenv OCEAN Pacific Start tcsh shell tcsh Print value of shell variable echo ${ocean} Print value of environment variable echo ${OCEAN} Exit shell exit Exit shell again exit