Summary of common commands in Dos and linux (details)

Table of contents

Table of contents

foreword

Note content mind map 

1. Win command to operate the computer

1.1 Example of command operation

Command 1, get the ip address:

 Command 2, get the current user:

 Command 3, enter the D drive and create a txt file

 Command 4, delete file

1.2. Common Dos commands

1.2.1# System information

1.2.2# Network

1.2.3#User

1.2.4#Port process service

1.2.5#Sharing

1.2.6#File operation

2, Linux commands to operate the computer (kali)

2.1, command operation example

2.1.1, switch to root user

2.1.2, check the ip address

2.1.3, view the current directory

2.1.4, create a folder

2.1.5, create file

2.2, common linux commands

important:

2.2.1, system information

2.2.2, files and directories

2.2.3, file search

2.2.4, mount a file system

2.2.5, disk space

2.2.6, users and groups

2.2.7, file permissions

2.2.8, special properties of files

2.2.9, Packing and compressing files

2.2.10, view file content

2.2.11, text processing

2.2.12, character setting and file format conversion

2.2.13, file system analysis

2.2.14, Initialize a file system

2.2.15, SWAP file system

2.2.16, backup

2.2.17 CD

2.2.18 Network - (Ethernet and WIFI wireless)

3. Summary


foreword

personal information

Sophomore in soft engineering

an ordinary undergraduate student

Passionate about cybersecurity and programming

Currently undergoing cybersecurity training

Looking for like-minded friends to learn and improve together! ! !

Today is the study notes of the 12 preview lessons, and I will summarize them.

Note content mind map 

1. Win command to operate the computer

First enter the command window through win+r and then enter cmd:

1.1 Example of command operation

Command 1, get the ip address:

                                               Enter ipconfig directly

 Command 2, get the current user:

                                                           Type whoami directly

 Command 3, enter the D drive and create a txt file

                      First enter D: and then enter echo ( printed in php ) + content to be stored +> + file name

 

                           At this time, a folder will appear on the D drive, which is the input content.

                       If you want to add information, you only need to add one more > on the basis of the above command

 

 Command 4, delete file

                                     Use del + file name, of course under the corresponding disk

 Here we delete the text file we just created

1.2. Common Dos commands

1.2.1# System information

CHCP 65001                              修改字体编码为UTF-8
    systeminfo                           查看系统信息
    hostname                             查看主机名
    SET                                  查看环境变量
    color                                改变cmd颜色
    cls                                  清除屏幕
    runas /user:administrator cmd        切换管理员

1.2.2# Network

ipconfig /all                        显示完整网络信息
    ping -t  -l  65500  ip               死亡之ping
    ipconfig    /release                 释放ip
    ipconfig    /renew                   重新获得ip
    ipconfig    /flushdns                刷新DNS缓存
    ipconfig   /displaydns               显示DNS解析程序缓存的内容
    route print                          打印路由信息
    arp -a                               查看arp缓存
    net view                             查看局域网内其他计算机名称
    netsh firewall show state            防火墙状态
    netsh firewall show config           防火墙规则

1.2.3#User

 net config workstation                查看当前登陆用户
    whoami                                查看我是哪个用户
    net user                              查看有哪些用户
    net user supermage                    查看用户supermage的信息
    net localgroup                        查看组
    net localgroup administrators         查看组administrators的信息
    net user  hack   123  /add            新建一个用户hack,密码为123
    net user  hack$  123  /add            新建一个隐藏hack用户,密码为123
    net user  hack   /del                 删除用户hack
    net localgroup  administrators  hack  /add   将普通用户hack提权到管理员
    net user  guest  /active:yes          激活guest用户
    net user  guest  /active:no           关闭guest用户
    net password   密码                   更改系统当前登录用户密码
    net user guest 密码                   更改guest用户密码

