Linux shell常用功能示例
1.统计代码行数
find ./ -name "*.c" -o -name "*.h"| xargs cat | grep -vc ^$
2.查看文件个数
可以使用tree命令
dhl@dhl:~$ tree
.
├── bitree.c
├── linkhash.c
├── linklist.c
├── linkqueue.c
├── linkstack.c
├── Makefile
├── sqlist.c
├── sqqueue.c
└── sqstack.c
1 directory, 9 files
3.Ubuntu下载应用源码
apt source <appName>
dhl@dhl:~/openvpn$ apt source openvpn
正在读取软件包列表... 完成
提示:openvpn 的打包工作被维护于以下位置的 Git 版本控制系统中:
https://salsa.debian.org/debian/openvpn.git
请使用:
git clone https://salsa.debian.org/debian/openvpn.git
获得该软件包的最近更新(可能尚未正式发布)。
需要下载 1,994 kB 的源代码包。
获取:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main openvpn 2.6.14-0ubuntu0.24.04.1 (dsc) [2,366 B]
获取:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main openvpn 2.6.14-0ubuntu0.24.04.1 (tar) [1,926 kB]
获取:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main openvpn 2.6.14-0ubuntu0.24.04.1 (diff) [65.3 kB]
已下载 1,994 kB,耗时 2秒 (1,188 kB/s)
dpkg-source: info: extracting openvpn in openvpn-2.6.14
dpkg-source: info: unpacking openvpn_2.6.14.orig.tar.gz
dpkg-source: info: unpacking openvpn_2.6.14-0ubuntu0.24.04.1.debian.tar.xz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying move_log_dir.patch
dpkg-source: info: applying auth-pam_libpam_so_filename.patch
dpkg-source: info: applying openvpn-pkcs11warn.patch
4.Ubuntu 查看系统信息
本人使用的系统环境Ubuntu 24.04.2,内核版本6.11.0,默认登录shell为bash,使用命令查看过程如下:
dhl@dhl:~$ cat /etc/issue
Ubuntu 24.04.2 LTS \n \l
dhl@dhl:~$ uname -a
Linux dhl 6.11.0-26-generic #26~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 17 19:20:47 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
dhl@dhl:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
dhl@dhl:~$ echo $SHELL
/bin/bash
dhl@dhl:~$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/usr/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/usr/bin/dash

浙公网安备 33010602011771号