Intro to the Command Line

Intro to the Command Line

Command Line Walkthrough

1. Setup
./setup.sh
cd ~

2. structure of a command
grep -r capital etext/*
command, flags/options, arguments

3. white spaces in commands: white spaces separate arguments and options, use quotes to include spaces in things like filenames
grep -r "they were" etext/*

4. the file system, files, folders, user folder
pwd
ls
ls -l
cd mydir
cd ~
mkdir mynewdir
mkdir -p mynewdir/mysubdir/mysubsub/subx3
touch goodbye.txt
rmdir mynewdir/mysubdir/mysubsub/subx3
rm goodbye.txt
rm -r mynewdir
cp hello.txt mydir/hello_copy.txt
mv mydir/hello_copy.txt ./

5. working with files: cat, less
cat hello.txt
cat aesopa10.txt
less aesopa10.txt

6. pipes and redirection
| pipes take the output from one command and sends it as an argument of the second one
>, > pipe output as input to the file/stream
echo "hello world." > hello.txt
cat aesopa10.txt | less
grep -r they etext/* > them.txt
cat > dummy.txt

*Use ctrl-d to finish entering text

7. finding stuff: grep, find
files:
find . -name "*.txt" -print
text:
grep -r race ./*
grep -r " race" ./*

case insensitive:
grep -ir german ./*
wildcards:
grep -ir "fr.nc[eh]" ./*

8. getting help: man, apropos, –help
man grep
apropos find
grep --help

9. autocompletion, bash history

10. exit

Additional Stuff

A. keyboard shortcuts: http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29#Keyboard_shortcuts
ctrl-c: kill the command
ctrl-d: exit
ctrl-z: pause and return to the command line (%n to resume)
ctrl-a: jump to the beginning of a line
ctrl-e: jump to the end of a line
up/down: previous/next command
tab: autocomplete
ctrl-l: clear the display

B. installing stuff:
Debian Linux (Mint, Ubuntu, etc.): apt (apt-get)
OS X: brew (recommended) or macports
Windows: cygwin + cyg-apt

C. other topics to look into: users, groups, permissions, linking, processes, shell scripts, loops…

D. Google is your friend!!!

Additional Resources

  1. http://cli.learncodethehardway.org/book/
  2. http://www.davidbaumgold.com/tutorials/command-line/
  3. http://learnpythonthehardway.org/book/appendixa.html
  4. http://ryanstutorials.net/linuxtutorial/commandline.php

Advanced Resources

  1. http://ohmyz.sh/
  2. https://github.com/revans/bash-it
  3. http://zachholman.com/2010/08/dotfiles-are-meant-to-be-forked/
  4. http://dotfiles.github.io/

Workshop Evaluation

Please take a moment to fill out the evaluation form: https://digitalfellows.commons.gc.cuny.edu/workshopevaluationform/

Keith Miyake is a graduate of the Earth and Environmental Sciences Program at the CUNY Graduate Center. His work crosses the fields of political economic geography, environmental justice and environmental governance, critical race and ethnic studies, American studies, and Asian American studies. His dissertation examined the institutionalization of environmental and racial knowledges within the contemporary capitalist state.
Skip to toolbar