1.2.4#Port process service

 tasklist                             查看进程
    tasklist  /svc                       查看进程,显示进程使用者名称
    netstat  -ano                        查看系统开放端口
    netstat  -ano|findstr 80             查看80端口对应的PID
    tasklist | findstr 80                查看80端口对应的进程
    taskkill /f /t /im xx.exe            杀死xx.exe进程
    taskkill /F -pid 520                 杀死pid为520的进程
    net start                            查看开启了哪些服务
    net start telnet                     开启telnet服务
    net stop  telnet                     停止 telnet服务
    start   www.baidu.com                打开网址

1.2.5#Sharing

 net use                               查看连接
    net share                             查看本地开启的共享
    net share ipc$                        开启ipc$共享
    net share ipc$ /del                   删除ipc$共享
    net share c$ /del                     删除C盘共享
    net use \\192.168.10.15\ipc$ /u:"" ""     与192.168.10.15建立ipc空连接
    net use \\192.168.10.15      /u:"" ""     与192.168.10.15建立ipc空连接,可以吧ipc$去掉
    net use \\192.168.10.15 /u:"administrator" "root"   以administrator身份与192.168.10.15建立ipc连接
    net use \\192.168.10.15 /del              删除ipc连接
    net use \\192.168.10.15\c$  /u:"administrator" "root"    建立C盘共享
    dir \\192.168.10.15\c$                  查看192.168.10.15C盘文件
    dir \\192.168.10.15\c$\user             查看192.168.10.15C盘文件下的user目录
    dir \\192.168.10.15\c$\user\test.exe    查看192.168.10.15C盘文件下的user目录下的test.exe文件
    net use \\192.168.10.15\c$  /del        删除该C盘共享连接
    net use k: \\192.168.10.15\c$  /u:"administrator" "root"    将目标C盘映射到本地K盘
    net use k: /del                                             删除该映射

1.2.6#File operation

  echo  hello,word > 1.txt              向1.txt中写入 hello,word
    echo  hello,word >>1.txt              向1.txt中追加 hello,word
    del                                   删除一个文件
    deltree                               删除文件夹和它下面的所有子文件夹还有文件
    ren 1.txt  2.txt                      将 1.txt 重命名为 2.txt
    type  1.txt                           查看1.txt文件的内容
    md                                    创建一个文件夹
    rd                                    删除一个文件夹
    move  1.txt  d:/                      将1.txt文件移动到d盘下
   123.txt  edit                          打开123.txt文件(可编辑)
    dir c:\                               查看C盘下的文件
    dir c:\ /A                            查看C盘下的所有文件,包括隐藏文件
    dir c:\ /S                            查看C盘下和其子文件夹下的文件
    dir c:\ /B                            只显示C盘下的文件名
    shutdown -s -t 60 -c  “你的电脑被黑了”  -s关机 -r重启 -a取消

2, Linux commands to operate the computer (kali)

Click directly on the command terminal to enter

2.1, command operation example

2.1.1, switch to root user

Enter sudo su and then enter the password kali. At this time, you cannot see the password display. It is a unique mechanism of kali. Just enter it and press Enter to be ok.

 

2.1.2, check the ip address

         Enter ifconfig, and find the local ip behind inet       

2.1.3, view the current directory

                                                        Enter pwd directly

 

2.1.4, create a folder

           Directly enter mkdir+ folder name , then enter ls to list all file names in the current directory, and find txt

2.1.5, create file

                                                    touch + file name

2.2, common linux commands

important:

Command format: command-option parameters
such as: Is -la/usr
Is: display file and directory list (list)
common parameters:
-1 (long)
-a (all) pay attention to hidden files, special directories. and.
-t (time )

2.2.1, system information

