Intro to your OS X Filesystem and Permissions

How to find home

note: as a user of the system you will be given a user directory under the Users directory

$ echo $HOME

How to go to the home directory choices:

$ cd $HOME$ cd ~$ cd, and

$ cd then drag your home directory from your Finder window

How to go to the root directory

note: when you see pathnames as such Users/patrick/Documents, this is an “absolute” path name starting at the root

$ cd /

How to print your working/current directory

note: every terminal window operates an independent working directory

$ pwd

How to list your files

$ ls

$ ls -F – this will append a forward slash (/) to directories, an asterisk (*) to executables or scripts, an (@) to symbolic links

$ ls -al – this will show the “long” version of “all” files in the directory

file permissions are shown on the first column in a super cryptic way like this (feel free to skip this portion: 

drwxr-xr-x

these are:

file type (1 char) – here “d” is directory, “-” would’ve meant file

owners file permission (3 char) – the owner has read, write, executable permissions on this directory

group file permission (3 char) – everyone in this users group has read and executable permissions

others file permission (3 char) – everyone on the computer in any group has read and execute permissions

How to see the disk usage of:

$ du Documents/Outline.doc (size of a file in 512-byte blocks)

$ du -s Documents (summary size of the directory in 512 byte blocks)

$ du -sh Documents (summary size of the directory in human readable format)

How to see the remaining free disk space

$ df -H (human readable disk free space using base 10 to calculate sizes)

How to change the permissions on files and directories

$ chmod "categories" "add/subtract" "permissions" "filename"

The categories permission options are:

u  owner, g  groups, o others, and

a – all permissions, owner, groups and others

The add/subtract options are:

+  adding, -  subtracting

The permission options are:

r  read, w  write, x  execute

Examples:

How to delete your user permission from removing the files within a directory (write access)

$ chmod u-w dirname

How to delete all permissions from removing the files within a directory (write access)

$ chmod a-w dirname

removing write access on a file does not stop it from being removed, you must remove write access to the directory to protect the file from deletion – Ice Bear

How to change the owner of a file or directory

$ chown some_name filename

 

Part II – Intro to OSX file management