Linux 101

What we're going to cover

  • Linux filesystem
  • Basic terminal/shell usage
  • Cron jobs
  • Additional/helpful resources

Linux filesystem

  • Think hierarchy
  • No concept of c/d drives, think mount points
  • EVERYTHING IS A FILE
  • The tilde "~" character is a shortcut for the reference to your home folder

http://www.howtogeek.com/137096/6-ways-the-linux-file-system-is-different-from-the-windows-file-system/

 

Loose standard for "what goes where": http://www.pathname.com/fhs/pub/fhs-2.3.pdf

Linux shell

Know it
LOVE IT
UsE IT
everything in linux can be accomplished via shell

cheatsheet

A-Z bash commands

we have Desktop environments, why use the shell?

  • Exposes you to the internals of how things work in Linux
  • If you can run it in the shell, you can automate it
  • 99% of Linux servers WON'T HAVE A DESKTOP ENVIRONMENT if setup correctly

LS/find

  • "ls" is the same as "dir" in Windows
  • "find" basically does a recursive "ls" + more

ex. List all files, including hidden files, in current folder

ls -la

http://unixhelp.ed.ac.uk/CGI/man-cgi?ls

http://content.hccfl.edu/pollock/Unix/FindCmd.htm

cd

  • Same as Windows
  • Changes current directory

 

cd ~  # go home

 

http://unixhelp.ed.ac.uk/CGI/man-cgi?cd

Filesystem navigation/basic manipulation

cp/MV/rm/mkdir

Copy/move/remove files

No "rename" in Linux, use "mv"

rm -rf  # recursively remove files
mkdir -p ~/projects/new_project
mv jeo.txt joe.txt  # rename file
cp ~/.ssh/known_hosts ~/hosts.bak

cat/touch

"Concatenate" == echo file content to standard out (stdout)

 

http://www.tecmint.com/13-basic-cat-command-examples-in-linux/

 

"Touch" == create empty file or update last-modified file date/time

 

less/more

  • Pause output at page boundaries
  • "less" is more versatile

 

http://linux.about.com/library/cmd/blcmdl1_less.htm

pipes and redirection

A pipe "pipes" the output from one command into the input of another command

 

cat joe.txt | sort

streams => STDIN/STDOUT/STDERR

echo "Hi, there!" > joe.txt

 

http://www.ibm.com/developerworks/library/l-lpic1-v3-103-4/

streams

ps

ps -aux | grep PROC

^ list all processes and filter down to process that contain "PROC" in their listing

 

http://linuxcommand.org/man_pages/ps1.html

kill and signals

  • Sends a signal to a process
  • Signal 9 == forcefully kill the process via kernel
  • Sends TERM (stop) to process by default, if process is hung it might not actually self-terminate

kill -9 PROCESSNUMBER

^ process with PROCESSNUMBER is now dead for sure

http://en.wikipedia.org/wiki/Unix_signal

processes

killall

  • killall firefox # processes named firefox sent TERM signal
  • killall -9 firefox # tell kernel to kill all firefox processes

https://www.digitalocean.com/community/tutorials/how-to-use-ps-kill-and-nice-to-manage-processes-in-linux

http://linux.die.net/man/1/killall

cron jobs

"run something on a schedule"

 

The Windows task scheduler, Linux style

 

http://www.thesitewizard.com/general/set-cron-job.shtml

resources

Linux 101

By Joe Meilinger

Linux 101

  • 274