Tuesday, March 19, 2013

Command Line Crash Course: Lessons 10-12

Lesson 10: Copy a File (cp)

I had an aha moment right off the bat with this one- instead of naming one file in the command, you name first the file that already exists then the file you want to create. "cp" allows you to copy a file and give the new file a new name simultaneously. "cp -r" lets you copy directories with files in them. This does not simultaneously rename the files, however.

It appears that you can only copy files into directories that are inside the file's current directory.

Lesson 11: Moving a File (mv)

This was pretty straightforward. mv renames a file. This is different from cp because you end with the same number of files you started with.

Lesson 12: View a File (less, MORE)

Before I could start this lesson I had to figure out how to move a file to a directory that is not located within the current directory. It turns out I was having difficulty with this because I was omitting an (apparently) crucial / from the beginning of the path.

For some reason with "less" you omit the .txt when you enter the command ( less ex12 worked for me but less ex12.txt did not). Then you view the file and press q when you're done.

Then I copied the text that I wrote so it would take several screens. I'm glad I did, as scrolling in Terminal looks weird: there is no sensation of movement at all, only a colon to tell you there's more and [end] to tell you there isn't.







Monday, March 18, 2013

Command Line Crash Course: Lesson 9

Lesson 9: Making Files (Touch)

I learned to touch! I made several new files and then deleted them. I filled the directory Plants with the files chlorophyll.txt, cell.txt, and fluid.txt. I also learned that you can't delete a directory with a file in it.

I'm turning in early tonight- I'll be back tomorrow for more lessons :-)

Sunday, March 17, 2013

Command Line Crash Course: Lessons 5-8

Happy Saint Patrick's Day!

Today I pursue the pot of gold hidden somewhere in this Command Line Crash Course, continuing with Lesson 5.

Lesson 5: Change Directory (cd)

This lesson had me move up and down the directories I created yesterday using "cd" and ".." For the most part this was intuitive, until I tried to navigate to the Documents folder, which did not work initially because I was missing part of the path. I wound up using "pwd" and "ls" to find out the exact paths to use, and then found my way to both Downloads and Documents. Yay :-) 

Lesson 6: List Directory (ls)

Oops, I jumped ahead! In this lesson I used ls to give me the names of files inside my directories, and used cd to navigate to those directories. I also learned that ls -lR gets you a list of all the directories inside the current working directory, so you don't have to cd down the whole hierarchy. I also confirmed my earlier discovery that ls and pwd are the "I am lost, where am I" commands.

Lesson 7: Remove Directory (rmdir)

This lesson combined ls, cd, and pwd and used them to accurately remove directories using rmdir. In order to use rmdir, you have to be in the directory that contains the directory that would want to remove, and the directory has to be empty.

Lesson 8: Moving Around (pushd, popd)

This lesson was initially confusing because I wasn't sure if pushd/popd was creating/ deleting d or moving between them. Turns out, it's  sort of both. Pushd says "go to and remember this location," popd takes you to the previous location. Pushd/popd lets you move easily between two locations, which is valuable because with cd you have to follow a hierarchy instead of skipping around. I also learned that mkdir -p lets you make an entire path at once instead of moving into each directory to make the directory inside it, and that capitalization matters. Terminal understands home and Home as two different places.










Saturday, March 16, 2013

Command Line Crash Course: Lessons 2-4

With a new coat of nail polish drying on my toes, I move on to Lesson 2 in the Command Line Crash Course.

Lesson 2: Paths, Folders, Directories (pwd)

 In this lesson, I typed my first ever command in Terminal! It was "pwd," or "Print Working Directory" and Terminal gave me /home/jane. The next part of the lesson was to practice pwd and look up /home/jane in my graphical file browser, which I did. Hello /home/jane/ .

Lesson 3: What's Your Computer's Name?

This lesson uses hostname, which tells you the name of your computer. Mine is "janebox." Repeated 20x for practice.

Lesson 4: Make a Directory (mkdir)

