别名
1 设置别名
alias www='ls /' 只在当前bashshell中生效
2 永久生效 写到配置文件中
echo "alias wk='ifconfig'" >> /etc/bashrc
3 unalias wk 取消当前bashshell生效,但不影响配置文件,重开窗口仍然有效。
如果写到配置文件中,取消,unalias wk+去配置文件删除
5 内置的别名:在配置文件中
alias ls
6 /bin/ls -al /root
直接执行命令文件
7 命令 --help
8 man 命令
查看文件占用空间
df -h
du -sh /usr/
查看用户登录记录
cat /var/log/secure
路径定位
1 . .. 相对路径,. 是当前,..是上一级
2 坑:带斜杠和不带斜杠
cd /usr
cd usr
3 执行当前路径下的某个文件(可执行文件xx)
./xx linux
xx windows
mkdir touch rm mv cp
mkdir dir1
mkdir /home/od/dir1 /home/od/dir2
mkdir -v /home/od/{dir3,dir4}
mkdir -pv /home/od/dir5/dir6
mkdir -pv /home/{od/{diu,but},boy}
touch file
touch file2 file3
touch /home/od/file4 file5
touch file{a,b,c}
touch file{1..10}
touch file{a..z}
rm -r dir/
rm -rf dir/
touch /home/dir10/{file2,file3,.file4}
rm -f /home/dir10/ //不包括隐藏文件
rm -rf file
rm -rf .pdf
rm -f file*
rm -f *.txt
mv file file1
mv file1 /tmp/
mv /tmp/file1 ./
mv dir/ /tmp/
touch file{1..3}
mv file1 file2 file3 /opt/
mkdir dir{1..3}
mv dir1/ dir2/ dir3/ /opt
cp
cp file /tmp/file_copy
cp name /tmp/name1
cp file /tmp/
cp -p file /tmp/file_p
cp -r /etc/ /tmp/
cp -rv /etc/hosts /etc/hostname /tmp
cp -rv /etc/{hosts,hosts.bak}
cp -rv /etc/hosts{,-org}
常用命令
1 tree /home/ 树状形式显示 yum install tree
2 cat :查看文本内容
cat >> test2.txt <<EOF
> ads
> adf
> EOF
3 less,more:文本查看,分页
less /etc/services
4 head -n1 /etc/services :查看该文件第一行
5 ps aux | head -n5 :查看前5个进程
6 tail -f /var/log/messages :动态查看文件变化
7 grep:查找命令
-grep "lqz" test2.txt 查找文件中有lqz的行
-ps aux | grep ssh 查看sshd进程是否在运行
8 less打开文件:ctrl+b:下翻页 ctrl+f:上翻页
9 wget:下载yum install wget
wget 路径 默认下载在当前路径
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
10 curl:连通性
django:127.0.0.1:8080端口,先在本地curl一下,看看能不能通,可能是防火墙,阿里云的安全组
curl -o /home/a.png https:72743-20190.png
11 上传下载 (4g以内)
yum install lrzsz -y
rz:上传,选择文件直接上传
sz:sz 文件路径 可以下载到当前主机
12 which 命令:
去/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin 路径找有没有
13 whereis -b ls 查找ls命令,只找二进制(可执行文件)
14 sort
sort file.txt 对内容进行排序
sort -t ":" -k2 file.txt
sort -t ":" -n -k2 file.txt
15 uniq 去重,连续挨着的才能去,所以要跟sort连用
sort file2.txt | uniq
16 cut
Im lqz, is QQ 306334678
cut -d " " -f2,5 file.txt
17 wc
wc -l /etc/services
ls | wc -l
ps aux |grep ssh | wc -l
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现