免费注册 查看新帖 |

Chinaunix

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

Summary20070427 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-04 20:53 |只看该作者 |倒序浏览

GNU-Linux-Tools-Summary.pdf实在是一个很不错的文档,一定要收藏为参考工具书使用。要注意自己的.bashrc文件的配置情况。

The unix tools philosophy
The " Unix tools philosophy" emerged during the creation of the UNIX operating system, after the breakthrough invention of the pipe '|' (refer to Chapter 6 for information on using the pipe).
The pipe allowed the output of one program to be sent to the input of another. The tools philosophy was to have small programs to accomplish a particular task instead of trying to develop large monolithic programs to do a large number of tasks. To accomplish more complex tasks, tools would simply be connected together, using pipes.

alias
The alias command will list your current aliases. You can use unalias to remove the alias (to disable it just for one command add a "\" (back−slash) before the command)...
An alias allows one command to be substituted for another. This is used to make a command do something else or to automatically add certain options. This can be either be done during one session using the alias command (see below) or the information can be added to the .bashrc file (found in the users home directory).
Below is an example of what an alias section (within your .bashrc file) might look like:

# my personal aliases
alias cp='cp −vi' #to prompt when copying if you want to overwrite and will tell you where alias rm='rm −i' #Prompts you if you really want to remove it.
alias mv='mv −i' #Prompts you if you are going to overwrite something

On any Mandriva GNU/Linux system the global aliases (for all users) are all in /etc/profile.d/alias.sh.
The above listed commands already have aliases, as well as several other commonly used commands.
set −x
set is one of bash's inbuilt commands, try looking in the bash manual for its many usage options.
Using set with the −x option will make bash print out each command it is going to run before it runs it.
This can be useful to find out what is happening with certain commands such as things being quoted that contain wildcards or special symbols that could cause problems, or complex aliases. Use set +x to turn this back off.
Examples
After using set −x you can run the command:
ls
The output printed before the command runs (for example):
+ ls −F −−color=auto
Which means that the command is really an alias to run ls with the −F and −−color=auto options.
Use a "\" (backslash) before the command to run it without the alias.
\ (backslash)
The backslash escape character can be used before a shell command to override any aliases.
For example if rm was made into an alias for rm −i then typing "rm" would actually run rm −i.
However, typing \rm lets the shell ignore the alias and just run rm (its runs exactly what you type),
this way it won't confirm if you want to delete things.

Using rm
Please note that the alias for the remove command is there for a reason. Using it incorrectly could remove files which you don't want removed.
Only use \rm if you know exactly what you are doing (recovering files is not easy, rm does not send things to a recycle bin).
The "\" character can be used before special characters (such as a space or a wildcard), to stop bash from trying to expand them. You can make a directory name with a space in it using a backslash before the space. For example you could type cd My\ Directory\ With\ Spaces which normally wouldn't work.
The "\" character can also be used to stop bash from expanding certain symbols (as an alternative you could use single quotation marks, although you may need to use both).
set bell−style none
This particular set command will turn off the system bell from the command−line (use xset −b for X windows). If you want the bell to stay off pernamently (no audible bell) then you can add this command to your ".bashrc" or ".bash_profile" (just add it to the same one you have your alises in...).
reset
The reset command re−initializes your current terminal. This can be useful when the text from your terminal becomes garbled, simply type "reset" and this will fix your terminal.
exit
Closes your current terminal (with x−terminals) or logs−out. Also try CTRLD .
logout
Logs out of a terminal, also try CTRLD .

4.3. Other Key combinations
GNU/Linux shells have many shortcut keys which you can use to speed up your work, below is a rough list of some (also see CTRLR in the history section of the commands, over here, Section 4.2).
CTRLD
the "end−of−file" (EOF) key combination can be used to quickly log out of any terminal. CTRLD is also used in programs such as "at" to signal that you have finished typing your commands (the EOF command).
CTRLZ
key combination is used to stop a process. It can be used to put something in the background temporarily.
For example, if you were editing a file with vim or emacs just press CTRLZ to regain control of the terminal do what you want and then type fg to bring it back.
For further information please see Section 9.3.
If fg doesn't work
If fg doesn't work you may need to type jobs and then fg job_name or fg job_number
CTRLA and CTRLE
These key combinations are used for going to the start and end of the line on the command line. Use
CTRLA to jump to the start of the line, and CTRLE to jump to the end of the line.
CTRLK
This key combination can be used to cut or delete what is currently in front of the cursor.
CTRLY
This key combination can be used to paste the last thing you deleted (using CTRLK or CTRLW ).
CTRLW
This key combination can be used to cut or delete the entire line that has being typed.
4.4. Virtual Terminals and screen
Using the key combination ALTF* keys you may change to different virtual terminals. You will have several (usually 6) virtual terminals setup with shells. Number 7 is usually setup with X you need to use
CTRLALTF* to change to a terminal from within X (X as in the X windowing system).


6.4. Performing more than one command
Executing the second command only if the first is successful
To do this you would type:
command1 && command2
command2 will be executed if command1 successfully completes (if command1 fails command2 won't be run). This is called a logical AND.
Executing the second command only if the first fails
To do this you would type:
command1 || command2
command2 will be executed if command1 does not successfully complete (if command1 is successful
command2 won't be run). This is called a logical OR.
Executing commands sequentially
To execute commands sequentially regardless of the success/failure of the previous you simply type:
command1; command2
command2 will execute once command1 has completed.
More than two commands
You can continue to use ';' (semicolon) characters to do more and more commands on the one line.


" cd −" will return you to the previous directory (a bit like an "undo").

mkdir
Make a directory. Use mkdir −p to create subdirectories automatically.
Directories are Folders
Directories are sometimes called folders in other operating systems (such as Microsoft Windows)
Examples:
mkdir −p /home/matt/work/maths
This would create the directories "work" and "maths" under matt's home directory (if matt's home directory didn't exist it would create that too).


stat
Tells you detailed information about a file, including inode number creation/access date. Also has many advanced options and uses.
For simple use type:
stat file



/proc
The files under the /proc (process information pseudo file−system) show various information about
the system. Consider it a window to the information that the kernel uses.
For example:
cat /proc/cpuinfo
Displays information about the CPU.
less /proc/modules
Use the above command to view information about what kernel−modules are loaded on your system.
dmesg
dmesg can be used to print (or control) the " kernel ring buffer". dmesg is generally used to print the contents of your bootup messages displayed by the kernel. This is often useful when debugging problems.
Simply type:
Dmesg

8.2. Finding information about partitions
There are a number of ways to find out information on your hard disk drives, for information on mounted partitions also try df in Chapter 8
Using the proc filesystem
You can look through the information in the relevant area of the proc filesystem, under the directory of either /proc/ide/ or /proc/ide?/hd? where the first question mark is a number and the second is a letter (starting with 'a'). For example:
cd /proc/ide0/hda
Under this directory there will be various information on the hard drive or cdrom connected.
Using fdisk
Using fdisk with the −l option will output information on any hard drives connected to the system and information on their partitions (for example, the type of partition).
Information relating to using fdisk to partition hard disks can be found in your distributions documentation, the fdisk manual page or online.
Root Access Required
This command needs root access to work

关于守护进程的介绍:
UNIX systems use scripts to control "daemons" which provide "services" (for example your sound output) to run a UNIX system. UNIX systems consist of a variety of services (daemons).
A "daemon" is a system process which runs in the background (zero interaction) performing a particular task.
Daemons normally have a "d" on the end of their name and either listen for certain events or perform
a system task, for example sshd listens for secure shell requests to the particular machine and handles them when they occur.
Daemons usually perform critical system tasks such as control swap−space, memory management and various other tasks.


关于压缩文件的工具可以参考15.3小节,这里不再列出。
20.2, 20.3小节介绍的检查磁盘和复制磁盘有些意思,有必要的时候可以看一下。
20.4.1介绍的标准通配符我只见过和用过一些,还需要学习。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/5756/showart_291518.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP