Linux [11] -- Recap Linux Basic Command

本文回顾了Linux基本命令,包括创建music、picture、video三个目录,批量移动桌面文件,高效复制文件到指定目录,以及如何删除文件和目录。重点讲解了mkdir、touch、mv、cp、rm -rf和rmdir的用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I.Intro

 生产实习期间,选的 Big Data,昨天刚搭完hadoop环境,今天想乘机把Linux命令行捡回来,做了一点小小的小练习巩固巩固~ ?

II.Get Started

  • make three directory name by music, picture, video
	# 文件夹之间用空格隔开
	Psycho@SheepCore desktop $ mkdir music picture video
	

snapshot: make dir

  • fork 18 files under desktop
	# 文件夹之间用空格隔开
	Psycho@SheepCore desktop $ touch song1.mp3 song2.mp3 song3.mp3 /
	Psycho@SheepCore desktop $ touch song4.mp3 song5.mp3 song6.mp3
	Psycho@SheepCore desktop $ touch snap1.jpg snap2.jpg snap3.jpg snap4.jpg snap5.jpg snap6.jpg
	Psycho@SheepCore desktop $ touch film1.avi film2.avi film3.avi film4.avi film5.avi film6.avi
	

snapshot:
在这里插入图片描述

  • move all these files into specific folder
	# using mv command to move files from a to b
	Psycho@SheepCore desktop $ mv ./snap1.jpg ./picture
	Psycho@SheepCore desktop $ mv ./snap2.jpg ./picture
	...
	...
	...
	

一个一个move太繁琐!!!

So, here is a tremendous way elevate your efficiency:

	# using mv command to move files with operator *
	Psycho@SheepCore desktop $ mv ./snap*.jpg ./picture
	Psycho@SheepCore desktop $ mv ./song*.mp3 ./music
	Psycho@SheepCore desktop $ mv ./film*.avi ./video
	# 使用通配符 * 可以批量处理文件,但必须文件名得长得差不多才行!
	

snapshot:
list

  • create three directorys
	# using mkdir to make filefolder
	Psycho@SheepCore desktop $ mkdir friends family work
	Psycho@SheepCore desktop $ ls
	BigData_Hadoop		friends			video
	bd01_bd02_Linux基础	music			work
	family				picture			~$164586李久枫.docx	
  • copy files to directorys
	# using cp(copy) command
	Psycho@SheepCore desktop $ cp ./music/song{1,2}.mp3 friends/
	Psycho@SheepCore desktop $ cp ./music/song{3,4}.mp3 family/
	Psycho@SheepCore desktop $ cp ./music/song{5,6}.mp3 work/
	Psycho@SheepCore desktop $ cp ./picture/snap{1,2}.jpg friends/
	Psycho@SheepCore desktop $ cp ./picture/snap{3,4}.jpg family/
	Psycho@SheepCore desktop $ cp ./picture/snap{5,6}.jpg work/
	Psycho@SheepCore desktop $ cp ./video/film{1,2}.avi friends/
	Psycho@SheepCore desktop $ cp ./video/film{3,4}.avi family/
	Psycho@SheepCore desktop $ cp ./video/film{5,6}.avi work/	
	

snapshot:
copy file

  • remove files and directorys
	# using cp(copy) command
	Psycho@SheepCore desktop $ rm -drf ./family ./friends/
	
  • remove files in directory but remain directory
	# remove all files in work dir and remain current dir
	Psycho@SheepCore desktop $ rm -rf ./work/*

snapshot:
remove files in dir

  • using rmdir to remove empty directory
	# using cp(copy) command
	Psycho@SheepCore desktop $ rmdir work
	Psycho@SheepCore desktop $ ls
	BigData_Hadoop		music			video
	bd01_bd02_Linux基础	picture			~$164586李久枫.docx
	

III. Summary

 学而时习之,方可为师也!?

  • fork a directory: mkdir
  • fork a file: touch
  • move files to dir: mv
  • copy files to another dir: cp ~/oldFile ~/newFolder
  • remove files and its father directory: rm -rf dirname
  • remove files but remain dir: rm -rf ~/folderName
  • remove empty directory: rmdir

 Do what you want to do, be what you want to be!
 LOVE && PEACE. ?

Happy Coding.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值