Linux常用命令,能解决工作中99%的Linux操作问题
创始人
2024-04-26 08:58:29
0

目录

一、ls

二、pwd

三、cd

四、touch

五、mkdir

六、rmdir&rm

七、man

八、cp

九、mv

九、cat

十、move

十一、less

十二、head

十三、tail

十四、时间

十五、cal

十六、find

十七、grep

十八、zip/unzip

十九、tar

二十、计算器

二十一、uname

二十二、热键

二十三、关机

补充:


添加用户:

删除用户:

 

一、ls

语法: ls [选项][目录或文件]
功能:对于目录,该命令列出该目录下的所有子目录与文件。对于文件,将列出文件名以及其他信息。

附加:

ls -a 列出所有文件,包括隐藏文件

ls -l 列出文件详细信息

[sunlang1@VM-12-13-centos ~]$ ls
code  myfile.txt  test.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ ls -l
total 4
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 myfile.txt
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .cache  code  .config  myfile.txt  test.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ ls -a -l
total 36
drwx------  5 sunlang1 sunlang1 4096 Dec 18 14:31 .
drwxr-xr-x. 4 root     root     4096 Dec 18 14:23 ..
-rw-------  1 sunlang1 sunlang1  275 Dec 18 14:34 .bash_history
-rw-r--r--  1 sunlang1 sunlang1   18 Apr  1  2020 .bash_logout
-rw-r--r--  1 sunlang1 sunlang1  193 Apr  1  2020 .bash_profile
-rw-r--r--  1 sunlang1 sunlang1  231 Apr  1  2020 .bashrc
drwxrwxr-x  3 sunlang1 sunlang1 4096 Dec 18 14:25 .cache
drwxrwxr-x  2 sunlang1 sunlang1 4096 Dec 18 14:31 code
drwxrwxr-x  3 sunlang1 sunlang1 4096 Dec 18 14:25 .config
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 myfile.txt
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ ls -al
total 36
drwx------  5 sunlang1 sunlang1 4096 Dec 18 14:31 .
drwxr-xr-x. 4 root     root     4096 Dec 18 14:23 ..
-rw-------  1 sunlang1 sunlang1  296 Dec 18 14:35 .bash_history
-rw-r--r--  1 sunlang1 sunlang1   18 Apr  1  2020 .bash_logout
-rw-r--r--  1 sunlang1 sunlang1  193 Apr  1  2020 .bash_profile
-rw-r--r--  1 sunlang1 sunlang1  231 Apr  1  2020 .bashrc
drwxrwxr-x  3 sunlang1 sunlang1 4096 Dec 18 14:25 .cache
drwxrwxr-x  2 sunlang1 sunlang1 4096 Dec 18 14:31 code
drwxrwxr-x  3 sunlang1 sunlang1 4096 Dec 18 14:25 .config
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 myfile.txt
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r--  1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp

二、pwd

语法: pwd
功能:显示用户当前所在的目录

[sunlang1@VM-12-13-centos ~]$ whoami
sunlang1
[sunlang1@VM-12-13-centos ~]$ pwd
/home/sunlang1

三、cd

语法:cd 目录名
功能:改变工作目录。将当前工作目录改变到指定的目录下。
cd .. : 返回上级目录
cd /home/litao/linux/ : 绝对路径
cd ../day02/ : 相对路径
cd ~:进入用户家目
cd -:返回最近访问目录

[sunlang1@VM-12-13-centos ~]$ whoami
sunlang1
[sunlang1@VM-12-13-centos ~]$ pwd
/home/sunlang1
[sunlang1@VM-12-13-centos ~]$ cd ..
[sunlang1@VM-12-13-centos home]$ pwd
/home
[sunlang1@VM-12-13-centos home]$ cd ..
[sunlang1@VM-12-13-centos /]$ pwd
/
[sunlang1@VM-12-13-centos /]$ cd /home/sunlang1
[sunlang1@VM-12-13-centos ~]$ pwd
/home/sunlang1
[sunlang1@VM-12-13-centos ~]$ cd ~
[sunlang1@VM-12-13-centos ~]$ pwd
/home/sunlang1
[sunlang1@VM-12-13-centos ~]$ cd -
/home/sunlang1

