1、hexdump
命令简介:hexdump是Linux下的一个二进制文件查看工具,它可以将二进制文件转换为ASCII、八进制、十进制、十六进制格式进行查看。
命令语法:hexdump: [-bcCdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]
命令参数:此命令参数是Red Hat Enterprise Linux Server release 5.7下hexdump命令参数,不同版本Linux的hexdump命令参数有可能不同。
学习参考:https://www.cnblogs.com/kerrycode/p/5077687.html
2、ag
安装:sudo apt-get install silversearcher-ag
命令简介:在文件里搜索特定的文本
命令语法:ag [options] PATTERN [PATH]
命令参数:man ag
学习参考:https://www.cnblogs.com/GMCisMarkdownCraftsman/p/3795315.html
参考:http://man.linuxde.net/
http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html
3、scp
命令简介:linux 的 scp 命令 可以 在 linux 之间复制 文件 和 目录;
命令格式: scp [可选参数] file_source file_target
命令参数:man scp
从 本地 复制到 远程
复制文件:scp local_file remote_username@remote_ip:remote_file
scp /home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music
复制目录:scp -r local_folder remote_username@remote_ip:remote_folder
scp -r /home/space/music/ root@www.cumt.edu.cn:/home/root/others/
从 远程 复制到 本地
从 远程 复制到 本地,只要将 从 本地 复制到 远程 的命令 的 后2个参数 调换顺序 即可;
scp root@www.cumt.edu.cn:/home/root/others/music /home/space/music/1.mp3
scp -r www.cumt.edu.cn:/home/root/others/ /home/space/music/
#!/bin/bash ty=$
local_dir=$
remote_ip=$
remote_dir=$ showUsage() {
echo -e "\033[31m ty local_dir remote_ip remote_dir \033[0m"
echo -e "\033[32m ty = l(local to remote); ty = r(remote to local) \033[0m"
echo -e "\033[32m local_dir = local file or local dir \033[0m"
echo -e "\033[32m remote_dir = remote file or remote dir \033[0m"
} #Copy the local file to the remote server
l_to_r() {
expect -c "
spawn scp -r ${local_dir} root@${remote_ip}:${remote_dir}
expect {
\"*password\" {set timeout 300; send \"passwd\r\";}
#设置超时时间,和输入passwd
} expect eof"
} #Copy the remote file to the local server
r_to_l() {
expect -c "
spawn scp -r root@${remote_ip}:${remote_dir} ${local_dir}
expect {
\"*password\" {set timeout 300; send \"passwd\r\";}
} expect eof"
} case $ in
"l")
l_to_r
;;
"r")
r_to_l
;;
*)
showUsage
;;
esac
学习参考:https://www.cnblogs.com/hitwtx/archive/2011/11/16/2251254.html
4、tee
Linux tee命令用于读取标准输入的数据,并将其内容输出成文件。
tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。
语法:tee [-ai][--help][--version][文件...]
参数:a或--append 附加到既有文件的后面,而非覆盖它;-i或--ignore-interrupts 忽略中断信号;
eg:ls | tee ./test.txt
5、iperf
命令简介:iperf命令是一个网络性能测试工具。iperf可以测试TCP和UDP带宽质量。iperf可以测量最大TCP带宽,具有多种参数和UDP特性。iperf可以报告带 宽,延迟抖动和数据包丢失。利用iperf这一特性,可以用来测试一些网络设备如路由器,防火墙,交换机等的性能。
用法:
device:
iperf -s
pc:
iperf -c deviceIp -t 120 -i 10
参考:http://blog.****.net/hankerzero/article/details/55093915
6、export
Linux设置/删除环境变量方法:
bash下
设置:export 变量名=变量值
删除:unset 变量名
7、date
8、sort
9、head
10、tail
11、expect
expect是用于提供自动交互的工具
不同系统安装方法不一样
ubuntu:sudo
apt-get
install
expect
#!/usr/bin/expect
#set timeout 20 #设置超时时间
spawn ssh root@192.168.43.131
expect "*password:"
send "123\r"
# expect "*#"
interact
1、#!/usr/bin/expect :需要先安装软件,然后来说明用expect来执行
2、spawn ssh root@192.168.43.131 :spawn是进入expect环境后才可以执行的expect内部命令,用来执行它后面的命令。
3、expect "*password:" :也是expect的内部命令,用来解惑关键的字符串,如果有,就会立即返回下面设置的内容,如果没有就看是否设置了超时时间。
4、send "123\r":这时执行交互式动作,与手工输入密码等效,在expect截获关键字之后,它就会输入send后面的内容。
5、interact :执行完毕后把持交互状态,把控制台,这时候就可以进行你想要进行的操作了。如果没有这一句,在登陆完成之后就会退出,而不是留在远程终端上。
摘抄自:https://www.cnblogs.com/yangmingxianshen/p/7967040.html
12、dd
dd if=/dev/urandom of=rnd_data bs=1024 count=32768000
sudo dd if=rnd_data of=/dev/sdc bs=1024 count=32768000
sudo dd if=/dev/sdc of=rnd_read bs=1024 count=32768000
注:随机产生非0的数据,保存到文件rnd_data,每次1k,共32G
参考:https://www.cnblogs.com/jikexianfeng/p/6103500.html
https://blog.****.net/cupidove/article/details/41379047
13、sed
去除文件中单引号
sed -e $'s/\'//g' ./FileName
14、ldd
ldd本身不是一个程序,而仅是一个shell脚本:ldd可以列出一个程序所需要得动态链接库
格式:ldd [options] file
功能:列出file运行所需的共享库
参数:
-d 执行重定位并报告所有丢失的函数
-r 执行对函数和对象的重定位并报告丢失的任何函数或对象
示例:
xiaomanon@xiaomanon-machine:~/Documents/c_code$ ldd tooltest
linux-gate.so.1 => (0xb775b000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7595000)
/lib/ld-linux.so.2 (0xb775c000)
我们可以将ldd的输出结果分为3列来看:
■ 第一列:程序需要依赖什么库
■ 第二列:系统提供的与程序需要的库对应的库名称
■ 第三列:依赖库加载的开始地址
通过上面的这些信息,我们可以总结出下面的用途:
(1) 通过对比第一列和第二列,我们可以知道程序需要的动态链接库和系统实际提供的是否相比配。
(2) 通过第三列,我们可以知道当前动态链接库中的符号在进程地址空间中的起始位置。
15、nm
就是可以帮你列举出该目标中定义的符合要求的符号。要求可以很多,主要通过参数实现:外部引入的、内部定义的、动态的... 也可以添加参数使nm同时打印行号、文件名等相关信息
格式:nm [options] file
功能:列出file中的所有符号
参数:
-C 将符号转化为用户级的名字
-s 当用于.a文件即静态库时,输出把符号名映射到定义该符号的模块或成员名的索引
-u 显示在file外定义的符号或没有定义的符号
-l 显示每个符号的行号,或为定义符号的重定义项
linux 命令学习参考:http://www.runoob.com/linux/linux-comm-tee.html