Ubuntu 常用命令
文件操作类
移动、重命名文件
mv [file] [folder]
# mv sss.txt ./myFolder/subFoulder
# mv sss.txt ttt.txt
删除文件
rm fileName
rm -f fileName # 强制删除
rm -rf folder # 强制删除文件夹下所有内容
# 删库跑路,千万不要尝试!
sudo rm -rf /
sudo rm -rf *
在命令行中编辑文件
sudo gedit /path/to/filename
sudoedit /path/to/filename
查看文件夹大小
du -sh folder_path
压缩文件
# using tar.gz
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
# using tar.xz
tar -cjvf name-of-archive.tar.xz /path/to/directory-or-file
# for example
tar -czvf grid1.tar.gz grid1
-c
: Create an archive.
-z
: Compress the archive with gzip.
-j
: Compression option for xz
-v
: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f
: Allows you to specify the filename of the archive. This option must come last, since it specifies the filename.
.gz
压缩速度最快,但文件大小更大。.xz
压缩速度较慢,但是压缩效率更高,文件大小更小
解压缩文件
.gz
and .xz
使用命令相同。
tar -xf archive.tar.gz -C /home/linuxize/files
# extracting specific files
tar -xf archive.tar.gz file1 file2
-c
: 提取文件到指定位置
# To list the content of a tar.gz file, use the --list (-t) option:
tar -tf archive.tar.gz
-t
: 显示压缩文件内容
进程类
杀死进程
sudo kill -9 process_id # PID