在Ubuntu或linux中为coreutils工具包的cp和mv命令添加进度条

1、查看当前最新的coreutils版本:

http://ftp.gnu.org/gnu/coreutils/

2、安装coreutils过程

wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.4.tar.xz

tar -xJf coreutils-9.4.tar.xz

cd coreutils-9.4/

对照上面的,下载对应coreutils版本的advcpmv版本。

https://github.com/jarun/advcpmv

wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.4.patch

patch -p1 -i advcpmv-0.9-9.4.patch

./configure FORCE_UNSAFE_CONFIGURE=1

configure: creating ./config.status

config.status: creating Makefile

config.status: creating po/Makefile.in

config.status: creating gnulib-tests/Makefile

config.status: creating lib/config.h

config.status: executing depfiles commands

config.status: executing po-directories commands

config.status: creating po/POTFILES

config.status: creating po/Makefile

make

make[4]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[3]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[2]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[1]: Leaving directory '/root/coreutils-9.4'
注:直接编译会出错,需要增加FORCE_UNSAFE_CONFIGURE=1 参数配置。

checking whether mknod can create fifo without root privileges... configure: error: in '/root/coreutils-9.4':

configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)

See 'config.log' for more details

替代当前系统命令,有必要可以先备份一下原来的,替换测试后,再将原有版本删除。

$ sudo cp src/cp /usr/local/bin/cp

$ sudo cp src/mv /usr/local/bin/mv

接着我们只需要在使用cp和mv命令的时候加上-g参数就可以显示进度条了。

为了方便起见我们可以在.bashrc文件中设置alias

alias cp='cp -ig'

alias mv='mv -ig'

至此,完成。

相关推荐
Maki Winster12 分钟前
在 Ubuntu 下配置 oh-my-posh —— 普通用户 + root 各自使用独立主题(共享可执行)
linux·运维·ubuntu
守望时空3314 分钟前
Linux下KDE桌面创建自定义右键菜单
linux
l0sgAi35 分钟前
vLLM在RTX50系显卡上部署大模型-使用wsl2
linux·人工智能
翻滚吧键盘43 分钟前
debian及衍生发行版apt包管理常见操作
运维·debian
Charlene Fung2 小时前
vs code远程自动登录服务器,无需手动输入密码的终极方案(windows版)
运维·服务器·vscode·ssh
麟城Lincoln2 小时前
【RHCSA-Linux考试题目笔记(自用)】servera的题目
linux·笔记·考试·rhcsa
碣石潇湘无限路2 小时前
【部署与总结】从本地运行到公网服务器的全过程
运维·服务器
linux修理工2 小时前
ipmitool 使用简介(ipmitool sel list & ipmitool sensor list)
运维·服务器
寻月隐君2 小时前
保姆级教程:Zsh + Oh My Zsh 终极配置,让你的 Ubuntu 终端效率倍增
linux·后端·命令行
XM-54582 小时前
2025微信小程序wxapkg解包全攻略
linux·运维·小程序