Permissions, Editing, Date, Time, Shell Scripting

permissions

(what command and options did I use to get this output?)

drwx------+ 18 bree  staff    612 Aug 10  2012 Music
drwx------+ 14 bree  staff    476 Jan 12 10:16 Pictures
drwxr-xr-x+  6 bree  staff    204 Apr 11  2012 Public
drwxr-xr-x+  6 bree  staff    204 Apr 11  2012 Sites
drwxr-xr-x   5 bree  staff    170 Aug 10  2012 VirtualBox VMs

permissions continued

I can get permissions for a single file by using ls -l on a single file…

$ ls -l filename.txt 
-rw-r--r--  1 bree  wheel  0 Feb 13 17:05 filename.txt

permissions continued

drwxrwxrwx
  |  |  |
 rwx |  | 
  u rwx |
     g rwx
        o

permissions continued

drwxrwxrwx

What are the permissions of this file? →

-rw-r--r--  1 bree  staff  0 Jan 14 16:51 file_name

chmod

change permissions

chmod [user, group or world] [plus or minus] [read, write or execute] [filename.sh]
	# allow user to execute
	chmod u+x filename.sh
	# prevent world from writing
	chmod o-w filename.txt
  

chown

change owner and group

chown bree:admins filename.txt

change owner

chown bree filename.txt

change group

chown :admins filename.txt

nano

start a command line txt editor!

nano filename.txt

# <CTRL-X> exit
# <CTRL-O> save
# <CTRL-K> cut
# <CTRL-U> paste
# <CTRL-W> search

date

show the current date and time

date

cal

show the current calendar month

cal

# for year...
cal 2013

shell scripts

shell scripts continued

For example, a script called "hello_world.sh"...


  	#!/bin/bash
	# Prints "Hello World!"

	echo "Hello World!"
   

How would I run this? →

./hello_world.sh
	  

Activity: Drills!

Entering commands flash cards x 3 (use set 4)

We’ll do this together, then try downloading it yourself:

  1. Download drills.py to the home directory
  2. Type python drills.py
  3. When prompted for a number, enter 4
  4. CTRL-C quits

Lab

Permissions, Editing, Date, Time

Activity: Drills!

Entering commands flash cards x 3 (use set 1234)

We’ll do this together, then try downloading it yourself:

  1. Download drills.py to the home directory
  2. Type python drills.py
  3. When prompted for a number, enter 1234
  4. CTRL-C quits