This lesson is a little more complex, it involves typing multiple commands so you can create a hierarchy or directories. I'm glad I'm doing this in Linux, the code for Windows looks needlessly complex. I also learned that when you're writing a path you can't put spaces after the slashes because Terminal will read the space as the end of the path and ignore everything after it. I also learned that accidentally typing a question mark deletes the last part of the path. I also spent a not inconsiderable amount of time trying to figure out how I broke mkdir. The answer? A spelling mistake :-P I practised making several lengthy paths. This second one I made turned into the plot of Macbeth four folders in. Fun ^ ^


























Learning to Use the Command Line: Lesson 1

My Sandbox is ready for me to play in! A huge thank you to +Kyle Barnhart for setting up Janebox so I have a safe place to play :-)


As it turns out, before I can learn Python I need to learn to use the command line. Fortunately, Learn Python the Hard Way links to a guide on the subject written by the same author, which is here:

http://cli.learncodethehardway.org/book/

In this post, I'll be taking notes on what I learn from Lesson 1 of the command line tutorial.

Notes:

Command Line Interface (CLI): A window where you type in code that tells the computer what to do

Shell: Software that creates a user interface, such as a CLI

Lesson 1: The Setup

Step 1: Find something name "shell" or "terminal". It is indeed just called "Terminal," and just looks like a black box when open. The icon is a small black box with these characters: >_ . It looks like a one-eyed winky face!

The next step is to learn some abbreviations and what they stand for. I'm going to write them down and define the terms here, because knowing what things mean helps me remember them.

pwd: print working directory (tells you where you are right now.)

hostname: your computer's network name

mkdir: make directory (a directory is like a folder in Windows)

cd: change directory (allows you to move into a different directory or subdirectory)

ls: list directory (lists files in the current working directory)

rmdir: remove directory (deletes an empty directory)

pushd: push directory (puts the file in the stack directory. This saves the file and makes it easy to return to later)

popd: pop directory (removes the file from the stack directory and returns to the path at the top of the stack directory. Path= name that specifies a unique place in a directory. stack directory= holding pen for files you want to switch between)

http://www.eriwen.com/bash/pushd-and-popd/

cp: copy a file or directory

mv: move a file or directory

less: page through a file

cat: print the whole file

xargs: execute arguments

find: find files

grep: find things inside files

man: reads a manual page (manual page= software documentation. "Manual" as in "How-to," not as in "done by hand.")

apropos: find what man page is appropriate

env: look at your environment (I found a lot of definitions for this, I assume it is a versatile command that subsequent lessons will explain.)

echo: print some arguments

export: export/ set a new environment variable (environment variable= characteristic of the environment you're working in, like language).

exit: exit the shell

sudo: become super user root (guide says this is dangerous, +Kyle Barnhart says you need it to do most important things. I assume both are true, I can think of a few important things that could go very wrong.)

chmod: change permission modifiers (who can read, write, and execute files)

chown: change ownership

End of terms! The next assignment is to study the flashcards I've made of the list.

End of Lesson 1! I'm going to go study my list; Lesson 2 will happen in my next post (expect to see that this afternoon as well).











Thursday, March 14, 2013

Learning Python the Hard Way

Curriculum chosen! http://learnpythonthehardway.org/book/ is the most highly recommended beginner's guide to programming I have come across thus far. I'll be starting on it as soon as my Linux sandbox is set up (thanks +Kyle Barnhart!) In the meantime, I'll be defining unfamiliar terms as I come across them here in the blog. Exciting times!

Wednesday, March 13, 2013

Programming: Step One

Dear Internet,

In See Jane Program, I will document this English major's attempts to learn to program. I've been hungry for a new challenge for awhile now, and I know learning to program will also open a lot of doors for me careerwise.

I'm also attracted to the idea of being able to create a universe of my own with just a computer. The sheer volume of things you can use programming to do is incredible. If you know how to tell computers what to do, you have a large part of the world at your fingertips.

That's why I'm documenting my attempts here. A record of my studies will keep me honest, and remind me of the progress I've made. Every day I will learn something about programming, and I will share it on this blog along with my goals for the next day.

Tomorrow: The Game Plan, in which I pick a curriculum to follow and detail my reasons for choosing it.