Intro to the Command Line

Intro to the Command Line

Command Line Walkthrough

1. Setup
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
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
find . -name "*.txt" -print
grep -r race ./*
grep -r " race" ./*

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

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

9. autocompletion, bash history

10. exit

Additional Stuff

A. 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


Advanced Resources


Workshop Evaluation

Please take a moment to fill out the evaluation form:

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.
Need help with the Commons? Visit our
help page
Send us a message
Skip to toolbar