四、touch

语法:touch [选项]... 文件...
功能: touch命令参数可更改文档或目录的日期时间,包括存取时间和更改时间,或者新建一个不存在的文件
 

[sunlang1@VM-12-13-centos ~]$ touch mytest.c

五、mkdir

语法: mkdir [选项] dirname...
功能:在当前目录下创建一个名为 “dirname”的目录
mkdir –p test/test1 : 递归建立多个目录

[sunlang1@VM-12-13-centos ~]$ mkdir dir
[sunlang1@VM-12-13-centos ~]$ pwd
/home/sunlang1
[sunlang1@VM-12-13-centos ~]$ mkdir
mkdir: missing operand
Try 'mkdir --help' for more information.
[sunlang1@VM-12-13-centos ~]$ ls
a.out  code  dir  myfile.txt  mytest.c  test.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ mkdir -p dir1/dir2/dir3/dir4/dir5
[sunlang1@VM-12-13-centos ~]$ ls
a.out  code  dir  dir1  myfile.txt  mytest.c  test.c  test.cpp

六、rmdir&rm

rmdir是一个与mkdir相对应的命令。 mkdir是建立目录,而rmdir是删除命令。
语法: rmdir [-p][dirName]
适用对象:具有当前目录操作权限的所有使用者
功能:删除空目录
常用选项:
-p 当子目录被删除后如果父目录也变成空目录的话,就连带父目录一起删除。
rm命令可以同时删除文件或目录

语法: rm [-f-i-r-v][dirName/dir]
适用对象:所有使用者
功能:删除文件或目录
常用选项:
-f 即使文件属性为只读(即写保护),亦直接删除
-i 删除前逐一询问确认
-r 删除目录及其下所有文件
 

[sunlang1@VM-12-13-centos ~]$ rmdir dir
[sunlang1@VM-12-13-centos ~]$ ls
a.out  code  dir1  myfile.txt  mytest.c  test.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ tree dir1
dir1
`-- dir2`-- dir3`-- dir4`-- dir54 directories, 0 files
[sunlang1@VM-12-13-centos ~]$ rm dir1
rm: cannot remove ‘dir1’: Is a directory
[sunlang1@VM-12-13-centos ~]$ rm -r dir1
[sunlang1@VM-12-13-centos ~]$ ls
a.out  code  myfile.txt  mytest.c  test.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ 

七、man

Linux的命令有很多参数,我们不可能全记住,我们可以通过查看联机手册获取帮助。访问Linux手册页的命令是
man 语法: man [选项] 命令
常用选项
-k 根据关键字搜索联机帮助
num 只在第num章节找
-a 将所有章节的都显示出来,比如 man printf 它缺省从第一章开始搜索,知道就停止,用a选项,当按
下q退出,他会继续往后面搜索,直到所有章节都搜索完毕。
解释一下,面手册分为8章
1 是普通的命令
2 是系统调用,如open,write之类的(通过这个,至少可以很方便的查到调用这个函数,需要加什么头文
件)
3 是库函数,如printf,fread4是特殊文件,也就是/dev下的各种设备文件
5 是指文件的格式,比如passwd, 就会说明这个文件中各个字段的含义
6 是给游戏留的,由各个游戏自己定义
7 是附件还有一些变量,比如向environ这种全局变量在这里就有说明
8 是系统管理用的命令,这些命令只能由root使用,如ifconfig


八、cp

语法: cp [选项] 源文件或目录 目标文件或目录
功能: 复制文件或目录
说明: cp指令用于复制文件或目录,如同时指定两个以上的文件或目录,且最后的目的地是一个已经存在的目录,则它会把前面指定的所有文件或目录复制到此目录中。若同时指定多个文件或目录,而最后的目的地并非一个已存在的目录,则会出现错误信息

