Ubuntu 批量压缩文件夹

安装软件 sudo apt-get update sudo apt-get install parallel sudo apt-get install pigz 建立一个可执行文件,如compress_dirs.sh #!/bin/bash # Function to compress a directory using pigz compress_dir() { local dir=$1 tar -cf - "$dir" | pigz > "${dir}.tar.gz" } export -f compress_dir # Check if at least one argument (the root directory) is provided if [ "$#" -lt 1 ]; then echo "Usage: $0 root_directory [exclude_folder1 exclude_folder2 ...]" exit 1 fi # Get the root directory root_directory=$1 shift # Get the folders to exclude exclude_folders=("$@") # Build the find command with exclusion criteria find_command="find \"$root_directory\" -maxdepth 1 -type d -not -path '$root_directory'" for folder in "${exclude_folders[@]}"; do find_command+=" -not -name \"$(basename "$folder")\"" done # Execute the find command and compress the directories using parallel with progress bar and increased parallelism eval "$find_command" | parallel --bar compress_dir 使用方法 ...

2024年6月10日 · 1 分钟 · sun510001

树莓派5 编译安装opencv和gstreamer插件

基于以下文章使用 树莓派4B 安装opencv完整教程基于python3(各种错误解决)-腾讯云开发者社区-腾讯云 下载opencv_4.9.0, opencv_contrib_4.9.0, 在opencv文件夹下建立编译地址 cd opencv mkdir build cd build 修改cmake命令 cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/sun/Desktop/camera/downloads/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON \ -D WITH_LIBV4L=ON \ -D WITH_GSTREAMER=ON \ -D PYTHON3_EXECUTABLE=/usr/bin/python3.11 \ -D PYTHON_INCLUDE_DIR=/usr/include/python3.11 \ -D PYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.11.so \ -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \ .. cmake结束的时候会打印出, 要安装的opencv的插件. 安装 make make install 查看安装是否成功 import cv2 print(cv2.__version__) print(cv2.getBuildInformation()) ...

2024年6月1日 · 1 分钟 · sun510001

TrueNas初期配置

0. 微超主板登陆 超微主板使用配置 ipmi 功能流程介绍 用户名和密码都是: ADMIN 可以在配置-用户中更改密码 设置时间 显示画面 在远程控制中找到iKVM/HTML5, 可以启动远程管理服务器, 在网页端直接看到开机时显示的bios等画面, 就不需要外接显示器了. ...

2023年4月19日 · 9 分钟 · sun510001

威联通QNAP Nas 相关问题

Nas静音 威联通Nas买来之后每天3点都会自动开始一些计划任务, 关闭后晚上安静不少 关于计划任务的说明和操作在这里 Add items to crontab # ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * * <command to execute> 问题是执行sudo crontab /etc/config/crontab && sudo /etc/init.d/crond.sh restart 命令之后, 一些任务又会自动重置 0 3 * * * /sbin/vs_refresh 4 3 * * 3 /etc/init.d/backup_conf.sh 解决方法: 问题出在/etc/init.d/crond.sh 上, 修改之 ############# # 46行 echo "0 3 * * * /sbin/vs_refresh" >> /etc/config/crontab # 或者新版 46行 local time=$(/sbin/getcfg vs_refresh schedule -d '13:0') ############ # 88-97行 1) #once a day echo "4 13 * * * /etc/init.d/backup_conf.sh" >> /etc/config/crontab ;; 30) #once a month echo "4 13 3 * * /etc/init.d/backup_conf.sh" >> /etc/config/crontab ;; 7) #once a week echo "4 13 * * 3 /etc/init.d/backup_conf.sh" >> /etc/config/crontab ;; *) #for testing echo "*/3 * * * * /etc/init.d/backup_conf.sh" >> /etc/config/crontab ;; 重启nas可能会重置设置 需注意. ...

2022年11月16日 · 3 分钟 · sun510001

无法远程连接Linux服务器故障排查记录

服务器ssh服务 在服务器上查看ssh服务, 或直接用本账号直接登陆服务器. 查看服务器网络服务, 打印路由表 ifconfig 或 ip addr ip route show route ping 查看是否ping通或有没有被跳转到其他ip地址 其他设备 ping 服务器 服务器 ping 其他设备 其他设备 ping 网关 服务器 ping 网关 查看防火墙设置 iptables -L 查看系统日志 需要事先启动服务 Ubuntu系统配置日志/var/log/message ...

2022年2月14日 · 2 分钟 · sun510001

Linux 问题整理

