本文共 1485 字,大约阅读时间需要 4 分钟。
Linux系统提供了丰富的Shell命令,能够帮助用户完成多种系统管理和数据处理任务。本文将介绍一些常用的Linux Shell命令,涵盖文件管理、用户权限、压缩解压、磁盘管理、网络操作等方面。
使用find
命令可以递归搜索当前目录及其子目录下的文件。例如:
find /path/to/directory/ -name "*pattern*" -type f
-r
:递归搜索子目录。-name "pattern"
:匹配文件名。-type f
:只匹配文件。可以参考以下命令手册:
ls -lh
chmod ugo+rwx file
chmod go-rwx directory
chown user:group file
tar
和gzip
):tar -czvf filename.tar.gz file
tar -xzvf filename.tar.gz file
rsync
同步文件:rsync -avP /source/path /destination/path
du -sh directory
useradd username
userdel -r username
usermod -c "Comment" username
groupadd groupname
groupdel groupname
groupmod -n newname oldname
cat /etc/passwd
cat /etc/group
mount /dev/sda1 /mnt/usb
umount /mnt/usb
df -h
du -sh /mnt/data
rsync
同步文件:rsync -avP /source/path/ 192.168.1.1:/destination/path/
ifconfig
ping 192.168.1.1
netstat -tuln
iptables -D INPUT -p tcp --dport 80
sed
和awk
sed -e 's/string1/string2/g' file
sed -e '/^$/d' file
sed -n '/^string/p' file
cat file1 file2 > merged_file
split -a line_number file
shutdown -h now
reboot
logout
date
date -u 2023-12-31
zip -r filename.zip directory
unzip filename.zip
通过这些命令,用户可以高效地完成日常的系统管理和数据处理任务。
转载地址:http://djrg.baihongyu.com/