免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3047 | 回复: 16
打印 上一主题 下一主题

Unix基础-学习笔记 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-11-04 11:37 |只看该作者 |倒序浏览
相信现在有很多朋友准备或者正在学习unix了,我也是一个newbie for unix.这是自己学习unix时的笔记,发上来供大家参考和指导~~~共同学习研究~~
(笔记是E文的,所以大家不要拿鸡蛋丢我哦~~~,只有这样才能学好它嘛~呵呵)

S1. What is Unix?
The Unix operating system comprises three parts: The Kernel, The Standard Utility Programs,and The System Configuration Files.

1.The Kernel: It's the core of the unix operating system.A large program that is loaded into memory when the machine is turned on,and it
controls the allocation of hardware resources from that point forward.
It has the necessary programs to talk to all the devices connected to it.

2.The Standard Utilities Programs: It includes simple utilities like
"cp",and complex utilities like the shell that allows u to issue commands to the operating system.

3.The System configuration Files: it is read by the kernel and some of
the standard utilities.The unix kernel and the utilities are flexible programs,and certain aspects of their behavior can be controlled by changing the standard configuration files.

eg. A system configuration files is the filesystem table "fstab",which
tells the kernel where to find all the files on the disk drives.
The system log configuration file "syslog.conf",which tells the kernel
how to record the kinds of events and errors it may encounter.

论坛徽章:
0
2 [报告]
发表于 2004-11-04 11:56 |只看该作者

Unix基础-学习笔记

S2. Accessing a Unix System
The main mode of access to a Unix machine is through a terminal,which usually includes a keyboard,and a video monitor.Each Terminal connected to Unix system,the kernel runs a process called a "tty" that accepts input from the terminal,and sends output to the terminal.TTY processes must be told the capabilities of the terminal to correctly read from,and write to ,the
terminal.
Console: A special type of terminal.Some unix system operations must be performed at the console.
Only accessible by the system operators,and administrators.

Dumb terminals:They have only the minimum amount of power required to send characters as input to
the unix system.Personal computers are often used to emulate dumb terminals.

Smart terminals: Just like X terminal.(瘟死你的操作系统形式)

论坛徽章:
0
3 [报告]
发表于 2004-11-04 12:43 |只看该作者

Unix基础-学习笔记

S3. Logging in and logging out
A system of user accounts.TO be used ,to ensure security and organization on a system with many user.

论坛徽章:
0
4 [报告]
发表于 2004-11-04 12:55 |只看该作者

Unix基础-学习笔记

S4. The Unix shell
It is the most important program on the unix system,from the end-user's standpoint,interface with Unix system, the middleman between u and the kernel.

Concept:а.The shell is a type of program callee an 'interpreter'.
              б.A program is referred to as a 'process',while the kernel is running it simultaneously.
              с.Execute a non built-in shell command,the shell asks the kernel to create a new subprocess(called a "child" process) to perform the command.

loop.gif (1.3 KB, 下载次数: 96)

loop.gif

论坛徽章:
0
5 [报告]
发表于 2004-11-04 13:02 |只看该作者

Unix基础-学习笔记

S5. Working with Files and Directories
1.The Unix filesystem structure:
Concept:The unix filesystem is heirarchical(resembling a tree structure).Anchored at a place called the 'root',designated by a slash "/".

tree.gif (2.51 KB, 下载次数: 91)

tree.gif

论坛徽章:
0
6 [报告]
发表于 2004-11-04 13:25 |只看该作者

Unix基础-学习笔记

eg. ls -l /etc/passwd
    -rw-r--r-- 1 root sys 41002 Nov 17 13:00 /etc/passwd
The first dash indicates the type of file(d for directory,s for special file,-for a regular file)
"rw-" permissions of the owner of the file:read and write,but no execute."r--" permissions for those in the same group as the owner:read,no write,no execute."r--" permission for all others:read,no write,no execute.

Setting permissions: use command "chmod"
"rwx" notation to specify the type of permission
"ugo" notation to specify those the permission apply to
add permission:+
remove permission:-
set a permission directly:=
eg. chmod g=rw- ~/.shrc ( ~ unix shorthand for your home directory)
    pwd =>; " print working directory"
    ls -lr /etc/i* ( * 通配符)
