Linux常用命令,能解决工作中99%的Linux操作问题

news2024/9/23 5:35:23

目录

一、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
            `-- dir5

4 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 ~]$ cal
    December 2022   
Su Mo Tu We Th Fr Sa
             1  2  3
 4  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_package
	zip warning: missing end signature--probably not a zip file (did you
	zip 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.zip
	zip warning: missing end signature--probably not a zip file (did you
	zip 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.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test.zip or
        test.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.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test.zip or
        test.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。
 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/98729.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot 整合Netty自定义消息协议

本文主要介绍springboot项目&#xff0c;配置netty进行消息通信&#xff0c;自定义的netty消息协议&#xff0c;本文消息主要以表格中进行 消息头消息体长度加密标识&#xff08;可选&#xff09;加密类型&#xff08;可选&#xff09;消息体标识消息体校验码2字节2字节1字节&…

SAP ABAP——SAP简介(一)【SAP发展历程】

&#x1f482;作者简介&#xff1a; THUNDER王&#xff0c;一名热爱财税和SAP ABAP编程以及热爱分享的博主。目前于江西师范大学会计学专业大二本科在读&#xff0c;同时任汉硕云&#xff08;广东&#xff09;科技有限公司ABAP开发顾问。在学习工作中&#xff0c;我通常使用偏后…

研究必备的 5 个外文文献检索网站

1. Google scholar 网址&#xff1a; https://scholar.google.com.hk/?hlzh-CN 如今搜索论文的首选&#xff0c;可以在这里查看论文统计和引用参考文献&#xff0c;还能通过关注作者或者论文获得新论文更新提醒&#xff0c;以及利用自动化推荐来提供一个基本库 2. DBLP 网址…

MSVC C++ UTF-8编程

除windows平台外大部分其他平台&#xff0c;编译器默认使用的编码都是UTF-8编码&#xff0c;最新版本的Clang编译器只支持UTF-8编码。如果程序需要在多个平台编译运行&#xff0c;则代码必须使用UTF-8。使用UTF-8可以更容易的在多字节字符串(char, std::string)和宽字符(wchar_…

Java+SSM汽车租赁系统汽车出租(含源码+论文+答辩PPT等)

项目功能简介: 该项目采用的技术实现如下 后台框架&#xff1a;Spring、SpringMVC、MyBatis UI界面&#xff1a;jQuery 、JSP 数据库&#xff1a;MySQL 系统功能 系统分为前台用户租车和后台系统管理&#xff1a; 1.前台用户租车 用户注册、用户登录、用户中心、浏览车辆、车辆…

Java项目:SSM在线二手图书交易商城网站平台

作者主页&#xff1a;源码空间站2022 简介&#xff1a;Java领域优质创作者、Java项目、学习资料、技术互助 文末获取源码 项目介绍 用户角色包含以下功能&#xff1a; 用户登录,查看商品详情,按分类查看,查看我的书架,上传二手书等功能。 由于本程序规模不大&#xff0c;可供课…

三、CAM可解释性分析——可解释性机器学习(DataWhale组队学习)

文章目录前言CAM算法的精妙之处相关工作CAM算法其它相关问题为什么不用池化操作&#xff1f;CAM的优点CAM算法的缺点扩展阅读和思考题前言 CAM算法奠定了可解释分析的基石 CAM算法的精妙之处 对深度学习实现可解释性分析、显著性分析可扩展性强&#xff0c;后续衍生出各种…

域名备案怎么查?怎么批量查询域名备案

ICP备案&#xff0c;是为了防止在网上从事非法的网站经营活动&#xff0c;打击不良互联网信息的传播&#xff0c;国家对互联网信息服务实行的备案制度。 备案的目的就是为了防止在网上从事非法的网站经营活动&#xff0c;打击不良互联网信息的传播&#xff0c;如果网站不备…

Android TP驱动模型框架分析

本文主要是对TP驱动框架的学习。 一、概述 1、触摸IC的工作原理 tp与主控间的通信接口一般是i2c&#xff0c;即scl、sda、gnd、vcc。在正常工作时需要加上rst、int脚。 整个过程是&#xff1a;通过点击屏幕&#xff0c;tp ic端会将int 脚电平拉低&#xff0c;等待主控的读取。…

【技术分享】Anaconda下载、安装、pip切换镜像源、conda切换镜像、conda创建指定Python版本虚拟环境教程

文章目录1.下载Anaconda1.1.下载最新版本Anaconda1.2.下载历史版本的Anaconda2.安装Anaconda3.conda切换镜像源4.pip切换镜像源5.conda创建指定版本Python环境1.下载Anaconda 1.1.下载最新版本Anaconda 步骤&#xff1a; 进入Anaconda官网&#xff0c;点击Download按钮下载最…

海量数据小内存!如何找到高频数

文章目录题目解答总结题目 如何在 20 亿个无符号整数中找到出现次数最多的那个数&#xff0c;在只提供 1 G 内存的条件下 解答 找到出现次数最多的数&#xff0c;通常的思维就是使用 HashMap 来统计这 20 亿个无符号整数中每个数出现的次数 已知只有 20 亿个数&#xff0c;…

b站黑马的Vue快速入门案例代码——【axios+Vue2】悦听player(音乐播放器)

目录 本文中修改的原代码中的BUG&#xff1a; 修改方法&#xff1a; 本文案例代码仍有的BUG&#xff1a;&#xff08;欢迎大家献计献策&#xff09; 目标效果&#xff1a; 悦音player案例——效果展示视频&#xff1a; 更换的新接口/参数&#xff1a; 1.歌曲搜索接口&…

实战讲解及分析Spring新建Bean的几种方式以及创建过程(图+文+源码)

1 缘起 作为一个应用开发人员而言&#xff0c;会使用某一个工具分为两个层次&#xff08;个人观点&#xff09;&#xff1a; 第一个层次&#xff0c;知道工具&#xff0c;会使用这个工具解决问题&#xff1b; 第二个层次&#xff0c;理解工具的实现原理。 关于Spring的学习&am…

Linux Centos7 磁盘的分区、挂载

1、前言 注&#xff1a;看不懂的同学可以直接跟着后面的步骤操作 一块新的磁盘放到电脑上&#xff0c;要经过分区-->给分区设置文件系统--->挂载才能用。 也就是说要想将磁盘挂载&#xff0c;必须完成给磁盘分区和给分区设置文件系统这两步。 分区的时候先分成主分区和扩…

【DBN分类】基于matlab深度置信网络DBN变压器故障诊断【含Matlab源码 2284期】

一、深度置信网络DBN变压器故障诊断简介 1 DBN模型 DBN是深度学习中最关键的一个多层网络架构&#xff0c;如图2所示&#xff0c;由多层RBM堆叠而成&#xff0c;前一层RBM的输出为后一层RBM的输入&#xff0c;最顶层采用Softmax分类器作为标签层&#xff0c;输出分类识别的结果…

AD-DA转换(PCF8591)

AD转换目录一、AD转换&#xff08;PCF8591&#xff09;①初始化函数②读取ADC值的函数二、DA转换&#xff08;PCF8591&#xff09;三、STC15系列单片机用户手册.pdf—第10章一、AD转换&#xff08;PCF8591&#xff09; 思路&#xff1a;&#xff08;66&#xff0c;两个地址0x90…

RNA-seq——上游分析练习2(数据下载+trim-galore+hisat2+samtools+featureCounts)

目录软件安装新建文件夹一、下载数据二、质控过滤1.数据质量检测2.数据质量控制3.对处理后的数据再次QC三、序列比对1.hisat2比对2.flagstat检查一下结果四、featureCounts定量写在前面——本文是转录组上游分析的实战练习。主要包含四个步骤&#xff1a; 数据下载&#xff08…

DockerCompose编排Redis6.2.6以及遇到的那些坑

场景 Docker中使用Dockerfile的方式部署SpringBootVue前后端分离的项目(若依前后端分离框架为例): Docker中使用Dockerfile的方式部署SpringBootVue前后端分离的项目(若依前后端分离框架为例)_霸道流氓气质的博客-CSDN博客_若依 dockerfile 在上面使用Dockerfile分别构建每个…

Heron‘s formula

In geometry, Heron’s formula (or Hero’s formula) gives the area A of a triangle in terms of the three side lengths a, b, c. If {\textstyle s{\tfrac {1}{2}}(abc)}{\textstyle s{\tfrac {1}{2}}(abc)} is the semiperimeter of the triangle, the area is,[1] {\d…

影视中学职场套路——《如懿传》中职场生存法则

目录 一、老板决定的事&#xff0c;赞成不赞成都要执行 二、居人之下&#xff0c;聪明劲儿别往外露 三、切忌大庭广众直接与上级冲突 四、取悦所有人&#xff0c;不如取悦最大的boss 五、再强的人&#xff0c;也需要团队作战 六、人善被人欺&#xff08;首先要自保&#…