arch                                   #显示机器的处理器架构(1)
uname -m                         #显示机器的处理器架构(2)
uname -r                           #显示正在使用的内核版本
dmidecode -q                   #显示硬件系统部件 - (SMBIOS / DMI)
hdparm -i /dev/hda          #罗列一个磁盘的架构特性
hdparm -tT /dev/sda        #在磁盘上执行测试性读取操作
cat /proc/cpuinfo             #显示CPU info的信息
cat /proc/interrupts         #显示中断
cat /proc/meminfo          #校验内存使用
cat /proc/swaps               #显示哪些swap被使用
cat /proc/version            #显示内核的版本
cat /proc/net/dev           #显示网络适配器及统计
cat /proc/mounts            #显示已加载的文件系统
lspci -tv   #罗列PCI设备
lsusb -tv   #显示USB设备
date 显示系统日期
cal 2007                          #显示2007年的日历表
date 041217002007.00   #设置日期和时间 - 月日时分年.秒
clock -w                           #将时间修改保存到 BIOS
关机 (系统的关机、重启以及登出 )
shutdown -h now    #关闭系统(1)
init 0                       #关闭系统(2)
telinit 0                   #关闭系统(3)
shutdown -h hours:minutes &   #按预定时间关闭系统
shutdown -c         #取消按预定时间关闭系统
shutdown -r now    #重启(1)
reboot     #重启(2)
logout        #注销

2.2.2, files and directories

cd /home    #进入 '/ home' 目录'
cd ..       #返回上一级目录
cd ../..    #返回上两级目录
cd          #进入个人的主目录
cd ~user1   #进入个人的主目录
cd -       #返回上次所在的目录
pwd        #显示工作路径

ls      #查看目录中的文件
ls -F   #查看目录中的文件
ls -l   #显示文件和目录的详细资料
ls -a   #显示隐藏文件
ls *[0-9]*   #显示包含数字的文件名和目录名
tree         #显示文件和目录由根目录开始的树形结构(1)
lstree       #显示文件和目录由根目录开始的树形结构(2)

mkdir dir1         #创建一个叫做 'dir1' 的目录'
mkdir dir1 dir2    #同时创建两个目录
mkdir -p /tmp/dir1/dir2   #创建一个目录树
rm -f file1    #删除一个叫做 'file1' 的文件'
rmdir dir1     #删除一个叫做 'dir1' 的目录'
rm -rf dir1    #删除一个叫做 'dir1' 的目录并同时删除其内容
rm -rf dir1 dir2    #同时删除两个目录及它们的内容
mv dir1 new_dir     #重命名/移动 一个目录

