Linux常用命令(学习记录)

  1. cd:切换目录

# 进入目录
cd /path/to/directory

# 返回上一级目录
cd ..

# 返回根目录
cd /
  1. ls:列出目录和文件

# 列出当前目录的内容
ls

# 列出指定目录的内容
ls /path/to/directory

# 列出详细信息(包括权限、大小、时间等)
ls -l
  1. mkdir:创建目录

# 创建一个新目录
mkdir /path/to/new_directory

# 创建多个新目录
mkdir -p /path/to/new_directory/sub_directory
  1. rm:删除文件或目录

# 删除文件
rm /path/to/file

# 删除目录及其内容(需要确认)
rm -r /path/to/directory

# 强制删除文件或目录(不进行确认)
rm -rf /path/to/file_or_directory
  1. touch:创建空文件

# 创建一个新文件
touch /path/to/new_file

# 创建多个新文件
touch /path/to/new_file1 /path/to/new_file2
  1. cat:查看文件内容

# 查看文件内容
cat /path/to/file

# 将多个文件合并并输出
cat file1 file2 > output

# 在文件末尾添加内容
cat >> /path/to/file
  1. cp:复制文件或目录

# 复制文件到另一个目录
cp /path/to/file /path/to/new_directory

# 复制目录及其内容到另一个目录
cp -r /path/to/directory /path/to/new_directory
  1. mv:移动或重命名文件或目录

# 移动文件到另一个目录
mv /path/to/file /path/to/new_directory

# 重命名文件
mv /path/to/file /path/to/new_file_name

# 移动目录及其内容到另一个目录
mv /path/to/directory /path/to/new_directory
  1. grep:查找文件中的文本

# 查找文件中包含指定文本的行
grep 'text' /path/to/file

# 查找文件中包含指定文本的行,并输出行号
grep -n 'text' /path/to/file

# 查找文件中不包含指定文本的行
grep -v 'text' /path/to/file
  1. top:查看系统进程和资源占用情况

# 查看系统进程和资源占用情况
top

# 按照CPU占用率排序
top -o %CPU

# 显示指定用户的进程
top -u username
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值