linux常用命令介绍

上传人:第*** 文档编号:32688390 上传时间:2018-02-12 格式:DOC 页数:9 大小:49.50KB
返回 下载 相关 举报
linux常用命令介绍_第1页
第1页 / 共9页
linux常用命令介绍_第2页
第2页 / 共9页
linux常用命令介绍_第3页
第3页 / 共9页
linux常用命令介绍_第4页
第4页 / 共9页
linux常用命令介绍_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《linux常用命令介绍》由会员分享,可在线阅读,更多相关《linux常用命令介绍(9页珍藏版)》请在金锄头文库上搜索。

1、GNU/Linux 常用命令介绍文 件 和 目 录 处 理创 建 目 录 :mkdir dir创 建 嵌 套 目 录 :mkdir p dir1/dir2切 换 目 录 :cd newdircd . (上一级目录)cd -(上一次目录)cd (用户根目录)cd bill (home directory of user bill)显 示 当 前 目 录 :pwd文 件 拷 贝 :cp source_file dest_file拷 贝 多 个 文 件 到 目 录 下 :cp file1 file2 dir目 录 拷 贝 ( 目 录 递 归 ) :cp r source_dir dest_dirrs

2、ync a source_dir/ dest_dir/建 立 一 个 链 接 :ln s linked_file link文 件 , 链 接 , 目 录 更 名 :mv source_file dest_file删 除 文 件 或 链 接 :rm file1 file2删 除 空 目 录 :rmdir dir删 除 不 为 空 的 目 录 :rm rf dir文 件 列 表列 出 当 前 目 录 所 以 常 规 文 件 ( 不 以 .开 始 的 文 件 )ls带 更 多 信 息 的 列 出 :ls -l列 出 当 前 目 录 的 所 有 文 件 (包 含 以 .开 头 的 文 件 ):ls -

3、a按 时 间 排 序 :ls -t按 大 小 排 序 :ls -S反 方 向 排 序 :ls -r参 数 可 以 组 合 :ls -ltrDISPLAYING FILE CONTENTSConcatenate and display file contents:cat file1 file2Display the contents of several files (stopping at each page):more file1 file2less file1 file2 (better: extra features)Display the first 10 lines of a fil

4、e:head -10 fileDisplay the last 10 lines of a file:tail -10 fileFile name pattern matchingConcatenate all “regular” files:cat *Concatenate all “hidden” files:cat .*Concatenate all files ending with .log:cat *.logList “regular” files with bug in their name:ls *bug*List all “regular” files ending with

5、 . and a single character:ls *.?HANDLING FILE CONTENTSShow only the lines in a file containing a given substring:grep substring fileCase insensitive search:grep i substring fileShowing all the lines but the ones containing a substring:grep v substring fileSearch through all the files in a directory:

6、grep r substring dirSort lines in a given file:sort fileSort lines, only display duplicate ones once:sort -u file (unique)CHANGING FILE ACCESS RIGHTSAdd write permissions to the current user:chmod u+w fileAdd read permissions to users in the file group:chmod g+r fileAdd execute permissions to other

7、users:chmod o+x fileAdd read + write permissions to all users:chmod a+rw fileMake executable files executable by all:chmod a+rX *Make the whole directory and its contents accessible by all users:chmod R a+rX dir (recursive)COMPARING FILES AND DIRECTORIESComparing 2 files:diff file1 file2Comparing 2

8、files (graphical):gvimdiff file1 file2tkdiff file1 file2kompare file1 file2Comparing 2 directories:diff r dir1 dir2LOOKING FOR FILESFind all files in the current (.) directory and its subdirectories with log in their name:find . -name“*log*”Find all the .pdf files in dir and subdirectories and run a

9、 command on each:find . -name“*.pdf” exec xpdf ;Quick system-wide file search by pattern (caution: index based, misses new files):locate “*pub*”REDIRECTING COMMAND OUTPUTRedirect command output to a file:ls *.png image_filesAppend command output to an existing file:ls *.jpg image_filesRedirect comma

10、nd output to the input of another command:cat *.log | grep errorJOB CONTROLShow all running processes:ps -efLive hit-parade of processes (press P, M, T: sort by Processor, Memory or Time usage):topSend a termination signal to a process:kill (number found in ps output)Have the kernel kill a process:k

11、ill -9 Kill all processes (at least all user ones):kill -9 -1Kill a graphical application:xkill (click on the program window to kill)FILE AND PARTITION SIZESShow the total size on disk of files or directories (disk usage):du sh dir1 dir2 file1 file2Number of bytes, words and lines in file:wc file (w

12、ord count)Show the size, total space and free space of the current partition:df h .Display these info for all partitions:df -hCOMPRESSINGCompress a file:gzip file (.gz format)bzip2 file (.bz2 format, better)lzma file (.lzma format, best compression)Uncompress a file:gunzip file.gzbunzip2 file.bz2unl

13、zma file.lzmaARCHIVINGCreate a compressed archive (tape archive):tar zcvf archive.tar.gz dirtar jcvf archive.tar.bz2 dirtar -lzma -cvf archive.tar.lzmaTest (list) a compressed archive:tar ztvf archive.tar.gztar jtvf archive.tar.bz2tar lzma tvf archive.tar.lzmaExtract the contents of a compressed arc

14、hive:tar zxvf archive.tar.gztar jxvf archive.tar.bz2tar lzma xvf archive.tar.lzmatar options:c: createt: testx: extractj: on the fly bzip2 (un)compressionz: on the fly gzip (un)compressionHandling zip archiveszip r archive.zip (create)unzip t archive.zip (test / list)unzip archive.zip (extract)PRINT

15、INGSend PostScript or text files to queue:lpr Pqueue f1.ps f2.txt (local printer)List all the print jobs in queue:lpq -PqueueCancel a print job number in queue:cancel 123 queuePrint a PDF file:pdf2ps doc.pdflpr doc.psView a PostScript file:ps2pdf doc.psxpdf doc.pdfUSER MANAGEMENTList users logged on

16、 the system:whoShow which user I am logged as:whoamiShow which groups user belongs to:groups userTell more information about user:finger userSwitch to user hulk:su - hulkSwitch to super user (root):su - (switch user)su (keep same directory and environment)TIME MANAGEMENTWait for 60 seconds:sleep 60Show the current date:dateCount the time taken by a command:time find_charming_prince cute -richCOMMAND HELPBasic help (works

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 职业教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号