常用选项:
-f 或 --force 强行复制文件或目录, 不论目的文件或目录是否已经存在
-i 或 --interactive 覆盖文件之前先询问用户
-r递归处理,将指定目录下的文件与子目录一并处理。若源文件或目录的形态,不属于目录或符号链接,则一律视为普通文件处理
-R 或 --recursive递归处理,将指定目录下的文件及子目录一并处理
 

[sunlang1@VM-12-13-centos ~]$ touch file.txt
[sunlang1@VM-12-13-centos ~]$ ll
total 20
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 15:20 file.txt
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 myfile.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ cat file.txt
[sunlang1@VM-12-13-centos ~]$ nano file.txt
[sunlang1@VM-12-13-centos ~]$ cat file.txt
你好呀
我喜欢你
[sunlang1@VM-12-13-centos ~]$ ls
a.out  file.txt    mytest.c  test.cpp
code   myfile.txt  test.c
[sunlang1@VM-12-13-centos ~]$ cp file.txt hello.txt
[sunlang1@VM-12-13-centos ~]$ ls
a.out  file.txt   myfile.txt  test.c
code   hello.txt  mytest.c    test.cpp
[sunlang1@VM-12-13-centos ~]$ cat hello.txt
你好呀
我喜欢你
[sunlang1@VM-12-13-centos ~]$ 

九、mv

mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录。
语法: mv [选项] 源文件或目录 目标文件或目录
功能:
1. 视mv命令中第二个参数类型的不同(是目标文件还是目标目录), mv命令将文件重命名或将其移至一个新的目录中。
2. 当第二个参数类型是文件时, mv命令完成文件重命名,此时,源文件只能有一个(也可以是源目录名),它将所给的源文件或目录重命名为给定的目标文件名。
3. 当第二个参数是已存在的目录名称时,源文件或目录参数可以有多个, mv命令将各参数指定的源文件均移至目标目录中。
常用选项:
-f : force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖
-i :若目标文件 (destination) 已经存在时,就会询问是否覆盖
 

[sunlang1@VM-12-13-centos ~]$ ll
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 file.txt
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:22 hello.txt
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 myfile.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ mv file.txt
mv: missing destination file operand after ‘file.txt’
Try 'mv --help' for more information.
[sunlang1@VM-12-13-centos ~]$ ll
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:22 hello.txt
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 myfile.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ mv myfile.txt hello.txt
[sunlang1@VM-12-13-centos ~]$ ll
total 24
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 hello.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ mv test.c test1.c
[sunlang1@VM-12-13-centos ~]$ ll
total 24
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 hello.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ mkdir dir
[sunlang1@VM-12-13-centos ~]$ ll
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 dir
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 hello.txt
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ mv dir mycode
[sunlang1@VM-12-13-centos ~]$ ls
a.out  code  hello.txt  mycode  mytest.c  test1.c  test.cpp
[sunlang1@VM-12-13-centos ~]$ ls -l
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   23 Dec 18 15:21 hello.txt
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 mycode
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp

九、cat

语法: cat [选项][文件]
功能: 查看目标文件的内容
常用选项:
-b 对非空输出行编号
-n 对输出的所有行编号
-s 不输出多行空行
 

[sunlang1@VM-12-13-centos ~]$ cat hello.txt
你好呀
我喜欢你

十、move

语法: more [选项][文件]
功能: more命令,功能类似 cat
常用选项:
-n 对输出的所有行编号
q 退出more
 

[sunlang1@VM-12-13-centos ~]$ echo "尹倩倩我喜欢你" > hello.txt
[sunlang1@VM-12-13-centos ~]$ ll
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   22 Dec 18 15:45 hello.txt
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 mycode
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
[sunlang1@VM-12-13-centos ~]$ cat hello.txt
尹倩倩我喜欢你
[sunlang1@VM-12-13-centos ~]$ echo "可以做我女朋友吗" >> hello.txt
[sunlang1@VM-12-13-centos ~]$ cat hello.txt
尹倩倩我喜欢你
可以做我女朋友吗

