My personal study notes. Unix Power Tools (3rd Edition)
Ch1
POSIX — Portable Operating System Interface (IEEE standard)
A shell is a command interpreter.
Programs can be strung together in “pipelines” in which the output of one program is used as the input of another
A vertical bar ( | ) represents pipe and means “take the output of the program on the left and feed it into the program on the right."
less -- read its standard input from a pipe and still interact with you at the keyboard. It does that by reading directly from your tty.
exception (Emacs) — once it starts, the editor works independently of the shell, reading its input and output directly from the terminal.
Traditionally, a command interpreter is called a “shell”, it’s just another program.
………………….
The Mac uses a carriage return ASCII character 015 to mark the end of each line, while Unix uses a linefeed (ASCII 012). As a result, with Unix, the file looks like one long paragraph, with no ned in sight.
tr can convert every occurrence of one character in a file to another:
tr ‘\015’ ‘\012’ <file.mac >file.unix
…………………...
a basic for loop
for x
do
echo "Converting $x"
tr ‘\015’ ‘\012’ <“$x” > “tmp.$x"
mv “tmp.$x” “$x"
……………………...
The search path: a list of directories that the shell should look through for a command whose name matches what is typed. The search path isn’t built into the shell, you specify in your shell setup files.
PATH —an environment variable
……………..
The kernel is the heart of the Unix OS itself.
The kernel assigns memory to each of the programs that are running, partitions time fairly so that each program can get its job done, handles all I/O operations, etc.
daemons— are the system’s “helpers”, they run continuously, or from time to time— small but important tasks like handling mail, running network communications, feeding data to your printer.
ps x —— get a list of all processes running on your system
ps aux —— see everything that’s running, including the deamons (or ps -el)
to turn off a UNIX, first run shutdown
when turning on a Unix machine, it runs fsck (file system disk check) first
………………….
ls -a
lists files including those names start with a .
Unix OS doesn’t consider . in a file name
in Unix, rm * is very dangerous, it deletes everything under the current directory
in other OS, you need to say *.* to refer to all files
…………………..
Wildcard
? matches a single character
* matches zero or more characters
[character-list] matches any single character that appears in the list.
[a-zA-Z] means any alphabetic English character
Wildcards never match / , which is both the name of the filesystem root, and the character used to separate directory names in a path. The only way to match is to escape it (\)
……………………….
hierarchical file system (tree structured)
A directory is a special kind of file that lists a bunch of other files. A directory can contain any number of files (try to keep it under 100 though). A directory can also contain other directories.
At the top, is the directory called “root” , which has the special name /
/home home directory
/etc has configuration files
pwd —print working directory (to find out your current directory)
path begins with /, it is an absolution path.
./textfile can also execute the file if it is given executable file permissions
………………………..
File Access Permissions
The user entry in the master password file /etc/passwd defines his “primary group membership"
The /etc/group file defines the groups that are available and can also assign other users to these groups as needed.
Every file belongs one user and one group.
As the file owner, you can use chgrp to change the file’s group.
Use chown to change the file’s owner.
Nine mode bits
3 groups, owner, a member of the file’s group, or other <read, write or execute>
…………………….
In general, a process is a program that’s running.
To become the superuser, you can either log in as root or use the su command
……………..Files……………..
The structures of a file is defined by the program who uses it, not by the Unix OS.
Unix programs abide by one convention. Text files uses a single newline character (linefeed) between lines of text, rather than the carriage return-linefeed combination used in Windows or the carriage returns used in the Macintosh. This difference may cause problems when you bring files from other OS over to Unix. Windows files will often be littered with carriage returns (Ctrl-M), which are necessary for that OS but superfluous for Unix. Mac text files will appear to be one long line with no breaks. Use Unix utilities to convert Mac and Windows files for Unix.
……………….Scripting…………...
Perl, Python and Tcl.
Perl—regular expressions, working with files and other forms of I/O.
Python— more OO and data-manipulation features than the file-manipulation and regular-expression manipulation of Perl.
Tcl— popular with Linux systems. Tk toolkit (GUI library)
………………Unix Networking…………….
The internet — is a worldwide network of computers.
WWW — World Wide Web is a set of information servers on the Internet. The servers are linked into a hypertext web of documents, graphics, sound and more. Your browser turn that hypertext into an easy-to-use Internet interface.
mail
ftp — one way to transfer files between your computer and another computer with TCP/IP.
UUCP —Unix-to-Unix Copy, a family of programs (uucp, uux, uulog, and others)
Usenet — a collection of thousands of computers worldwide that exchange files called news articles.
telnet—This utility logs into a remote computer over a network (such as the Internet) using TCP/IP. You can work on the remote computer as if it were your local computer. telnet can log you into other OS from your Unix host and vice versa.
rsh— “remote shell” to run a command on a remote system w/o needing to log in interactively. Often used to start the “X Window System”
ssh— acts like rsh and rlogin, but it makes a secure encrypted connection to the remote computer.
rcp — “remote cp"
scp — secure version of rcp
NFS— not a user utility. The Network FileSystem and related packages like NIS (Network Information Service) let system administrator mount remote computers’ filesystems onto your local computer.
write — sends msg to another use’s screen.
talk — it splits the screen into two pieces and let users type at the same time if they wish.
irc— Internet Relay Chat allows multiple users to carry on multiple discussions across the Internet and other networks.