Linux文件管理命令非常丰富,以下是一些常用的Linux文件管理命令:
ls
-l
(长格式显示)、-a
(显示所有文件,包括隐藏文件)、-h
(人类可读的文件大小)。cd
cd /home/user/Documents
pwd
mkdir
mkdir new_directory
rmdir
rmdir old_directory
rm
-r
(递归删除目录及其内容)、-f
(强制删除)。cp
cp source.txt destination.txt
或 cp -r source_directory destination_directory
mv
mv old_name.txt new_name.txt
或 mv file.txt /new/path/
touch
find
find /home/user -name "*.txt"
grep
grep "error" logfile.log
sed
sed 's/old/new/g' file.txt
awk
awk '{print $1}' file.txt
tar
tar -czvf archive.tar.gz /path/to/directory
zip/unzip
zip archive.zip file1.txt file2.txt
和 unzip archive.zip
chmod
chmod 755 script.sh
chown
chown user:group file.txt
du
-h
(人类可读)、-s
(总结)。df
-h
(人类可读)。ps
ps aux
top
lsattr
chattr
chattr +i file.txt
(使文件不可修改)scp
scp localfile.txt user@remotehost:/path/to/destination
rsync
rsync -avz /local/path/ user@remotehost:/remote/path/
cat
cat file.txt
head/tail
head -n 10 file.txt
和 tail -n 10 file.txt
cut
sort
uniq
wc
rm -rf
)时,请务必小心谨慎。man command
)获取详细信息。掌握这些基本命令将大大提高你在Linux系统中的文件管理效率!