<<

Introduction to

Website to load Unix emulator: http://bellard.org/jslinux/ ​ Basic Commands

description

present working directory: shows you where you are located in the system ​ ​ ​ ​ ​ list: shows all the files in your present working directory ​ ​ ​ change directory: changes the present working directory to another location ​ ​ ​ directory: makes a new folder in the specified location ​ ​ ​ ​ ​ copy: copy a file to a specified location ​ ​ ​ remove: remove the specified file ​ ​ ​ move: move file to a new location, or rename a file ​ ​ ​ more: displays the content of a file ​ catenate: reads a file or writes content to a file (end file with CTRL­d) ​ echo: display the content of a variable ​ emacs emacs: text editor program (use CTRL­x, CTRL­ to save and ) ​ word count: displays the number of words in a file ​ ​ ​ tape archive: extracts a tar file (a of compressed file) ​ ​ ​ sh shell: executes a shell script ​ globally search a regular expression and print: finds text within a file ​ ​ ​ ​ ​ ​ ​ find: finds a file or directory in the file system ​ table of processes: shows all running processes (quit with q) ​ ​ ​ ​ ​ kill: ends a running process defined by the PID (process ID) ​ cut: splits a string into multiple defined by a delimiter ​ man manual: displays how to use a command and lists the available options it has ​

command description

CTRL­c cancel a running process

CTRL­z suspend a running process

CTRL­d detach, or end a file when using cat ​ TAB complete filename or command up to the point of uniqueness

> to

< read from

$ use before variables when referencing them

| pipe: allows for the execution of a sequence of commands

­ dash: use this before declaring special options for various commands

. signifies current directory; the first character of a hidden file’s name

.. signifies parent directory

` execute whatever is in between the `s

$RANDOM gives a random number between 0 and 32767 (max int16)

Basic Programming for for loops allow for a code to be performed a certain number of times ​ while while loops allow for code to be performed until a specific condition is met ​ do start code to be done in the loops with do ​ done end code to be done in the loops with done ​ if allow for code to run only under certain conditions

then if condition is met, do the then ​ ​ elif else if: if the first condition is not met, check new condition ​ ​ ​ ​ ​ else if none of the conditions are met, do the else ​ ​ fi end an if block with fi ​ ​ ​

Tasks

1. Delete the file hello.c in the root folder. ​ ​ ​ ​ 2. Delete the folder dos in the root folder. ​ ​ ​ ​ 3. Write a file named number.list that lists the numbers from 1 to 5 with one number on ​ ​ ​ ​ ​ ​ each line. 4. Create a folder called numbers, and inside of that, create a folder for each number from ​ ​ 1 to 5. ​ ​ ​ 5. Create a new folder called tunnel, and within that another folder called tunnel, and within ​ ​ ​ ​ that another one… repeat until your tunnel is 5 folders deep. ​ ​ ​ ​ 6. Copy number.list to each folder within numbers. ​ ​ ​ ​ 7. Copy numbers to the end of the tunnel. ​ ​ ​ ​ 8. Return to the root directory and find all number.lists within the tunnel. Save the output ​ ​ ​ ​ ​ ​ into number.files. ​ ​ 9. Delete every number.list within the tunnel by making use of number.files. ​ ​ ​ ​ ​ 10. Find all tunnel folders and save the output in tunnel.paths. ​ ​ ​ ​ 11. Write a script, using a for loop, that copies number.list back to all the locations in the ​ ​ tunnel. ​ 12. Repeat all of the above using only scripts, and changing 5 everywhere above to 20. ​ ​ ​ ​

13. Extra 1: Add a fork in the 20­deep tunnel every 4 tunnel depth, and make each fork 10 ​ ​ ​ ​ ​ ​ ​ ​ ​ deep. 14. Extra 2: Remove all number.lists from the forked tunnel, and add a copy of it to a random ​ ​ ​ ​ ​ ​ location inside the tunnel. 15. Extra 3: Find the randomly placed number.list without using find. ​ ​ ​ ​