cp file1 file2     #复制一个文件
cp dir/* .         #复制一个目录下的所有文件到当前工作目录
cp -a /tmp/dir1 .   #复制一个目录到当前工作目录
cp -a dir1 dir2     #复制一个目录

ln -s file1 lnk1  #创建一个指向文件或目录的软链接
ln file1 lnk1     #创建一个指向文件或目录的物理链接

touch -t 0712250000 file1   #修改一个文件或目录的时间戳 - (YYMMDDhhmm)
file file1 outputs the mime type of the file as text
iconv -l   #列出已知的编码

iconv -f fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.

find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)

2.2.3, file search

find / -name file1     #从 '/' 开始进入根文件系统搜索文件和目录
find / -user user1     #搜索属于用户 'user1' 的文件和目录
find /home/user1 -name \*.bin        #在目录 '/ home/user1' 中搜索带有'.bin' 结尾的文件
find /usr/bin -type f -atime +100    #搜索在过去100天内未被使用过的执行文件
find /usr/bin -type f -mtime -10     #搜索在10天内被创建或者修改过的文件
find / -name \*.rpm -exec chmod 755 '{}' \;      #搜索以 '.rpm' 结尾的文件并定义其权限
find / -xdev -name \*.rpm        #搜索以 '.rpm' 结尾的文件,忽略光驱、捷盘等可移动设备
locate \*.ps       #寻找以 '.ps' 结尾的文件 - 先运行 'updatedb' 命令
whereis halt       #显示一个二进制文件、源码或man的位置
which halt         #显示一个二进制文件或可执行文件的完整路径

2.2.4, mount a file system

mount /dev/hda2 /mnt/hda2    #挂载一个叫做hda2的盘 - 确定目录 '/ mnt/hda2' 已经存在
umount /dev/hda2            #卸载一个叫做hda2的盘 - 先从挂载点 '/ mnt/hda2' 退出
fuser -km /mnt/hda2         #当设备繁忙时强制卸载
umount -n /mnt/hda2         #运行卸载操作而不写入 /etc/mtab 文件- 当文件为只读或当磁盘写满时非常有用
mount /dev/fd0 /mnt/floppy        #挂载一个软盘
mount /dev/cdrom /mnt/cdrom       #挂载一个cdrom或dvdrom
mount /dev/hdc /mnt/cdrecorder    #挂载一个cdrw或dvdrom
mount /dev/hdb /mnt/cdrecorder    #挂载一个cdrw或dvdrom
mount -o loop file.iso /mnt/cdrom    #挂载一个文件或ISO镜像文件
mount -t vfat /dev/hda5 /mnt/hda5    #挂载一个Windows FAT32文件系统
mount /dev/sda1 /mnt/usbdisk         #挂载一个usb 捷盘或闪存设备
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share      #挂载一个windows网络共享

2.2.5, disk space

df -h           #显示已经挂载的分区列表
ls -lSr |more    #以尺寸大小排列文件和目录
du -sh dir1      #估算目录 'dir1' 已经使用的磁盘空间'
du -sk * | sort -rn     #以容量大小为依据依次显示文件和目录的大小
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n 
#以大小为依据依次显示已安装的rpm包所使用的空间 (fedora, redhat类系统)
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n 
#以大小为依据显示已安装的deb包所使用的空间 (ubuntu, debian类系统)

2.2.6, users and groups

groupadd group_name   #创建一个新用户组
groupdel group_name   #删除一个用户组
groupmod -n new_group_name old_group_name   #重命名一个用户组
useradd -c "Name Surname " -g admin -d /home/user1 -s /bin/bash user1     #创建一个属于 "admin" 用户组的用户
useradd user1      #创建一个新用户
userdel -r user1   #删除一个用户 ( '-r' 排除主目录)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1   #修改用户属性

passwd         #修改口令
passwd user1   #修改一个用户的口令 (只允许root执行)
chage -E 2005-12-31 user1    #设置用户口令的失效期限
pwck     #检查 '/etc/passwd' 的文件格式和语法修正以及存在的用户
grpck    #检查 '/etc/passwd' 的文件格式和语法修正以及存在的群组
newgrp group_name     #登陆进一个新的群组以改变新创建文件的预设群组

2.2.7, file permissions

使用 "+" 设置权限,使用 "-" 用于取消

ls -lh    #显示权限
ls /tmp | pr -T5 -W$COLUMNS   #将终端划分成5栏显示
chmod ugo+rwx directory1      #设置目录的所有人(u)、群组(g)以及其他人(o)以读(r )、写(w)和执行(x)的权限
chmod go-rwx directory1      #删除群组(g)与其他人(o)对目录的读写执行权限
chown user1 file1            #改变一个文件的所有人属性
chown -R user1 directory1    #改变一个目录的所有人属性并同时改变改目录下所有文件的属性
chgrp group1 file1          #改变文件的群组
chown user1:group1 file1     #改变一个文件的所有人和群组属性
find / -perm -u+s           #罗列一个系统中所有使用了SUID控制的文件
chmod u+s /bin/file1        #设置一个二进制文件的 SUID 位 - 运行该文件的用户也被赋予和所有者同样的权限
chmod u-s /bin/file1        #禁用一个二进制文件的 SUID位
chmod g+s /home/public      #设置一个目录的SGID 位 - 类似SUID ,不过这是针对目录的
chmod g-s /home/public      #禁用一个目录的 SGID 位
chmod o+t /home/public      #设置一个文件的 STIKY 位 - 只允许合法所有人删除文件
chmod o-t /home/public      #禁用一个目录的 STIKY 位

2.2.8, special properties of files

- 使用 "+" 设置权限,使用 "-" 用于取消

chattr +a file1   #只允许以追加方式读写文件
chattr +c file1   #允许这个文件能被内核自动压缩/解压
chattr +d file1   #在进行文件系统备份时,dump程序将忽略这个文件
chattr +i file1   #设置成不可变的文件,不能被删除、修改、重命名或者链接
chattr +s file1   #允许一个文件被安全地删除
chattr +S file1   #一旦应用程序对这个文件执行了写操作,使系统立刻把修改的结果写到磁盘
chattr +u file1   #若文件被删除,系统会允许你在以后恢复这个被删除的文件
lsattr           #显示特殊的属性

2.2.9, Packing and compressing files

bunzip2 file1.bz2   #解压一个叫做 'file1.bz2'的文件
bzip2 file1         #压缩一个叫做 'file1' 的文件
gunzip file1.gz     #解压一个叫做 'file1.gz'的文件
gzip file1          #压缩一个叫做 'file1'的文件
gzip -9 file1       #最大程度压缩

rar a file1.rar test_file          #创建一个叫做 'file1.rar' 的包
rar a file1.rar file1 file2 dir1   #同时压缩 'file1', 'file2' 以及目录 'dir1'
rar x file1.rar     #解压rar包
unrar x file1.rar   #解压rar包

tar -cvf archive.tar file1   #创建一个非压缩的 tarball
tar -cvf archive.tar file1 file2 dir1  #创建一个包含了 'file1', 'file2' 以及 'dir1'的档案文件
tar -tf archive.tar    #显示一个包中的内容
tar -xvf archive.tar   #释放一个包
tar -xvf archive.tar -C /tmp     #将压缩包释放到 /tmp目录下
tar -cvfj archive.tar.bz2 dir1   #创建一个bzip2格式的压缩包
tar -jxvf archive.tar.bz2        #解压一个bzip2格式的压缩包
tar -cvfz archive.tar.gz dir1    #创建一个gzip格式的压缩包
tar -zxvf archive.tar.gz         #解压一个gzip格式的压缩包

zip file1.zip file1    #创建一个zip格式的压缩包
zip -r file1.zip file1 file2 dir1    #将几个文件和目录同时压缩成一个zip格式的压缩包
unzip file1.zip    #解压一个zip格式压缩包

2.2.10, view file content

cat file1      #从第一个字节开始正向查看文件的内容
tac file1      #从最后一行开始反向查看一个文件的内容
more file1     #查看一个长文件的内容
less file1     #类似于 'more' 命令,但是它允许在文件中和正向操作一样的反向操作
head -2 file1    #查看一个文件的前两行
tail -2 file1    #查看一个文件的最后两行
tail -f /var/log/messages     #实时查看被添加到一个文件中的内容

2.2.11, text processing

cat file1 file2 ... | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT

cat file1 | command( sed, grep, awk, grep, etc...) > result.txt 
#合并一个文件的详细说明文本,并将简介写入一个新文件中
cat file1 | command( sed, grep, awk, grep, etc...) >> result.txt 
#合并一个文件的详细说明文本,并将简介写入一个已有的文件中

grep Aug /var/log/messages     #在文件 '/var/log/messages'中查找关键词"Aug"
grep ^Aug /var/log/messages    #在文件 '/var/log/messages'中查找以"Aug"开始的词汇
grep [0-9] /var/log/messages   #选择 '/var/log/messages' 文件中所有包含数字的行
grep Aug -R /var/log/*         #在目录 '/var/log' 及随后的目录中搜索字符串"Aug"

sed 's/stringa1/stringa2/g' example.txt 
#将example.txt文件中的 "string1" 替换成 "string2"
sed '/^$/d' example.txt           #从example.txt文件中删除所有空白行
sed '/ *#/d; /^$/d' example.txt   #从example.txt文件中删除所有注释和空白行
echo 'esempio' | tr '[:lower:]' '[:upper:]'    #合并上下单元格内容
sed -e '1d' result.txt          #从文件example.txt 中排除第一行
sed -n '/stringa1/p'            #查看只包含词汇 "string1"的行
sed -e 's/ *$//' example.txt    #删除每一行最后的空白字符
sed -e 's/stringa1//g' example.txt  
#从文档中只删除词汇 "string1" 并保留剩余全部
sed -n '1,5p;5q' example.txt     #查看从第一行到第5行内容
sed -n '5p;5q' example.txt       #查看第5行
sed -e 's/00*/0/g' example.txt   #用单个零替换多个零

