Linux: Basic Command Introduction IV

本文介绍了Linux系统中常用的帮助命令如man、whatis及文件压缩命令如gzip、tar、zip等的功能、语法及使用场景,并对比了它们之间的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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

资源下载链接为: https://pan.quark.cn/s/d9ef5828b597 在本文中,我们将探讨如何通过 Vue.js 实现一个带有动画效果的“回到顶部”功能。Vue.js 是一款用于构建用户界面的流行 JavaScript 框架,其组件化和响应式设计让实现这种交互功能变得十分便捷。 首先,我们来分析 HTML 代码。在这个示例中,存在一个 ID 为 back-to-top 的 div 元素,其中包含两个 span 标签,分别显示“回到”和“顶部”文字。该 div 元素绑定了 Vue.js 的 @click 事件处理器 backToTop,用于处理点击事件,同时还绑定了 v-show 指令来控制按钮的显示与隐藏。v-cloak 指令的作用是在 Vue 实例渲染完成之前隐藏该元素,避免出现闪烁现象。 CSS 部分(backTop.css)主要负责样式设计。它首先清除了一些默认的边距和填充,对 html 和 body 进行了全屏布局,并设置了相对定位。.back-to-top 类则定义了“回到顶部”按钮的样式,包括其位置、圆角、阴影、填充以及悬停时背景颜色的变化。此外,与 v-cloak 相关的 CSS 确保在 Vue 实例加载过程中隐藏该元素。每个 .page 类代表一个页面,每个页面的高度设置为 400px,用于模拟多页面的滚动效果。 接下来是 JavaScript 部分(backTop.js)。在这里,我们创建了一个 Vue 实例。实例的 el 属性指定 Vue 将挂载到的 DOM 元素(#back-to-top)。data 对象中包含三个属性:backTopShow 用于控制按钮的显示状态;backTopAllow 用于防止用户快速连续点击;backSeconds 定义了回到顶部所需的时间;showPx 则规定了滚动多少像素后显示“回到顶部”按钮。 在 V
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值