If you understand the console-based commands for invoking or controlling applications, you have a POWERFUL advantage over those who are limited by knowing only GUI-based control. When you know what's really going on, then you are more easily able to ramp up your knowledge when confronted with a new GUI interface that simplifies (i.e., "dumbs down") interaction to an application you already know.
To that end, we have here a golden opportunity to learn some console-based shell commands (the shell is the part of an operating system that interacts with a user) and some sftp commands.
Keep in mind, a GUI interface interprets your mouse clicks into something rather like shell commands, then those commands are executed. It may look like the mouse click does something directly -- but that would be wrong.
From a specific directory or file looking "up" there is one path to the root. From a specific data file looking "down", there is no where else to go -- a file cannot "hold" anything in the file structure. From a specific directory looking down, there are from 0 to many possible branches.
A picture may help here. insert picture of approximately:
/ Stuff/ HisStuff/ f1.txt Pictures/ p1.jpg p2.jpg f2.txt MyStuff/ file1.txt file2.txt /Projects P1/ p1.java p1.class P2/ p2a.java
Speaking casually, we say a directory contains directories and files, and a file contains data.
A directory or a file is identified in the file system by its path. A complete path for a directory or file is the complete specification of all directories from the root to the desired destination. A relative path is the specification of directories to a desired destination but starting at a location different from the root. The path to the desired file (directory) relative to a specific starting directory.
There are two special names used in the file system. '.' refers to the current working directory. '..' refers to the working directory's parent.
file1.txt
is /Stuff/MyStuff/file1.txt
. The complete
path for the directory named P1
is /Stuff/MyStuff/P1
.
P1
(e.g., pretend you're editing p1.java
), then the relative path to Projects
is
..
, and the relative path to P2
is ../P2
.
If the current working directory is P1
, then the
relative path to f1.txt
is ../../../HisStuff/f1.txt
.
Terminal
application opens a shell. Terminal
is typically located
at Applications | Utilities
. If you can't find it there, then search (the icon is a
magnifying glass in the upper-most, right-most corner of the screen) for it.
I forget
application opens a shell. ...
is located at
Start | All Programs | Applications
. Another way to invoke the shell
in Windows is to choose Run...
and type cmd
or is it command.com?to the buffer.
OS X | OS X flags | Win | Win flags | action |
---|---|---|---|---|
man cmd | on line documentation of shell command cmd | |||
ls | -l give more information | dir | /w wide output format | list contents of current directory |
ls path | -l | dir path | list contents of path | |
pwd | print path of current working directory | |||
cp f1 f2 | copy f1 f2 | create a copy of file f1 and place in file f2 | ||
mv f1 path | move file f1 to location given by path | |||
cd path | change working directory to path | |||
pwd | print (on screen) path of working directory | |||
rm f1 | del f1 | delete file f1 | ||
mkdir d1 | create a new directory named d1 in current working directory | |||
rmdir d1 | delete directory named d1 | |||
vi f1 | edit f1 | open plain text editor on file f1 | ||
sftp username@hostname | open sftp client to host hostname using user username | |||
ssh username@hostname | open ssh connection to host hostname using user username | |||
sftp username@hostname
to invoke an sftp client. The client will open an sftp connection to
the sftp server that is running on the host machine named hostname.
Your machine (running the sftp client for you) is the local computer. The machine running the sftp server for you (at hostname) is the remote computer. The local computer uploads data to the remote computer and downloads data from the remote computer.
command | action |
---|---|
? | print a list of ftp commands |
put f1 | uploads file f1 in local working directory to remote working directory |
get f1 | download file f1 to local working directory from remote working directory |
mkdir d1 | create new directory in remote working directory |
pwd | print path of remote working directory |
cd path | change remote working directory |
ls | print contents of remote working directory |
lpwd | print path of local working directory |
lcd path | change local working directory to path |
lls | print contents of local working directory |
bye | end sftp connection and close sftp client |
Setting access permission with sftp is not as intuitive as setting them with a shell.
The same command chmod
is used, but sftp requires numeric arguments rather
than symbolic. To give read access to index.html for all users, use
chmod 644 index.html
To give read and execute access to directory Dir1 for all users (you need both read and
execute to get the behavior you probably want) use
chmod 755 Dir1