文件操作:
cp:拷贝文件,例如:cp ./apps/bin ./apps/dev/bin 即从./apps/bin 拷贝到./apps/dev/bin;
mv:移动或更名现有的文件或目录。用法基本与 cp 相同
rm:删除文件,rm -rf 强制删除,不管是目录还是文件
scp: 在远程机器上 copy 档案例如:
copy 本地的档案到远程的机器上 scp /etc/lilo.conf k@net67.ee.oit.edu.tw:/home/k
会将本地的 /etc/lilo.conf 这个档案 copy 到 net67.ee.oit.edu.tw,使用者 k 的家目录下。
copy 远程机器上的档案到本地来 scp k@net67.ee.oit.edu.tw:/etc/lilo.conf /etc
会将 net67.ee.oitdu.tw 中 /etc/lilo.conf 档案 copy 到本地的 /etc 目录下。
保持从来源 host 档案的属性 scp –p k@net67.ee.tw:/etc/lilo.conf /etc
ln:ln -s target-dest target 创建 target 的快捷方式 target-dest
chmod:改变执行权限 例 :将档案 file1.txt 设为所有人皆可读取 : chmod ugo+r file1.txt
将档案 file1.txt 设为所有人皆可读取 : chmod a+r file1.txt
将档案 file1.txt 与 file2.txt 设为该档案拥有者,与其所属同一个群体者可写入,但其他以外的人则不可写
入 :
chmod ug+w,o-w file1.txt file2.txt
将 ex1.py 设定为只有该档案拥有者可以执行 : chmod u+x ex1.py
chgrp:用来修改文件的所属组。例如将目录/etc/httpd 的所属组修改为 http: chgrp http /etc/httpd
tar:压缩解压命令,解压 tar。只打包不压缩:tar -cvf mysql,解压时用 tar xvf mysql.tar 压缩:tar -zcvf
mysql, 解压: tar zxvf mysql.tar.gz,几种压缩方式参考- -help
zip:压缩命令,对应解压命令 unzip,如,zip mysql, unzip mysql.zip
cat:把档案串连接后传到基本输出(屏幕或加 > fileName 到另一个档案)
把 textfile1 的档案内容加上行号后输入 textfile2 这个档案里 cat -n textfile1 >> textfile2
把 textfile1 和 textfile2 的档案内容加上行号(空白行不加)之后将内容附加到 textfile3 里。