jobs -查看正在后台中执行的进程
ps - report a snapshotof the current processes.
ps 显示前台的进程
ps -x 查看系统中属于自己的进程。
ps -au 查看系统中所有用户的进程。
ps -aux 查看系统中包含系统内部的及所有用户的进程。
ps -e To seeevery process on the system using standard syntax
chown 修改文件和文件夹的用户和用户组属性
例sudo chown root file
chown -R foo:net/tmp/tmp(将/tmp/tmp目录改为net组foo所有)
chmod 修改文件和文件夹读写执行属性
chmod a+r file 增加读权限对file的所有用户
chmod a-x file 删除执行权限对file的所有用户
chmod 777 *
chmod u+s file
查找变量、函数等所在的文件
grep <str>* -rni path
-r --recursive
-i --ignore-case
-n --line-number
在键入命令时的几个快捷键:
Ctrl + a - 跳到行首
Ctrl + e - 跳到行尾
Ctrl + r - 查找历史命令
Ctrl + u -Delete backward from cursor // 密码输入错误的时候比较有用
tar命令参数:
-j--bzip2:filter archive through bzip2,use to decompress .bz2 files
-v--verbose:verbosely list files processed
-x--extract,--get:extract files from an archive
-z--gzip,--gunzip,--ungzip:filter the archive through gzip
-f --file:usearchive file
-c--create:create a new archive
某测试tar cvf archive.tar files&dir/ --250+M
tar zcvfarchive.tar.gz files&dir/ -- 77M
tar jcvfarchive.tar.bz2 files&dir/ -- 55M
bzip2的压缩效率高于gzip,速度慢于gzip,频繁解压缩时使用gzip.
在unix下*.* 的意思是包含有点的文件,不包括点开头的文件。
.* 的意思是所有点开头的文件。
* 的意思是全部文件,但是不包括点开头的文件(所谓的隐含文件)(目录下.config之类文件不会被打包)
tar zcvffile.tar.gz /home/user/ 会打包所有的文件
tar zcvffile.tar.gz /home/user/* 打包除了隐藏文件外的所有文件
bzcat命令解压文件到标准输出,查看.bz2文件内容(不进行解压)。
linux批量修改扩展名为.asp的文件修改为.html
rename's/.asp$/.html/' *
linux批量修改文本中".asp"串->".html"
sed -i"s/\.asp/\.html/g" *.*
sed批量修改不成功可能是权限问题。
sed -- streameditor,遇到的常是批量修改文本内容,更多具体使用,没有实验,可在遇到类似问题时具体查找。
shutdown -h now 现在立即关机
shutdown -r now 现在立即重启
shutdown -r +3 三分钟后重启
shutdown -h +3"The System will shutdown after 3 minutes" 提示使用者将在三分钟后关机
shutdown -r20:23 在20:23时将重启计算机
比较两个文件的不同之处(我是经常使用Beyond Compare进行比较)
diff -uNr file1file2
为linux-2.6目录建立软连接linux
ln -s linux-2.6/linux
ln -s linux-2.6/linux/ (错误的方式)
在工程的Makefile中,一般指明路径为“linux”,这样,在修改了所使用的内核版本时不会对Makefile进行修改。
du - estimatefile space usage.
-h--human-readable
使用du -sh dirs 查看目录占用磁盘空间的大小
stat命令查看文件的状态:访问、修改时间等
想要在当前目录及子目录中查找所有的"*.txt"文件
find . -name"*.txt"
想要的当前目录及子目录中查找文件名以一个大写字母开头的文件
find . -name"[A-Z]*"
(对于正则表达式的使用,可令查阅资料)
删除路径下所有相同名字目录 find . -name ".svn" |xargs rm -fr
echo"\thello" //打印\thello
echo -e"\thello" //打印(Tab)hello
echo
NOTE:your shellmay have its own version of echo which will supercede the version describedhere. Please refer to your shell's documentation for details about the optionsit supports.
echo -n do notoutput the trailing newline.
-e enableinterpretation of the backslash-escaped characters listed below.
touch - changefile timestamps.
update theaccess and modification times of each FILE(argument) to the current time.
A FILE argumentthat does not exist is created empty, unless –c or –h is supplied.
cd - 返回上一次(不是上一级)的目录
uptime - Tellhow long the system has been running.
将系统时间设定成2009年5月10日
#date -s 05/10/2009
将系统时间设定成上午10点18分0秒
#date -s10:18:00
pwd -P 显示出实际路径,而非使用连接(link)路径。在makefile常可见。