1. 程式人生 > >linux學習記錄.4.常用命令

linux學習記錄.4.常用命令

退出 CP 軟件工具 使用命令 nbsp comm ebo update 行號

幫助command --help 獲取‘command‘命令的幫助

目錄與文件

cd /home 進入‘home’目錄

cd .. 返回上一級目錄

cd 進入個人目錄

cd - 返回上一級目錄

pwd 顯示當前路徑

ls 查看目錄中的文件與目錄

ls -l 顯示文件和目錄的詳細資料

ls -a 顯示包含隱藏文件

mkdir dir1 創建以一個‘dir1’目錄

mkdir -p dir1/dir2 建立一個多層目錄,dir1/dir2

rmkdir [-p] dir 刪除空目錄‘dir’,-p 連同上層的空目錄也刪除

touch [-acdmt] hello.c 建立一個‘hello.c’空文件,-a 僅修改時間,-c 僅修改時間若不存在則不建立新文件

cat [options] hello.c 從第一行開始顯示文件hello.c內容,-A 相當於 -vET,-n 顯示行號,-v 列出不可見字符,-E 換行符$顯示,-T [tab]以^I顯示

tac [options] hello.c 從最後一行開始顯示

nl [options] hello.c 顯示文件hello.c的內容,-b

rm hello.c 刪除文件’hello.c‘

rm [options] dir 刪除文件夾dir,-r 向下遞歸,-f 忽略提示

cp [options] source destination 復制文件或目錄

mv [options] source destination 移動文件或目錄

chmod 改變文件權限

tar 壓縮包 tar.gz 使用命令 tar -xzvf filename 解壓到當前目錄

系統

date 顯示日期

cal 顯示日歷

sync 同步內存到硬盤

shutdown 關機

poweroff 關機

halt 關機

reboot 重啟

exit 退出終端

kill 關閉進程

軟件工具

apt-get install packageName 安裝/更新一個 deb 包

apt-get update 更新包

apt-get upgrade 升級軟件

apt-cache search package

snap install packageName 安裝一個 snap 包

snap refresh 更新

linux學習記錄.4.常用命令