Files. Useful Commands. Permissions tar. More Commands. Working Remotely.
Emacs. Looking at Files. ◮ display contents of file in terminal: cat .
Unix
Unix
Unix
Directories
Directories
Files
Files
Useful Commands
Useful Commands
Unix is an operating system, like DOS or Windows
Permissions
Unix L555
Unix
What is Unix?
tar
Permissions tar
More Commands
◮
developed in 1969 by Bell Labs
Working Remotely
◮
works well for single computers as well as for servers
Working Remotely
Emacs
◮
underlying operating system for Macs
Emacs
Dept. of Linguistics, Indiana University Fall 2012
More Commands
Linux: open source version of Unix (mostly for PCs)
1 / 21 Unix
Directory Structure
2 / 21 Unix
Graphical Representation
Unix
Unix
Directories
directory = folder ◮
directory structure: tree structure
Important directories: ◮ ◮ ◮
home directory: your private directory (/Users/guest) root node: / important directories on a Mac: ◮ ◮ ◮ ◮
Directories
/
Files
Files
Useful Commands
Useful Commands
Permissions
Applications
tar
Permissions
Users
Volumes
tar
More Commands
More Commands
Working Remotely
Working Remotely
mdickinson
Emacs
...
guest
Data
/Applications /Users /Volumes /Volumes/Data/Corpora (on jones!)
Emacs
Corpora
ar
en
de
multilingual
3 / 21 Unix
Useful Commands for Directories ◮
◮
◮ ◮
Useful Shortcuts
list files in current directory:
Unix
Unix
ls
Directories
Directories
list files with more information:
Files
Files
ls -l
Useful Commands
Useful Commands
Permissions
Permissions
change directories:
TAB completion
tar
tar
cd
More Commands
two possibilities to specify :
Working Remotely
If you start typing a command or filename, then press TAB, the shell will complete the word for you – as far as possible.
Command history
Emacs
◮
from root:
Emacs
cd /Users/mdickinson ◮
More Commands Working Remotely
The shell keeps a history of your commands. To scroll through them, simply press the up arrow key.
from where we are:
cd ../mdickinson .. means ’go up’ ◮
4 / 21 Unix
go back to home directory:
cd ◮
show the directory where you are:
pwd 5 / 21
6 / 21
Unix
Looking at Files
Unix
Looking at Files More Commands
◮
◮
Unix
Unix
Directories
Directories
display contents of file in terminal:
Files
Files
cat
Useful Commands
display page by page:
Permissions
less
tar
◮ ◮ ◮ ◮ ◮ ◮ ◮
◮
next page: space bar quit: q go to beginning of file: g go to end of file: G search forward: / + hit return search backward: ? + hit return in search: next found occurrence: n
Useful Commands
◮
More Commands
◮
Working Remotely Emacs
◮
display beginning of file (normally 10):
Permissions
head
tar
display X beginning lines of file:
More Commands
head -n X
Working Remotely Emacs
display end of file (normally 10):
tail ◮
count number of lines, words, characters in a file:
wc
Likewise, there is the more command
7 / 21 Unix
More Useful Commands
8 / 21 Unix
More Useful Commands (2)
Unix
Unix
◮
Directories
◮
◮
list files that end in ’.txt’:
Files
ls *.txt
Useful Commands
make directory:
Permissions
mkdir subdirectory: mkdir results in your home directory: mkdir ◮
Useful Commands
sort (numbers) in numeric order:
Permissions
◮
tar
Working Remotely Emacs
grep
copy a file from one location to another:
◮
copy a file to the directory ’results’ in your home directory:
cp dates.txt
Files
find a word in a file and display all the lines in which it occurred:
More Commands
∼/results
Directories
sort sort -n
tar
cp ◮
◮
sort your file:
∼/results
◮
More Commands Working Remotely Emacs
find a word in a file and display all the lines in which it occurred and save results into a file in your home directory:
grep > ∼/ example:
grep linguistic mycorp.txt > ∼/res.txt 9 / 21 Unix
More Useful Commands (3)
10 / 21 Unix
Permission System ◮
Unix
ls -l
Unix
Directories
Directories
Files Useful Commands
◮
◮
◮
delete lines (adjacent) with identical content:
Permissions
uniq
tar
delete lines (adjacent) with identical content, but list how many were there:
More Commands
uniq -c
Emacs
-rw-r--r-drwxr-xr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x
1 15 3 4 35
root root root root root
admin admin admin admin admin
168724 510 102 136 1190
Nov 9 2003 Aug 31 2006 Aug 4 2004 Mar 2 2007 Feb 18 15:23
Jokes.pdf ar cs de en
Files Useful Commands Permissions tar More Commands Working Remotely
Working Remotely
◮
change permissions:
Emacs
chmod : user = u; group= g; others = o; all = a; : read = r; write = w; execute = x;
display differences between two files
diff ◮
example: give user write permissions for file ’hello.txt’:
chmod u+w hello.txt ◮
example: deny others write and execute permissions for directory ’test’:
chmod o-wx test 11 / 21
12 / 21
Unix
Packing and Unpacking Files Unix
◮
◮ ◮
Directories
gzip
Files
results in .gz
Useful Commands
gunzip .gz ◮
◮
Unix
pack a file:
unpack file:
Directories
◮
Permissions
◮
tar More Commands
’pack’ more than one file:
Working Remotely
tar cvf .tar
Emacs
unpack:
◮
◮
tar xvf .tar ◮
copy a file from one location to another:
Files
cp
Useful Commands Permissions
move a file from one location to another:
tar
mv
More Commands
rename a file:
Working Remotely
mv
Emacs
remove a file:
rm
tar and gzip:
◮
tar cvzf .tgz ◮
Unix
More on Copy and Move
remove a directory including contents:
rm -r
unpack:
tar xvzf .tgz
13 / 21 Unix
Important Shortcuts in Paths
14 / 21
Unix
Unix
Directories
Directories
Files
Files
Useful Commands
◮
Permissions
◮ ◮ ◮
.. (go) up one directory . here
∼ home directory
Unix
Translate
tar More Commands Working Remotely
◮
Emacs
◮
exchange characters for others:
Useful Commands
tr ’aeiou’ ’X’ < tr ’aeiou’ ’AEIOU’ <
Permissions tar More Commands
collapse characters (squeeze):
Working Remotely
tr -s ’J’ <
Emacs
exchange complement of characters for others:
tr -c ’a-z’ ’\n’ < \n is a linebreak
15 / 21 Unix
Putting Commands Together
16 / 21 Unix
Find out More
Unix
Unix
Directories
Directories
Files
Files
◮
< use following filename as input file
Useful Commands
Useful Commands
◮
> use following filename as output file
Permissions
Permissions
| use output of preceding command as input for
tar
tar
◮
following commands
More Commands Working Remotely Emacs
◮
man
More Commands Working Remotely Emacs
example:
cat | tr ’A-Z’ ’a-z’ | sort >
17 / 21
18 / 21
Unix
Remote Login Unix
Unix
Directories
Directories
Files Useful Commands
◮
login: ssh husernamei@hmachinenamei e.g.
ssh
[email protected]
◮
Permissions
More Commands Working Remotely
to copy a local file to (your home directory) on another machine:
scp : e.g. scp vm.pos jones.ling.indiana.edu:
tar
Emacs
◮
Unix
Remote Copy
◮
to copy a file from another machine to the current directory:
Files Useful Commands Permissions tar More Commands Working Remotely Emacs
scp :/ . e.g. scp jones.ling.indiana.edu:/Volumes/Data/ Corpora/en/penntreebankv3/readme.all .
logout:
exit
(in one line!)
19 / 21 Unix
Emacs Unix
Directories
◮
◮
◮
◮
emacs is a fairly basic text editor that can be run in a window or in the shell
Files Useful Commands Permissions
to start emacs:
tar
emacs
More Commands
to quit:
Working Remotely
Ctrl-x Ctrl-c
Emacs
save:
Ctrl-x Ctrl-s ◮
search:
Ctrl-s
21 / 21
20 / 21