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。
 

相关内容

热门资讯

安卓如何操控苹果系统,揭秘跨平... 你知道吗?在这个科技飞速发展的时代,安卓和苹果两大操作系统之间的较量可是从未停歇。虽然它们各自有着忠...
安卓系统账户同步数据,畅享无缝... 你有没有遇到过这种情况:手机里存了那么多宝贝照片、重要文件,结果换了个新手机,却发现那些宝贝全都不翼...
安卓系统不停推送广告,安卓系统... 你有没有发现,最近你的安卓手机是不是越来越“热情”了?没错,就是那个不停在你屏幕上跳来跳去的广告!今...
airpods可以和安卓系统,... 你有没有想过,那些炫酷的AirPods竟然也能和安卓手机完美搭配?没错,就是那个我们平时只听说和iP...
安卓系统实体键盘不对,创新与挑... 你是不是也遇到了这个问题?安卓手机的实体键盘突然不对劲了,按下去没反应,或者反应迟钝,简直让人抓狂!...
汽车导航改装安卓系统,安卓系统... 你有没有想过,你的汽车导航系统是不是已经out了?现在,让我来给你揭秘如何给你的爱车来一次科技大变身...
安卓系统如何限制下载,安卓系统... 你有没有发现,手机里的安卓系统越来越智能了?不过,这也意味着有时候我们不小心就会下载一些不想要的软件...
安卓系统调成日语,概要の副標題... 你有没有想过,你的安卓手机竟然可以变成一个日式小天地呢?没错,就是那种动漫里常见的日语界面,是不是听...
男生耳机推荐安卓系统,男生耳机... 耳机可是现代生活中不可或缺的小玩意儿,尤其是对于喜欢听音乐的男生来说,一副好耳机简直就是灵魂的伴侣。...
安卓同版本升级系统,功能优化与... 你知道吗?最近手机界可是热闹非凡呢!各大品牌纷纷推出了安卓同版本升级系统,让我们的手机焕然一新。今天...
安卓更换别的手机系统,轻松切换... 你有没有想过,你的安卓手机用久了,是不是有点审美疲劳了呢?或者,你最近是不是对其他手机系统产生了浓厚...
安卓系统单机神雕侠侣,指尖重温 你有没有想过,在手机上也能体验一把江湖恩怨、侠骨柔肠?没错,就是那个让人心驰神往的《神雕侠侣》!今天...
安卓系统键盘语言切换,安卓系统... 你有没有发现,手机上的安卓系统键盘语言切换功能,简直就像是个神奇的魔法棒,轻轻一点,就能让文字飞舞在...
oppok1安卓系统,性能与体... 你有没有发现,最近手机圈里又掀起了一股热潮?没错,就是OPPO K1这款新机!这款手机不仅外观时尚,...
安卓系统环境的搭建,从零开始构... 想要在电脑上体验安卓系统的魅力,是不是已经跃跃欲试了呢?别急,今天就来手把手教你如何搭建一个属于自己...
【MySQL】锁 锁 文章目录锁全局锁表级锁表锁元数据锁(MDL)意向锁AUTO-INC锁...
【内网安全】 隧道搭建穿透上线... 文章目录内网穿透-Ngrok-入门-上线1、服务端配置:2、客户端连接服务端ÿ...
GCN的几种模型复现笔记 引言 本篇笔记紧接上文,主要是上一篇看写了快2w字,再去接入代码感觉有点...
数据分页展示逻辑 import java.util.Arrays;import java.util.List;impo...
Redis为什么选择单线程?R... 目录专栏导读一、Redis版本迭代二、Redis4.0之前为什么一直采用单线程?三、R...