十一、less

less 工具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大。
less 的用法比起 more 更加的有弹性。在 more 的时候,我们并没有办法向前面翻, 只能往后面看
但若使用了 less 时,就可以使用 [pageup][pagedown] 等按键的功能来往前往后翻看文件,更容易用来查看一个文件的内容!
除此之外,在 less 里头可以拥有更多的搜索功能,不止可以向下搜,也可以向上搜。
语法: less [参数] 文件
功能:
less与more类似,但使用less可以随意浏览文件,而more仅能向前移动,却不能向后移动,而且less在查看之前不会加载整个文件。
选项:
-i 忽略搜索时的大小写
-N 显示每行的行号
/字符串:向下搜索“字符串”的功能
?字符串:向上搜索“字符串”的功能
n:重复前一个搜索(与 / 或 ? 有关)
N:反向重复前一个搜索(与 / 或 ? 有关)
q:quit


十二、head

head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块, head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾。
语法: head [参数]... [文件]...
功能:
head 用来显示档案的开头至标准输出中,默认head命令打印其相应文件的开头10行。
选项:
-n<行数> 显示的行数

十三、tail

tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -
f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新,使你看到最新的文件内容.
语法: tail[必要参数][选择参数][文件]
功能: 用于显示指定文件末尾内容,不指定文件时,作为输入信息进行处理。常用查看日志文件。
 

[sunlang1@VM-12-13-centos ~]$ head hello.txt
尹倩倩我喜欢你
可以做我女朋友吗
[sunlang1@VM-12-13-centos ~]$ head -20 hello.txt
尹倩倩我喜欢你
可以做我女朋友吗
[sunlang1@VM-12-13-centos ~]$ tail -20 hello.txt
尹倩倩我喜欢你
可以做我女朋友吗
[sunlang1@VM-12-13-centos ~]$ head -2 hello.txt | tail -1
可以做我女朋友吗

十四、时间

date显示
date 指定格式显示时间: date +%Y:%m:%d
date 用法: date [OPTION]... [+FORMAT]

1.在显示方面,使用者可以设定欲显示的格式,格式设定为一个加号后接数个标记,其中常用的标记列表如下

%H : 小时(00..23)
%M : 分钟(00..59)
%S : 秒(00..61)
%X : 相当于 %H:%M:%S
%d : 日 (01..31)
%m : 月份 (01..12)
%Y : 完整年份 (0000..9999)
%F : 相当于 %Y-%m-%d
2.在设定时间方面

date -s //设置当前时间,只有root权限才能设置,其他只能查看。
date -s 20080523 //设置成20080523,这样会把具体时间设置成空00:00:00
date -s 01:01:01 //设置具体时间,不会对日期做更改
date -s “01:01:01 2008-05-23″ //这样可以设置全部时间
date -s “01:01:01 20080523″ //这样可以设置全部时间
date -s “2008-05-23 01:01:01″ //这样可以设置全部时间
date -s “20080523 01:01:01″ //这样可以设置全部时间

3.时间戳
时间->时间戳: date +%s
时间戳->时间: date -d@1508749502
Unix时间戳(英文为Unix epoch, Unix time, POSIX time 或 Unix timestamp)是从1970年1月1日(UTC/GMT的
午夜)开始所经过的秒数,不考虑闰秒
 

[sunlang1@VM-12-13-centos ~]$ date
Sun Dec 18 15:56:21 CST 2022

十五、cal

cal命令可以用来显示公历(阳历)日历。公历是现在国际通用的历法,又称格列历,通称阳历。 “阳历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”。

[sunlang1@VM-12-13-centos ~]$ date +%Y-%m-%d_%H:%M:%S
2022-12-18_16:00:26
[sunlang1@VM-12-13-centos ~]$ calDecember 2022   
Su Mo Tu We Th Fr Sa1  2  34  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

十六、find

