Linux基本命令

2021-10-14 12:23:17 字數 1254 閱讀 3693

企業伺服器用linux系統的原因:成本低、穩定。

【檔案建立】

萬用字元檢視多個檔案:ls *.txt

建立多個資料夾:touch _wenjian.txt

【使用者】

檢視當前賬戶:who am i

建立使用者:sudo adduser hx

登陸使用者:su -l hx

su - hx

【使用者組】

檢視當前使用者組:groups  hx

檢視已過濾的使用者組資訊:cat /etc/group |  grep -e "shiyanlou"

使用者加入使用者組:sudo usermod -g sudo hx

刪除使用者:sudo deluser hx --remove-home

刪除使用者組:groupdel

【檔案許可權】

檢視檔案許可權:ls -l

檢視隱藏檔案:ls -a

檢視檔案所有者和許可權:ls -alh iphone15

更改檔案所有者:sudo chown shiyanlou iphone15

777對應擁有者,所屬使用者組,其他使用者的許可權

管道:連線多個命令。linux提供管道符"|"將兩個命令隔開,管道符左邊命令的輸出就會作為管道符右邊命令的輸入。

eg:echo a.sh | grep 』2』 #列印a.sh的同時,找出其中包含2的整段

【目錄和檔案操作】

cd時目錄可以用tab鍵補全

建立多級目錄:mkdir -p desktop/a/a11

強制刪除檔案:rm -f 1.txt

刪除目錄 rm -rf a1

重新命名:mv 1.txt 2.txt

【變數和查詢檔案】

定義變數:tmp=shiyanlou

檢視變數:echo $tmp

執行shell檔案: ./hello_shell.sh

*shell標頭檔案:#!/bin/bash

查詢檔案:sudo find shiyanlou -name 1.txt

資料流重定向:echo 'hi'>>1.txt

【檢視程序】

ps -ef | grep sshd 命令詳解:

linux基本命令

linux常用命令 基礎 eg man ls 就可以檢視ls相關的用法 注 按q鍵或者ctrl c退出,在linux下可以使用ctrl c終止當前程式執行。2.ls 檢視目錄或者檔案的屬 列舉出任一目錄下面的檔案 eg ls usr man ls l a.d表示目錄 directory 如果是乙個 ...

《linux基本命令》

博主部落格 斷橋殘雪 uname 顯示版本資訊 同win2k的 ver dir 顯示當前目錄檔案,ls al 顯示包括隱藏檔案 同win2k的 dir pwd 查詢當前所在的目錄位置 cd cd 回到上一層目錄,注意cd 與.之間有空格。cd 返回到根目錄。cat 檔名 檢視檔案內容 cat abc...

LINUX 基本命令

檔案和目錄操作的基本命令 cat clear cmp cut diff du emacs fgrep file grep head ln less more pico pwd sort stat strings tail touch umask uniq vi wc whatis ls ls 選項 ...