Basic command line

pwd

  • print working directory

ls

  • list subjects

cd

  • change directory
  • cd .. back to last dir level
  • cd ~ back to home

mkdir

  • make a new directory

rm

  • rmdir - remove directory
  • rm -r - remove recursive

mv

  • mv file dir - move file to directory

touch

  • create new file

man

  • man command - command description

copy

  • cp /old-dir/file.txt /new-dir/file.txt

less

  • less file
  • head -n2 file

count words, lines

  • wc -l

match pattern

  • grep “some_pattern”
  • grep “^somepattern” (pattern at beginning of each line)

cut by column (default filed by tab)

  • cut -d(separator) -f1

output as input

  • command 1 command 2 command 3

output to a file

  • (add to exist)

#download from web

  • wget address

#readlink

  • readlink .

#remote copy

  • scp -r netid@msu.edu:source destination

#check tab or space vi space/tab to see hilights