Linux下find命令在目录结构中搜索文件,并执行指定的操作。
Linux下find命令提供了相当多的查找条件,功能很强大。由于find具有强大的功能,所以它的选项也很多,其中大部分选项都值得我们花时间来了解一下。
即使系统中含有网络文件系统( NFS), find命令在该文件系统中同样有效,只你具有相应的权限。
在运行一个非常消耗资源的find命令时,很多人都倾向于把它放在后台执行,因为遍历一个大的文件系统可能会花费很长的时间(这里是指30G字节以上的文件系统)


十七、grep

语法: grep [选项] 搜寻字符串 文件
功能: 在文件中搜索字符串,将找到的行打印出来
常用选项:
-i :忽略大小写的不同,所以大小写视为相同
-n :顺便输出行号
-v :反向选择,亦即显示出没有 '搜寻字符串' 内容的那一行
 

[sunlang1@VM-12-13-centos ~]$ nano hello.txt
[sunlang1@VM-12-13-centos ~]$ grep 'c++" hello.txt
> ^C
[sunlang1@VM-12-13-centos ~]$ grep 'c++' hello.txt
c++
[sunlang1@VM-12-13-centos ~]$ grep -i 'c++' hello.txt
c++
C++
[sunlang1@VM-12-13-centos ~]$ grep -iv 'c++' hello.txt
尹倩倩我喜欢你
可以做我女朋友吗
c
Java
Python
python
shell
Shell
go
Go

十八、zip/unzip

语法: zip 压缩文件.zip 目录或文件
功能: 将目录或文件压缩成zip格式
常用选项:
-r 递 归处理,将指定目录下的所有文件和子目录一并处理
 

@VM-12-13-centos ~]$ touch test.zip
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c     test1.c   test.zip
code   mycode     tar_package  test.cpp
[sunlang1@VM-12-13-centos ~]$ zip -r test.zip tar_packagezip warning: missing end signature--probably not a zip file (did youzip warning: remember to use binary mode when you transferred it?)zip warning: (if you are trying to read a damaged archive try -F)zip error: Zip file structure invalid (test.zip)
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c     test1.c   test.zip
code   mycode     tar_package  test.cpp
[sunlang1@VM-12-13-centos ~]$ rm -rf tar_package
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c  test.cpp
code   mycode     test1.c   test.zip
[sunlang1@VM-12-13-centos ~]$ zip test.zipzip warning: missing end signature--probably not a zip file (did youzip warning: remember to use binary mode when you transferred it?)zip warning: (if you are trying to read a damaged archive try -F)zip error: Zip file structure invalid (test.zip)
[sunlang1@VM-12-13-centos ~]$ unzip test.zip
Archive:  test.zipEnd-of-central-directory signature not found.  Either this file is nota zipfile, or it constitutes one disk of a multi-part archive.  In thelatter case the central directory and zipfile comment will be found onthe last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test.zip ortest.zip.zip, and cannot find test.zip.ZIP, period.
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c  test.cpp
code   mycode     test1.c   test.zip
[sunlang1@VM-12-13-centos ~]$ ls tar_package
ls: cannot access tar_package: No such file or directory
[sunlang1@VM-12-13-centos ~]$ ls /tar_package
ls: cannot access /tar_package: No such file or directory
[sunlang1@VM-12-13-centos ~]$ cat tac_package
cat: tac_package: No such file or directory
[sunlang1@VM-12-13-centos ~]$ 
[sunlang1@VM-12-13-centos ~]$ unzip test.zip -d /home/sunlang1
Archive:  test.zipEnd-of-central-directory signature not found.  Either this file is nota zipfile, or it constitutes one disk of a multi-part archive.  In thelatter case the central directory and zipfile comment will be found onthe last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test.zip ortest.zip.zip, and cannot find test.zip.ZIP, period.
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c  test.cpp
code   mycode     test1.c   test.zip
[sunlang1@VM-12-13-centos ~]$ ls -l /home/sunlang1
total 28
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   95 Dec 18 16:03 hello.txt
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 mycode
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 16:13 test.zip
[sunlang1@VM-12-13-centos ~]$ 
[sunlang1@VM-12-13-centos ~]$ tar czf test.tgz tar_package
tar: tar_package: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
[sunlang1@VM-12-13-centos ~]$ ls
a.out  hello.txt  mytest.c  test.cpp  test.zip
code   mycode     test1.c   test.tgz
[sunlang1@VM-12-13-centos ~]$ ls -l
total 32
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   95 Dec 18 16:03 hello.txt
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 mycode
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
-rw-rw-r-- 1 sunlang1 sunlang1   45 Dec 18 16:18 test.tgz
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 16:13 test.zip
[sunlang1@VM-12-13-centos ~]$ tar xzf test.tgz
[sunlang1@VM-12-13-centos ~]$ ls -l
total 32
-rwxrwxr-x 1 sunlang1 sunlang1 8360 Dec 18 15:03 a.out
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 14:31 code
-rw-rw-r-- 1 sunlang1 sunlang1   95 Dec 18 16:03 hello.txt
drwxrwxr-x 2 sunlang1 sunlang1 4096 Dec 18 15:38 mycode
-rw-rw-r-- 1 sunlang1 sunlang1   70 Dec 18 15:03 mytest.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test1.c
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 14:30 test.cpp
-rw-rw-r-- 1 sunlang1 sunlang1   45 Dec 18 16:18 test.tgz
-rw-rw-r-- 1 sunlang1 sunlang1    0 Dec 18 16:13 test.zip
[sunlang1@VM-12-13-centos ~]$ tar xzf test.tgz -C /home/sunlang1
[sunlang1@VM-12-13-centos ~]$ 

