`
DavyJones2010
  • 浏览: 154791 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Linux: Basic Command Introduction IV

阅读更多

 

Part I: Help command

1) Command Name: man

    Command Derived From: manual

    Command Path: /usr/bin/man

    Command Auth: all users

    Command Function: get help information for command or config file

    Command Syntax: man [command name OR config file name]

    Example:

man ls              --> Get help information for command ls

man services   --> Get help information for /etc/services config file

Q: There is a command called passwd used to set password for user.

     There is also a config file /etc/passwd.

     When we type "man passwd", what are we doing? Is it find help file for config file or for command?

A: When man, command help is preferred than config help. There are 5 kind of man help. The first kind is command help, The fifth kind is config file help.

If we want to look at the config file help for passwd, we just use "man 5 passwd"

what is ls       --> Get basic concept of ls command

ls --help         --> Simply get basic select options for ls command

chomd --help

 

2) Command Name: whatis  OR apropos OR mkwhatis

    Command Derived From: Search the whatis db for help info

    Command Path: /usr/bin/whatis; /usr/bin/apropos; /usr/sbin/mkwhatis

    Command Auth: all users; all users; root

    Command Function: get short help information for command; get short help info for config file; update help info db

    Command Syntax: whatis [command name]; apropos [config file name]; mkwhatis

    Example:

whatis ls              --> Get brief help information for command ls

apropos services   --> Get brief help information for /etc/services config file

Everytime we install a software, its help info will be stored in a specific location in file sys.

So we should update whatis db from time to time.

 

Part II: File compression command

1) Command Name: gzip

    Command Derived From: GNU zip

    Command Path: /bin/gzip

    Command Auth: all users

    Command Function: compress file as .gz format

    Command Syntax: gzip [option] [file name]

    Example:

gzip /home/administrator/Test3/Test.java

We can find out that the original file Test.java has been compressed as Test.java.gz

    Comments:

There is limitation for gzip command:

1) gzip can only compress file and cannot compress folder.

2) gzip will not save the original file that needed to be compressed.

Q: How to solve these problems?

 

2) Command Name: gunzip

    Command Derived From: GNU unzip

    Command Path: /bin/gunzip

    Command Auth: all users

    Command Function: decompress .gz file as original format

    Command Syntax: gunzip [option] [zipped file name]

    Example:

gunzip /home/administrator/Test3/Test.java.gz

We can find out that the original file Test.java.gz has been decompressed as Test.java

    Comments:

There are limitations for gunzip command:

1) gzip can only decompress file and cannot decompress folder.

2) gzip will not save the original file that needed to be decompressed.

 

3) Command Name: tar

    Command Derived From: ...

    Command Path: /bin/tar

    Command Auth: all users

    Command Function: packing folder as .tar format. That means convert folder into file

    Command Syntax: tar [c OR v OR f OR z] [folder name]

-c --> Generate .tar format packaged file

-x --> Depackage .tar file

-v --> Show the detailed packaging info

-f  --> Assign the generated compressed file name. Required!

-z --> Operate packaging and gzip both. --> Not supported by all Unix/Linux OS.

    Example:

Compress:

Step1: tar -cf /home/administrator/Test3.tar /home/administrator/Test3/

We can find out that the original folder Test3 has been packeged as Test3.tar

Step2: gzip /home/administrator/Test3.tar

We can find out that the original file Test3.tar has been compressed as Test3.tar.gz

 

tar -cfz /home/administrator/Test3.tar.gz /home/administrator/Test3/

This operation equals Step1 + Step2

 

It is a good practice to name the compressed file as .gz, and name the packaged file as .tar

We can actually operate " tar -cfz /home/administrator/Test /home/administrator/Test3/ "

Then that would be difficult to recognize the original file type of the compressed Test3 file.

There is a command we can find the type of file.

administrator@ubuntu:~$  file Test3
Test3: directory
administrator@ubuntu:~$ file Test3.tar.gz
Test3.tar.gz: gzip compressed data, was "Test3.tar", from Unix, last modified: Wed Sep 25 00:30:30 2013

Decompress:

gunzip /home/administrator/Test3.tar.gz

tar -xvf Test3.tar   --> But this seems doesn't work for me!! Why???

 

    Comments:

We should recognize:

1) -f should always be used for both packaging and depackaging.

2) -c used for packaging and -x used for depackaging.

 

4) Command Name: zip

    Command Derived From: zip

    Command Path: /usr/bin/zip

    Command Auth: all users

    Command Function: compress file as .zip format. It is the only common format in both Win and Linux.

    Command Syntax: zip [-r] [compressed file name] [original file name or dir name]

-r --> Option for compress folder.

    Example:

zip /home/administrator/Test3/Test.java.zip /home/administrator/Test3/Test.java

We can find out that the original file Test.java has been compressed as Test.java.zip

zip -r /home/administrator/Test.zip /home/administrator/Test

We can find out that the original folder Test3 has been compressed as Test3.zip

 

    Comments:

1) zip is supported by both Win OS and Linux OS. For environment that have frequent file tranfer in different platform, we should consider use .zip file

2) zip compression ratio may not be that high as gzip.

3) Both file and folder compression are supported.

4) zip will keep the original file

 

5) Command Name: unzip

    Command Derived From: unzip

    Command Path: /usr/bin/unzip

    Command Auth: all users

    Command Function: decompress .zip file as original.

    Command Syntax: unzip [compressed file name]

    Example:

unzip /home/administrator/Test3/Test.java.zip

We can find out that the original file Test.java.zip has been decompressed as Test.java and prompt may occur asking for replacing existing Test.java.

unzip /home/administrator/Test.zip

We can find out that the original file Test3.zip has been decompressed as Test3 and prompt may occur asking for replacing existing folder Test3.

 

    Comments:

1) unzip will keep the original zipped file.

 

6) Command Name: bzip2

    Command Derived From: add user

    Command Path: /usr/bin/bzip2

    Command Auth: all users

    Command Function: compress file

    Command Syntax: bzip2 [-k] [filename]

-k --> Keep the original file

-d --> Decompress file

    Example:

bzip2 -k Test.java    -> Compress file and keep original. Generate file named Test.java.bzip2

bzip2 -k Test3.tar      -> Compress packaging file and keep original. Generated file named Test3.tar.bzip2

bzip2 -d Test3.tar.bzip2  --> Decompress file and generated file named Test3.tar

bzip2 -d Test.java.bzip2 --> Decompress file and generated file named Test.java

    Comments:

1) Like gzip, bzip2 is only applied for compressing file. It cannot be used to compress folder.

    If we want to compress folder, we should packaging the folder first using tar.

2) The only difference between gzip and bzip2 is that bzip2 has the option -k to keep the original file.

    And the compress ratio is really high.

3) The postfix of the compressed file is .bzip2.

 

Part III: Network

分享到:
评论

相关推荐

    Air and Spaceborne Radar Systems: An Introduction

    ""This introduction to the field of radar is intended for actual users of radar. It focuses on the history, main principles, functions, modes, properties and specific nature of modern airborne radar....

    The_Linux_Networking_Architecture

    Part IV: Network Layer 221 Chapter 13. The TCP/IP Protocols 223 Section 13.1. The Internet Protocol Suite 224 Chapter 14. The Internet Protocol V4 227 Section 14.1. Properties of the Internet...

    The.Linux.Networking.Architecture

    Part IV: Network Layer 221 Chapter 13. The TCP/IP Protocols 223 Section 13.1. The Internet Protocol Suite 224 Chapter 14. The Internet Protocol V4 227 Section 14.1. Properties of the ...

    unix power tools 3ed.pdf

    #### 四、基本编辑 (Part IV: Basic Editing) **4.1 拼写检查、字数统计和文本分析 (Chapter 16: Spell Checking, Word Counting, and Textual Analysis)** - **拼写检查工具**: 如`aspell`, `hunspell`等。 - **...

    Cisco Press - OSPF Network Design Solutions, 2nd Edition

    Part IV Additional OSPF Resources 707 Appendix A OSPF RFCs 705 Index 724 0323FMf.book Page vi Wednesday, March 12, 2003 9:41 AM vii Contents Introduction xix Part I OSPF Fundamentals and Communication...

    Tornado Train Workshop

    98 graphical and command-line user interfaces, file systems, and standard Windows editor. iv Wind River Systems Course Objectives • Overview of Tornado / VxWorks facilities. • Boot VxWorks and ...

    Practical C++ Programming C++编程实践

    Simple Pointers const Pointers Pointers and Printing Pointers and Arrays The reinterpret_cast Pointers and Structures Command-Line Arguments Programming Exercises Answers to Chapter Questions Part IV....

    MFC+Windows程序设计

    Introduction Like many of my colleagues in this industry, I learned Windows programming from Charles Petzold's Programming Windows—a classic programming text that is the bible to an entire ...

    VC技术内幕第五版.chm

    Introduction Like many of my colleagues in this industry, I learned Windows programming from Charles Petzold's Programming Windows—a classic programming text that is the bible to an entire generation...

    The Indispensable PC Hardware Book - rar - part1. (1/7)

    Basic Logical Elements. CMOS Inverters as Low-power Components. An Example: 1-bit Adder. The CPU as the Core of all Computers. 3. Everything Began with the Ancestor 8086. Pins and Signals in ...

    Spring中文帮助文档

    6.2.5. 引入(Introduction) 6.2.6. 切面实例化模型 6.2.7. 例子 6.3. 基于Schema的AOP支持 6.3.1. 声明一个切面 6.3.2. 声明一个切入点 6.3.3. 声明通知 6.3.4. 引入 6.3.5. 切面实例化模型 6.3.6. ...

    Spring API

    6.2.5. 引入(Introduction) 6.2.6. 切面实例化模型 6.2.7. 例子 6.3. 基于Schema的AOP支持 6.3.1. 声明一个切面 6.3.2. 声明一个切入点 6.3.3. 声明通知 6.3.4. 引入 6.3.5. 切面实例化模型 6.3.6. ...

    hadoop_the_definitive_guide_3nd_edition

    Basic Filesystem Operations 52 Hadoop Filesystems 54 Interfaces 55 The Java Interface 57 Reading Data from a Hadoop URL 57 Reading Data Using the FileSystem API 59 Writing Data 62 Directories 64 ...

    Developing Flex Applications 910p dda_doc88_cracker.zip

    This package contains 3 kid: 1. a book Developing Flex Applications 2. a web page viewer for doc88 ebt ... CONTENTS PART I: Presenting Flex CHAPTER 1: Introducing Flex....About Flex....

    php_6_fast_and_easy_web_development.pdf

    Using the SHOW Command. . . . . . . . . . . . . . . . . . . . . . . . . . . 521 Appendix FUsing SQLite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 Examples of SQLite in Action. . . ...

    最新版的DebuggingWithGDB7.05-2010

    5.1.7 Breakpoint Command Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.8 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.9 ...

Global site tag (gtag.js) - Google Analytics