<<

EECS 183 Discussion 2 Milind Furia

Adapted from: Anna Wasewicz Using a VM • a virtual machine (VM) is a fake computer running as a program.

• It can be used as a playground to things out and work without risking anything on your day-to-day machine.

• It can also be used for development if you don’t have a based system (. Windows) VM Caen Linux

• http://caenfaq.engin.umich.edu/12374-Linux- Login-Service/how-do-i-connect-to-a-caen- linux-computer-remotely The line

• a tool into which you can text commands to perform specific tasks  Instead of using the gui with your mouse to click on things to accomplish tasks • A lot of things can be automated using the command line Some simple commands • (list space) • -l to the end of my ls command, I'll see a detailed listing • -t will the results by • -S will sort by file size • -r will reverse the sorting • –a lets you see hidden files  there are two entries for "." and ".." the beginning of the list.  "." is the current folder. “..” is the parent folder (change directory)

• Lets you navigate which folder you are in • You can navigate to either full or relative paths. • If you're in /path/to/ and you want to navigate to the folder stuff inside that folder, you can simply type: cd stuff (list working directory)

• tells you which directory you are in Creating and removing folders

• To create a new folder, use the command • Remove any folder with the • If the folder is not empty, this command will not let you delete the folder. If you want to remove the folder and all it’s contents you can use –rf  be careful with this!  the –f flag stands for force  the –r flag stands for recursive Creating and removing files

• use the command to create a new, blank file • use the rm command to delete files Kleene Star ( * )

• means match everything • if you're in a folder and want to delete every file inside that folder, just type: rm *

• Delete every instance of a matching filename pattern from the current directory and below: rm –rf filename.* Edit files using command line

• The command that you use to edit text files will be different based on the platform you're using • Linux has the nano editor to quickly edit files, which might be suitable for beginners. • nano /path/to/file • I recommend vim or or gvim command • utility for searching plain-text data sets for lines matching a regular expression • used to quickly text within files, even searching through subdirectories. • if you wanted to search through all files in the current directory and below it for "text string", you could use this command: grep –ir "text string" * Shortcuts

• Ctrl + U: Clears the line from the cursor point back to the beginning. • Ctrl + A: Moves the cursor to the beginning of the line. • Ctrl + E: Moves the cursor to the end of the line. • Ctrl + R: Allows you to search through the previous commands. Quiz

Questions!! On the spot Regex

• What the * is this?

[0-9]{3}[-. \)\(]*[0-9]{3}[-. \\\)\(]*[0-9]{4} Regexes

• is a sequence of characters that define a search pattern, mainly for use in pattern matching with • can be used for find and replace tasks • grep is what you can use on the command line to match regular expressions A Regular Expression contains one or more of the following:

• A character set: characters retaining their literal meaning

• An anchor: These designate (anchor) the position in the line of text that the RE is to match. For example, ^, and $ are anchors.

• Modifiers: These expand or narrow (modify) the range of text the RE is to match. Modifiers include the asterisk, brackets, and the backslash.