cat -n file1       #标示文件的行数
cat example.txt | awk 'NR%2==1'      #删除example.txt文件中的所有偶数行
echo a b c | awk '{print $1}'        #查看一行第一栏
echo a b c | awk '{print $1,$3}'     #查看一行的第一和第三栏
paste file1 file2           #合并两个文件或两栏的内容
paste -d '+' file1 file2    #合并两个文件或两栏的内容,中间用"+"区分

sort file1 file2              #排序两个文件的内容
sort file1 file2 | uniq       #取出两个文件的并集(重复的行只保留一份)
sort file1 file2 | uniq -u    #删除交集,留下其他的行
sort file1 file2 | uniq -d    #取出两个文件的交集(只留下同时存在于两个文件中的文件)

comm -1 file1 file2    #比较两个文件的内容只删除 'file1' 所包含的内容
comm -2 file1 file2    #比较两个文件的内容只删除 'file2' 所包含的内容
comm -3 file1 file2    #比较两个文件的内容只删除两个文件共有的部分

2.2.12, character setting and file format conversion

dos2unix filedos.txt fileunix.txt      #将一个文本文件的格式从MSDOS转换成UNIX
unix2dos fileunix.txt filedos.txt      #将一个文本文件的格式从UNIX转换成MSDOS
recode ..HTML < page.txt > page.html   #将一个文本文件转换成html
recode -l | more                       #显示所有允许的转换格式

