如果在命令行下使用gedit, 關閉程序窗口(壹般先保存文件),就自動退到命令行界面。
如果在命令行下使用vim,先按下ESC退出編輯模式,然後輸入:wq 保存並退出或者q退出或者q!強制退出,從而回到命令行界面。
擴展資料:
linux常見命令:
命令
apropos whatis 顯示和word相關的命令。 參見線程安全
man?-t man | ps2pdf - > man.pdf 生成壹個PDF格式的幫助文件
which command 顯示命令的完整路徑名
time command 計算命令運行的時間
time cat 開始計時. Ctrl-d停止。參見sw
nice?info 運行壹個低優先級命令(這裏是info) ?
renice 19 -p $$ 使腳本運行於低優先級。用於非交互任務。
目錄操作?
cd - 回到前壹目錄
cd 回到用戶目錄 ?
(cd dir && command) 進入目錄dir,執行命令command然後回到當前目錄?
pushd?. 將當前目錄壓入棧,以後妳可以使用popd回到此目錄
文件搜索
alias?l='ls -l --color=auto' 單字符文件列表命令?
ls -lrt 按日期顯示文件. 參見newest ?
ls /usr/bin | pr -T9 -W$COLUMNS 在當前終端寬度上打印9列輸出?
find -name '*.[ch]' | xargs grep -E 'expr' 在當前目錄及其子目錄下所有.c和.h文件中尋找'expr'. 參見findrepo
find -type f -print0 | xargs -r0 grep -F 'example' 在當前目錄及其子目錄中的常規文件中查找字符串'example'?
find -maxdepth 1 -type f | xargs grep -F 'example' 在當前目錄下查找字符串'example' ?
find -maxdepth 1 -type d | while?read?dir; do echo $dir; echo cmd2; done 對每壹個找到的文件執行多個命令(使用while循環) ?
find -type f ! -perm -444 尋找所有不可讀的文件(對網站有用)
find -type d ! -perm -111 尋找不可訪問的目錄(對網站有用)?
locate -r 'file[^/]*\.txt' 使用locate 查找所有符合*file*.txt的文件?
look reference 在(有序)字典中快速查找?
grep?--color?reference /usr/share/dict/words 使字典中匹配的正則表達式高亮?
歸檔 and compression
gpg -c file 文件加密?
gpg file.gpg 文件解密 ?
tar -c dir/ | bzip2 > dir.tar.bz2 將目錄dir/壓縮打包 ?
bzip2 -dc dir.tar.bz2 | tar -x 展開壓縮包 (對tar.gz文件使用gzip而不是bzip2) ?
tar -c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg' 目錄dir/壓縮打包並放到遠程機器上?
find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2 將目錄dir/及其子目錄下所有.txt文件打包?
find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents 將目錄dir/及其子目錄下所有.txt按照目錄結構拷貝到dir_txt/?
( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p ) 拷貝目錄copy/到目錄/where/to/並保持文件屬性
( cd /dir/to/copy && tar -c?.?) | ( cd /where/to/ && tar -x -p ) 拷貝目錄copy/下的所有文件到目錄/where/to/並保持文件屬性
( tar -c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar -x -p' 拷貝目錄copy/到遠程目錄/where/to/並保持文件屬性
dd bs=1M if=/dev/sda | gzip | ssh user@remote 'dd of=sda.gz' 將整個硬盤備份到遠程機器上