Unix wizardry
Dr. Jay Maron


Unix is "High Valyrian" for Macs.

__________________________________________________________________________________________________

Open an XTerm and try the following commands.

> cd ~                       # Change directory to your home directory
> pwd                        # Show current directory
> ls                         # Show contents of the directory
> ls -sxp                    # Fancy version of ls
> man ls                     # Shows the manual page for ls
> mkdir badger               # Create a subdirectory called "badger"
> cp -r badger badger2       # Copy directory "badger" to "badger2"
> rmdir badger2              # Remove directory "badger2"
> cd badger                  # Change directories into "badger"
> cd ..                      # Go up one directory
> du badger                  # Print the total amount of bytes taken up by files in the directory "badger"
> df                         # Show the amount of space taken up on each disk
> date > hawkeye             # Print the date and put the output into the file "hawkeye"
> less hawkeye               # Print the contents of the file "hawkeye"
> cat hawkeye                # Print the contents of the file "hawkeye" without screen pauses
> cp hawkeye hawkeye2        # Copy the file "hawkeye" to "hawkeye2"
> cat hawkeye hawkeye2 > hawkeye3   # Print files "hawkeye" and "hawkeye2" and place the contents
                                    # in the file "hawkeye3"
> grep "2015" hawkeye        # Search for occurances of the string "2015" in the file "hawkeye"
> python                     # Open a python session.  From here, see www.jaymaron.com/python/python.html
>>> exit()                   # Exit the python session
> emacs hawkeye              # Edit the file "hawkeye" with the mighty "Emacs" editor.
                             # To exit, type "Control-c", "Control-x".
> rm hawk*                   # The "*" character is a wildcard.  This removes both "hawkeye" and "hawkeye2".
> screen                     # This activates the "GNU Screen" utility, which allows you to pack multiple
                             # sessions into one terminal.
> open musicfile.mp4         # The "open" command will find the appropriate utility for the given filetype.
> ls -l                      # Show the priviliges of the files the directory
> chmod u+r filename         # Make "filename" readable by the user
> chmod u+w filename         # Make "filename" writable by the user
> chmod u+x filename         # Make "filename" executable by the user.
> ./filename                 # Execute the unix commands in "filename"
                             # These commands will execute as though they were typed from the terminal.
> ./filename &               # Execute the unix commands in "filename", with the process running in
                             # the background.
> uptime                     # Show how long the system has been running.
> top                        # Show the jobs that are being run by the CPU
> scp -r filename username@hostname.edu:     # Copy "filename" to the remote computer "hostname"
> scp -r username@hostname.edu:filename .    # Copy "filename" from the remote computer "hostname" to the
                                             # local directory.

__________________________________________________________________________________________________

GNU Screen commands:

> C-a, c                     # Stands for "Control-a", "c".  This creates a new window.
                             # There is no limit to the number of windows you can create.
> C-a, w                     # List all windows and show which is the current window.
> C-a, 0                     # Change to window 0
> C-a, 1                     # Change to window 1
> screen -d                  # Detatch the screen into the background
> screen -r                  # Re-attach the screen to the present terminal
> C-a, k                     # Kill current window.  To exit screen, kill all windows.

__________________________________________________________________________________________________

Emacs commands: "C" stands for "control" and "M" stands for "esc"

Cf forward one character
Cb backward one character
Cp previous line
Cn next line
Ck kill
Cy yank
Cd delete character
Cs search forward
Cr search backward
Ca beginning of line
Ce end of line
Cv up one page
Mv down one page
M< beginning of file
M> end of file
Cx,u   undo
Cx,Cs  Save
Cx,Cc  Save and exit

__________________________________________________________________________________________________

Download
www.jaymaron.com/wizard/.emacs
and
www.jaymaron.com/wizard/.alias2
Have a look at them and place them in your home directory with

> cd ~
> cp ~/Downloads/.emacs ~    # This is an Emacs customization file.
                             # Placing it in your home directory causes the customized commands
                             # to be used instead of the defaults.
                             # The .emacs file contains a discussion of the commands.
> cp ~/Downloads/.alias2 ~   # This is a shell customization file
> source .alias2             # This activates the aliases in the file ".alias2".

Using "System preferences", remap the "Caps Lock" key to the control key, which empowers
emacs and GNU screen.

__________________________________________________________________________________________________

Python:  www.jaymaron.com/python/python.html

__________________________________________________________________________________________________


Index of textbooks


Free online science textbook project at gofundme.com