2.2.13, file system analysis

badblocks -v /dev/hda1    #检查磁盘hda1上的坏磁块
fsck /dev/hda1            #修复/检查hda1磁盘上linux文件系统的完整性
fsck.ext2 /dev/hda1       #修复/检查hda1磁盘上ext2文件系统的完整性
e2fsck /dev/hda1          #修复/检查hda1磁盘上ext2文件系统的完整性
e2fsck -j /dev/hda1       #修复/检查hda1磁盘上ext3文件系统的完整性
fsck.ext3 /dev/hda1       #修复/检查hda1磁盘上ext3文件系统的完整性
fsck.vfat /dev/hda1       #修复/检查hda1磁盘上fat文件系统的完整性
fsck.msdos /dev/hda1      #修复/检查hda1磁盘上dos文件系统的完整性
dosfsck /dev/hda1         #修复/检查hda1磁盘上dos文件系统的完整性

2.2.14, Initialize a file system

mkfs /dev/hda1        #在hda1分区创建一个文件系统
mke2fs /dev/hda1      #在hda1分区创建一个linux ext2的文件系统
mke2fs -j /dev/hda1   #在hda1分区创建一个linux ext3(日志型)的文件系统
mkfs -t vfat 32 -F /dev/hda1   #创建一个 FAT32 文件系统
fdformat -n /dev/fd0           #格式化一个软盘
mkswap /dev/hda3               #创建一个swap文件系统

2.2.15, SWAP file system

mkswap /dev/hda3             #创建一个swap文件系统
swapon /dev/hda3             #启用一个新的swap文件系统
swapon /dev/hda2 /dev/hdb3   #启用两个swap分区

2.2.16, backup

dump -0aj -f /tmp/home0.bak /home    #制作一个 '/home' 目录的完整备份
dump -1aj -f /tmp/home0.bak /home    #制作一个 '/home' 目录的交互式备份
restore -if /tmp/home0.bak          #还原一个交互式备份

rsync -rogpav --delete /home /tmp    #同步两边的目录
rsync -rogpav -e ssh --delete /home ip_address:/tmp           #通过SSH通道rsync
rsync -az -e ssh --delete ip_addr:/home/public /home/local    #通过ssh和压缩将一个远程目录同步到本地目录
rsync -az -e ssh --delete /home/local ip_addr:/home/public    #通过ssh和压缩将本地目录同步到远程目录

dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz'  
#通过ssh在远程主机上执行一次备份本地磁盘的操作
dd if=/dev/sda of=/tmp/file1 
#备份磁盘内容到一个文件
tar -Puf backup.tar /home/user 执行一次对 '/home/user' 
#目录的交互式备份操作
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' 
#通过ssh在远程目录中复制一个目录内容
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' 
#通过ssh在远程目录中复制一个本地目录
tar cf - . | (cd /tmp/backup ; tar xf - ) 
#本地将一个目录复制到另一个地方,保留原有权限及链接

find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents 
#从一个目录查找并复制所有以 '.txt' 结尾的文件到另一个目录
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 
#查找所有以 '.log' 结尾的文件并做成一个bzip包

dd if=/dev/hda of=/dev/fd0 bs=512 count=1 
#做一个将 MBR (Master Boot Record)内容复制到软盘的动作
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 
#从已经保存到软盘的备份中恢复MBR内容

2.2.17 CD

cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force 
#清空一个可复写的光盘内容

mkisofs /dev/cdrom > cd.iso             #在磁盘上创建一个光盘的iso镜像文件
mkisofs /dev/cdrom | gzip > cd_iso.gz    #在磁盘上创建一个压缩了的光盘iso镜像文件
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd 

#创建一个目录的iso镜像文件
cdrecord -v dev=/dev/cdrom cd.iso               #刻录一个ISO镜像文件
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom -  #刻录一个压缩了的ISO镜像文件
mount -o loop cd.iso /mnt/iso                  #挂载一个ISO镜像文件

cd-paranoia -B             #从一个CD光盘转录音轨到 wav 文件中
cd-paranoia -- "-3"        #从一个CD光盘转录音轨到 wav 文件中(参数-3)
cdrecord --scanbus         #扫描总线以识别scsi通道
dd if=/dev/hdc | md5sum    #校验一个设备的md5sum编码,例如一张 CD

2.2.18 Network - (Ethernet and WIFI wireless)

ifconfig eth0    #显示一个以太网卡的配置
ifup eth0        #启用一个 'eth0' 网络设备
ifdown eth0      #禁用一个 'eth0' 网络设备
ifconfig eth0 192.168.1.1 netmask 255.255.255.0     #控制IP地址
ifconfig eth0 promisc     #设置 'eth0' 成混杂模式以嗅探数据包 (sniffing)
dhclient eth0            #以dhcp模式启用 'eth0'

route -n    #查看路由表
route add -net 0/0 gw IP_Gateway    #配置默认网关
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 
#配置静态路由到达网络'192.168.0.0/16'
route del 0/0 gw IP_gateway        #删除静态路由

hostname #查看机器名
host www.example.com       #把一个主机名解析到一个网际地址或把一个网际地址解析到一个主机名。
nslookup www.example.com   #用于查询DNS的记录,查看域名解析是否正常,在网络故障的时候用来诊断网络问题。
ip link show            #查看网卡信息
mii-tool                #用于查看、管理介质的网络接口的状态
ethtool                 #用于查询和设置网卡配置
netstat -tupl           #用于显示TCP/UDP的状态信息
tcpdump tcp port 80     #显示所有http协议的流量

3. Summary

Today I learned to use commands to operate win and kali. Although I have operated it before, I didn’t use commands to do many things like today. It seems to be a common and convenient operation, but using commands is faster and more convenient. Use alternative operations to use The operating system is really becoming more and more like a hacker.

Word of the day:

But I didn't understand then, that sooner or later I might have to hurt someone, leave her with a wound that couldn't heal. In some cases, the very existence of one person hurts another.

If my study notes are useful to you, you may wish to like and save them. Thank you for your support. Of course, you are also welcome to give me suggestions or supplement the deficiencies in the notes. It will be of great help to my study, thank you.  

Guess you like

Origin blog.csdn.net/weixin_72543266/article/details/132482426