Working with files (and jobs)
in UNIX
Many systems available.
VI, Emacs, and Pico are all text editor applications used on a Unix system.
Both Emacs and VI use commands to manipulate text. (They does this slightly different from each other)
Pico is an editor similar to Microsoft Notepad.
Emacs is a popular one.
The command line movement on Emacs is superior to VI.
Text manipulation commands:
to go Forward........ Ctrl-F
to go Back...............Ctrl-B
previous..................Ctrl-P
next..........................Ctrl-N
Beginning of line.. Ctrl-A
end of line...............Ctrl-E
first char of file....... Esc
end of file................ Esc <
delete char to right.. Ctrl-D
delete to left........…. Del
Kills word to right:.. Esc D
Kills word to left..... Esc Del
Kills line.................. Ctrl-K
Restore last line...… Ctrl-Y
Undo last change.… Ctrl-X + U
Compilation commands:
compile.................... Esc X
check for errors.......Ctrl-X
Emacs is easier to learn than VI.
Pico:
Allows mouse cursor to copy, cut, paste, etc.
Allows for use of Windows capability inside editor.
Pico is a little easier to work with; it has a menu to make things easier.
Job Control in Unix:
Ctrl-Z stops execution temporarily. Allows user to perform other tasks and return.
fg takes stopped job to foreground.
jobs checks all stopped jobs.
a.out& puts job in background.
example of job list:
[1] stopped VI
[2] stopped VI
[3] stopped G++
[4] stopped emacs
+/- indicate job status.
+ means current job
- means next current job
fg without argument resumes stopped job
examples:
%4& resumes job 4 in background.
stop%6 stops job 6.
cannot logout with stopped jobs.
other commands:
kill%2: kills job number 2.
kill 680: kills process.
kill - 9: a sure kill, similar to Ctrl + Alt + Del
history: replays a set of commands
sort: sorts a file.
able to sort output from one file to another.. called a pipe ( | ).
setenv: sets environment variables.
term: name of terminal environment variable.
printenv: prints available environment variables.
wc: counts words in file.
File permission is necessary to adjust at times:
chmod:
chmod lets you change permissions on a file.
chmod (who) (action) (permission) (filename)
+ Adds permission
- Takes it away
permission is given to a certain group to use your files (u = user, g = group, o = others).
types of permissions include: read, execute, write
ls-l a.out will tell you permissions:
example: rwx = read write execute, r-x = read execute, etc.
chmod g-r o-r a.out === this takes read access away from group and others.
ls-l a.out will now show these new permissions.