The cat command: it concatenates files and sends them to the screen.
# cat ~/.profile
# head -15 /etc/rc to see the first 15 lines of the /etc/rc file
# tail /etc/rc to see the last 10 lines(default 10 lines, u can change it)
Copying files and directories:
cp source destination
eg. cp ~/.profile ~/pcop
Moving and renameing files:
# mv ~/pcop ~/qcop
Removing files: rm filename
#rm ~/.pcop
Creating a directory:
mkdir directoryname
# mkdir ~/cry
# mkdir ~/cry/los
Removing a directory:
# rmdir ~/cry/los
# rmdir ~/cry

论坛徽章:
0
7 [报告]
发表于 2004-11-04 14:00 |只看该作者

Unix基础-学习笔记

S6. Redirecting Input and Output
Concept: Every program u run from the shell opens three files: Standard input , Standard output, and Standard error.
The standard input file provides a way to send data to a process. As a default, it is read from the terminal keyboard. The standard output provides a means for the program to output data. As a default, it goes to the terminal display screen. The standard error is where the program reports any errors encountered during execution. By default, the standard error goes to the terminal display.
Unix uses the “less than” and “greater than” special characters (<and> to signity input and output redirection, respectively.
Redirecting input:
“less-than” sign: # < file1
# more < /etc/passwd
# head /etc/passwd    work just the same as   # head < /etc/passwd

Redirecting output:
“greater-than” sign: # >; file2 (如果file2已经存在,会被新的覆盖)
Redirecting error: In the POSIX shell and ksh, redirect the standard error with the symbol “2>;”
eg. sort the /etc/passwd file, place the results in a file called cry, and trap any errors in a file
called err:
# sort </etc/passwd>; cry 2>;err

论坛徽章:
0
8 [报告]
发表于 2004-11-04 14:25 |只看该作者

Unix基础-学习笔记

S7. Pipelines and Filters
Concept: Unix allows u to connect processes, by letting the standard output of one process feed into the standard input of another process. That mechanism is called a Pipe.
eg. # cat .profile .shrc | more
   # cat file | head –75 | tail – 50 (display lines 25 through 75 of a file)
Remember that input/output redirection connects processes with files, while the pipe connects processes with other processes.
Grep(文件内字符串查找):
grep [-options] pattern[file]
It is always best to enclose the pattern within single quotes, to prevent the shell from misinterpreting the command.
Characters can use to build grep expressions:
l        The carat (^) matches the beginning of a line
l        The dollar sign ($) matches the end of a line.
l        The period (.) matches zero or more occurrences of the previous character.
l        The expression [a-b] matches any characters that are lexically between a and b.
eg.  # grep  ‘cry’   /etc/passwd  (the lines containing the string “cry”.)
# grep  ‘^cry’  /etc/passwd  (the line begin with the character string “cry”.)
List all the files in the /tmp directory owned by the user root
# ls  –l  /tmp | grep ‘root’

论坛徽章:
0
9 [报告]
发表于 2004-11-04 14:39 |只看该作者

Unix基础-学习笔记

不行了,累死我了,后面的我会慢慢更新整理贴上来的~~
搞了一上午,幸亏boss不在,不然就。。。嘿嘿~~

论坛徽章:
0
10 [报告]
发表于 2004-11-04 16:02 |只看该作者

Unix基础-学习笔记

S8. Process Control and Multitasking
Concept: The Unix kernel can keep track of many processes at once, dividing its time between the jobs submitted to it. Each process submitted to the kernel is given a unique process ID. In reality, it is running only one job at a time, but quickly switching between all of its ongoing tasks. The concept of switching is called process scheduling.
Viewing processes: ps (process status) for viewing the status of all the unfinished jobs that have been submitted to the kernel.
eg. # ps  -ef
   -e option causes ps to include all processes (indluding ones that do not belong to u), and –f option causes ps to give a long listing (include the process owner, the process ID, the ID of the parent process,  processor utilization, the time of submission, the process’s terminal, the total time for the process, and the command that started the process.)
eg. Use ps and grep, in a pipeling to find all the processes owned by u.
   # ps  -ef  |  grep  crystalos(here is your username)
Killing processes: Occasionally, u will find a need to terminate a process.
Kill [-options] process-ID
eg. To force termination of a job whose process ID is 111,enter:
  # ps  -9  111
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP