为linux内核创建补丁文件

gst*_*gst 2 linux diff sudo ubuntu-12.04

我正在尝试创建一个补丁文件,用于我在linux内核中所做的修改.原始目录是/usr/src/linux.vanilla,新内核是/ usr/src/linux-master.我用的命令是

h@ubuntu:/usr/src$ sudo diff -rupN  linux-master/ linux.vanilla/ > original.patch 
Run Code Online (Sandbox Code Playgroud)

但是我收到一个错误说明

bash: original.patch: Permission denied
Run Code Online (Sandbox Code Playgroud)

任何人都可以指出我出错的地方.我使用的是Ubuntu和Linux内核版本3.15.0.

谢谢.

Bil*_*nch 5

您键入终端的命令是:

sudo diff -rupN  linux-master/ linux.vanilla/ > original.patch 
Run Code Online (Sandbox Code Playgroud)

这将以root身份运行:

diff -rupN  linux-master/ linux.vanilla/
Run Code Online (Sandbox Code Playgroud)

然后作为普通用户帐户,它会将输出写入

original.patch
Run Code Online (Sandbox Code Playgroud)

但是,您没有写入权限original.patch.

修复1

在root shell下完成工作.

sudo su
diff -rupN  linux-master/ linux.vanilla/ > original.patch 
Run Code Online (Sandbox Code Playgroud)

修复2

使用tee重定向到一个文件中.

sudo diff -rupN  linux-master/ linux.vanilla/ | sudo tee original.patch 
Run Code Online (Sandbox Code Playgroud)

修复3

将文件写入主目录(或您具有写权限的其他位置).

sudo diff -rupN  linux-master/ linux.vanilla/ > ~/original.patch 
Run Code Online (Sandbox Code Playgroud)

  • 修复3:将输出写入别处? (2认同)