十九、tar

tar [-cxtzjvf] 文件与目录 ....
参数: 

-c :建立一个压缩文件的参数指令(create 的意思);
-x :解开一个压缩文件的参数指令!
-t :查看 tarfile 里面的文件!
-z :是否同时具有 gzip 的属性?亦即是否需要用 gzip 压缩?
-j :是否同时具有 bzip2 的属性?亦即是否需要用 bzip2 压缩?
-v :压缩的过程中显示文件!这个常用,但不建议用在背景执行过程!
-f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
-C : 解压到指定目录


二十、计算器

[sunlang1@VM-12-13-centos ~]$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
3+9
12
^C
(interrupt) Exiting bc.
[sunlang1@VM-12-13-centos ~]$ 

二十一、uname

语法: uname [选项]
功能: uname用来获取电脑和操作系统的相关信息。
补充说明: uname可显示linux主机所用的操作系统的版本、硬件的名称等基本信息。
常用选项: 

-a或–all 详细输出所有信息,依次为内核名称,主机名,内核版本号,内核版本,硬件名,处理器类型,硬件平台类型,操作系统名称

[sunlang1@VM-12-13-centos ~]$ uname -a
Linux VM-12-13-centos 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[sunlang1@VM-12-13-centos ~]$ uname -r
3.10.0-1160.71.1.el7.x86_64

二十二、热键

[Tab]按键---具有『命令补全』和『档案补齐』的功能
[Ctrl]-c按键---让当前的程序『停掉』
[Ctrl]-d按键---通常代表着:『键盘输入结束(End Of File, EOF 戒 End OfInput)』的意思;另外,他也可以用来取代exit


二十三、关机

补充:

安装和登录命令: login、 shutdown、 halt、 reboot、 install、 mount、 umount、 chsh、 exit、 last;
◆ 文件处理命令: file、 mkdir、 grep、 dd、 find、 mv、 ls、 diff、 cat、 ln;
◆ 系统管理相关命令: df、 top、 free、 quota、 at、 lp、 adduser、 groupadd、 kill、 crontab;
◆ 网络操作命令: ifconfig、 ip、 ping、 netstat、 telnet、 ftp、 route、 rlogin、 rcp、 finger、 mail、 nslookup;
◆ 系统安全相关命令: passwd、 su、 umask、 chgrp、 chmod、 chown、 chattr、 sudo ps、 who;
◆ 其它命令: tar、 unzip、 gunzip、 unarj、 mtools、 man、 unendcode、 uudecode。
 

