Introduction to Unix

Introduction to Unix

Introduction to Unix Website to load Unix emulator: http://bellard.org/jslinux/ ​ Basic Commands command description pwd present working directory: shows you where you are located in the file system ​ ​ ​ ​ ​ ls list: shows all the files in your present working directory ​ ​ ​ cd change directory: changes the present working directory to another location ​ ​ ​ mkdir make directory: makes a new folder in the specified location ​ ​ ​ ​ ​ cp copy: copy a file to a specified location ​ ​ ​ rm remove: remove the specified file ​ ​ ​ mv move: move file to a new location, or rename a file ​ ​ ​ more more: displays the content of a file ​ cat catenate: reads a file or writes content to a file (end file with CTRL­d) ​ echo echo: display the content of a variable ​ emacs emacs: text editor program (use CTRL­x, CTRL­c to save and exit) ​ wc word count: displays the number of words in a file ​ ​ ​ tar tape archive: extracts a tar file (a type of compressed file) ​ ​ ​ sh shell: executes a shell script ​ grep globally search a regular expression and print: finds text within a file ​ ​ ​ ​ ​ ​ ​ find find: finds a file or directory in the file system ​ top table of processes: shows all running processes (quit with q) ​ ​ ​ ​ ​ kill kill: ends a running process defined by the PID (process ID) ​ cut cut: splits a string into multiple strings 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 > write 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 at 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. ​ ​ ​ ​.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us