Linux Ubuntu 20.04 系统安装流程 NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running. $ sudo add-apt-repository ppa:graphics-drivers/ppa $ ubuntu-drivers devices $ sudo apt install nvidia-driver-460 # edit GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub. 可以不用 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=realloc" or GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" $ sudo update-grub $ sudo reboot 移动文件夹下所有文件, 包括子文件夹下的内容 Open a terminal and execute this command: mv -v ~/Downloads/* ~/Videos/ It will move all the files and folders from Downloads folder to Videos folder. To move all files, but not folders: If you are interested in moving all files (but not folders) from Downloads folder to Videos folder, use this command find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos To move only files from the Download folders, but not from sub-folders: If you want to move all files from the Downloads folder, but not any files within folders in the Download folder, use this command: find ~/Downloads/ -maxdepth 1 -type f -print0 | xargs -0 mv -t ~/Videos here, -maxdepth option specifies how deep find should try, 1 means, only the directory specified in the find command. You can try using 2, 3 also to test. 文件大小查看命令 查看某一个文件夹的大小 du -sh [文件夹] 查看当前文件夹下的文件大小总和 ls | wc -l 文件查找命令 查找遍历文件夹下所有文件后缀为jpg的文件并复制 find [查找文件夹] -name "*.jpg" | xargs -i cp {} [输出文件夹] 批量执行命令 awk 查找文件后批量处理 ls | grep zip | awk -F . '{system("echo " $1)}' "ffmpeg -i " $1 ".wav -ar 36000 ../Wave_2/" $1 ".wav" for %a in ("*.wav") do ffmpeg -i "%a" -ar 36000 "\%~na.wav" script 输入参数: 直接写 $1 就是第一个参数 获得当前文件夹名 echo $(basename $(pwd)) DNS服务器地址修改 找到/etc/resolv.conf nameserver 就是DNS服务器地址 图形界面添加自动启动项 gnome-session-properties 文本界面设置子启动服务 写服务文件,如nginx.service、redis.service、supervisord.service [Unit]:服务的说明 Description:描述服务 After:描述服务类别 [Service]服务运行参数的设置 Type=forking 是后台运行的形式 ExecStart 为服务的具体运行命令 ExecReload 为服务的重启命令 ExecStop 为服务的停止命令 PrivateTmp=True 表示给服务分配独立的临时空间 注意:启动、重启、停止命令全部要求使用绝对路径 [Install] 服务安装的相关设置,可设置为多用户 WantedBy=multi-user.target 文件保存在目录下:以754的权限。目录路径:/usr/lib/systemd/system/ 设置开机自启动 [root@localhost ~]# systemctl enable nginx.service [root@localhost ~]# systemctl enable supervisord 停止开机自启动 [root@localhost ~]# systemctl disable nginx.service [root@localhost ~]# systemctl disable supervisord 验证一下是否为开机启动 [root@localhost ~]# systemctl is-enabled nginx [root@localhost ~]# systemctl is-enabled supervisord 开机自动启动脚本 写脚本放入/etc/profile.d/ Ubuntu引导损坏 引导修复 双系统Ubuntu 引导修复(Boot Repair)_碧海凌云的博客-CSDN博客_ubuntu引导修复 linux 使用rar https://www.rarlab.com/download.htm找到对应linux的压缩包 wget https://www.rarlab.com/rar/rarlinux-x64-6.0.2.tar.gz tar -xvf rarlinux-x64-6.0.2.tar.gz cd rar sudo make # 解压 unrar x xxx.rar # 压缩 ubuntu tar 多线程压缩 安装pigz apt-get install -y pigz 压缩文件夹(默认占用所有cpu核心, 占用率50%-80%) tar --use-compress-program=pigz -h -cvpf [tar file name] [dir] 解压文件夹 tar --use-compress-program=pigz -xvpf [tar file name] -C [dir] 需要限制cpu占用的话 taskset -c [core number start]-[core number end] [command] 向压缩包里追加文件 tar -rvf [tar file name] [file you need to add] 格式化新的磁盘 Installing A New Hard Drive InstallingANewHardDrive Start parted as follows: sudo parted /dev/sdb Create a new GPT disklabel (aka partition table): (parted) mklabel gpt Set the default unit to TB: (parted) unit TB Create one partition occupying all the space on the drive. For a 4TB drive: (parted) mkpart Partition name? []? primary File system type? [ext2]? ext4 Start? 0 End? 4 Check that the results are correct: (parted) print There should be one partition occupying the entire drive. Save and quit “parted”: (parted) quit Command Line Formatting To format the new partition as ext4 file system (best for use under Ubuntu): sudo mkfs -t ext4 /dev/sdb1 To format the new partition as fat32 file system (best for use under Ubuntu & Windows): sudo mkfs -t fat32 /dev/sdb1 As always, substitute “/dev/sdb1” with your own partition’s path. 匹配k380键盘 可能成功 Pairing LOGITECH K380 in Ubuntu 20.04 Arch Linux 开发常用组件安装,遇到gcc之类的基础组件缺失时使用 apt-get install build-essential 向日葵 远程登录失败问题 需要轻量化桌面 sudo apt install lightdm 查看某个文件夹下文件或文件夹的数量(递归) # 查看文件数量 ls -lR | grep "^-" | wc -l # 查看文件夹数量 ls -lR | grep "^d" | wc -l 非root用户cuda安装 安装CUDA和cuDNN到指定目录_kxqt233的博客-CSDN博客_cudnn安装位置 磁盘空间清理 rm -rf ~/.cache/pip conda clean -a htop设置 使用htop命令查看进程的时候可以关闭重复线程方便查看 F2 (Setup) -Display options --Hide userland threads F10 (Done) Ubuntu 隐藏上方状态栏、左边任务栏及菜单按钮移到下方居中及隐藏(详细) Ubuntu 隐藏上方状态栏、左边任务栏及菜单按钮移到下方居中及隐藏(详细)_锵锵锵锵~蒋的博客-CSDN博客_ubuntu隐藏任务栏 ubuntu 20.04 vps 开机自启动 cd /etc/profile.d/ vim xxx.sh chmod a+x xxx.sh zip相关指令 1.1. 查看压缩包内容和统计 zip -sf images.zip | grep -v *.jpg | wc -l zip -sf: 查看zip压缩包内容 grep -v: 去除不需要的行, 筛选需要的文件名 wc -l: 按行统计 1.2. 解压压缩包内部分文件 zip -sf images.zip | head -n 10 # 查看压缩包前10行内容 unzip images.zip "images/00001/000003.jpg" -d . # 解压单个文件到当前文件夹 1.3. 批量压缩文件夹并删除原文件夹 find . -maxdepth 1 -type d ! -name "." -exec sh -c 'zip -r -6 "{}.zip" "{}" && rm -r "{}"' \; ...

2021年8月1日 · 8 分钟 · sun510001