相关内容

热门资讯

安卓系统源码怎么打开,并可能需... 你有没有想过,安卓系统的源码就像是一扇神秘的门,隐藏着无数的技术秘密?想要打开这扇门,你得掌握一些小...
安卓8.0系统体验视频,智能革... 你有没有听说安卓8.0系统最近可是火得一塌糊涂啊!作为一个紧跟科技潮流的数码达人,我当然要来给你好好...
宣传系统漫画app安卓,探索安... 亲爱的读者们,你是否曾在某个午后,百无聊赖地打开手机,想要寻找一些轻松愉悦的读物?今天,我要给你介绍...
鸿蒙替换安卓系统吗,开启智能生... 你知道吗?最近科技圈里可是炸开了锅,因为华为的新操作系统鸿蒙系统,据说要大举进军手机市场,替换掉安卓...
手机安卓系统深度清理,解锁手机... 手机里的东西是不是越来越多,感觉就像一个装满了杂物的储物柜?别急,今天就来教你一招——手机安卓系统深...
安卓上的windows系统,融... 你有没有想过,在安卓手机上也能体验到Windows系统的魅力呢?没错,这就是今天我要跟你分享的神奇故...
安卓系统焦点变化事件,Andr... 你知道吗?在安卓系统的世界里,最近发生了一件超级有趣的事情——焦点变化事件。这可不是什么小打小闹,它...
一加系统安卓降级,轻松还原经典... 你有没有想过,你的手机系统升级后,突然发现某些功能变得不那么顺心了?别急,今天就来聊聊一加系统安卓降...
日本最好的安卓系统,体验非凡 亲爱的读者们,你是否曾想过,在遥远的东方,有一个国家,他们的智能手机系统独具特色,让人眼前一亮?没错...
荣耀安卓11 系统证书,保障安... 你知道吗?最近手机圈里可是炸开了锅,荣耀安卓11系统证书成了大家热议的话题。这不,我就迫不及待地来和...
安卓手机开机升级系统,体验流畅... 你有没有发现,每次你的安卓手机开机,总会有那么一刹那,屏幕上跳出一个升级系统的提示?是不是觉得这就像...
真正的安卓系统手机,安卓系统手... 你有没有想过,为什么有些人对安卓系统手机情有独钟?是不是觉得市面上的安卓手机千篇一律,缺乏个性?别急...
安卓怎么用定位系统,轻松实现精... 你有没有想过,手机里的定位系统竟然这么神奇?它不仅能帮你找到回家的路,还能在茫茫人海中找到你的好友。...
安卓的哪个系统流畅,探索新一代... 你有没有想过,为什么你的安卓手机有时候像蜗牛一样慢吞吞的,而别人的手机却像风一样快?今天,就让我带你...
安卓系统解锁工具下载,畅享自由 你是不是也和我一样,对安卓系统的解锁工具感兴趣呢?想象你的手机被锁住了,无论是忘记密码还是想尝试新的...
谷歌退出安卓系统停用,停用背后... 你知道吗?最近有个大新闻在科技圈里炸开了锅!谷歌竟然宣布要退出安卓系统,这可真是让人大跌眼镜啊!想象...
安卓系统卡顿修复,轻松提升手机... 手机用久了是不是感觉有点卡卡的呢?别急,今天就来给你支几招,让你的安卓手机重焕生机,告别卡顿的烦恼!...
安卓系统停用怎么解除,轻松恢复... 你是不是也遇到了安卓系统停用的问题,急得像热锅上的蚂蚁?别急,今天就来给你详细解析怎么解除这个让人头...
最初始的安卓系统,技术演进与产... 亲爱的读者,你是否曾好奇过,那个如今无处不在的安卓系统,它的诞生之初是怎样的呢?今天,就让我们一起穿...
patchwall系统和安卓系... 你有没有发现,手机上的界面越来越个性化了?没错,这就是科技的魅力所在。今天,咱们就来聊聊两个在个性化...