天天看點

Linux指令總結(重制版)

linux command

  • ​​建立一個新使用者,并且配置設定home目錄​​
  • ​​删除檔案夾中所有檔案除了某幾個檔案或檔案夾​​
  • ​​檢視檔案夾占用空間​​
  • ​​檢視硬碟空間​​
  • ​​find和vim聯合使用,find查找某個檔案後vim直接打開​​
  • ​​nohup​​
  • ​​sed command​​
  • ​​查找檔案和檔案夾​​
  • ​​list the installed apps​​
  • ​​查找大于某個尺寸的檔案​​
  • ​​列出詳細資訊​​
  • ​​從終端打開檔案管理器​​
  • ​​查找程序​​
  • ​​殺死程序​​
  • ​​set proxy​​
  • ​​檔案夾和檔案設定權限​​
  • ​​find a pid process using a special port​​
  • ​​copy a folder to a remote machine​​

建立一個新使用者,并且配置設定home目錄

sudo useradd -m your_user_name
# as root user
passwd      

删除檔案夾中所有檔案除了某幾個檔案或檔案夾

rm -rf -v !("filename"|"foldername")      

檢視檔案夾占用空間

du -h /logs   # -h stands for human, which is more readable for human.      

檢視硬碟空間

df      

find和vim聯合使用,find查找某個檔案後vim直接打開

find . -name hello.md -exec vi {} \;
# or
# vi $(find . -name hello.md)      

nohup

​​How to use Nohup in Linux​​

sed command

​​Sed Command in Linux/Unix with examples​​

查找檔案和檔案夾

find {path} -iname {filename}
eg. find . -iname "server"
e.g.  find . -iname "*kuka*"
# -iname 模糊查找

find {path} -name {filename}
eg. find . -name server
# or find . -type f -name server
# -name 精準查找

# find directory

find . -type d -name ".git"      

list the installed apps

apt list --installed      

查找大于某個尺寸的檔案

find {目錄}  -type f -size +100k
e.g.  find .      

列出詳細資訊

ll      

從終端打開檔案管理器

nautilus .   # .代表目前目錄      

查找程序

ps aux | grep {pid name}
e.g.  ps aux | grep v2ray

# or      

殺死程序

kill pid_num
# kill from name 
pkill      

set proxy

alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1089" 
alias unsetproxy="unset ALL_PROXY"      

檔案夾和檔案設定權限

檔案夾一共有三種權限類型:

  • read
  • write
  • execute

通過使用數字來指定對應的權限:

  • read - 4
  • write - 2
  • execute - 1

使用chmod指令來修改權限,格式為​

​chmod xyz <file or directory>​

​ 其中:

  • x - 代表使用者的所有權限的合
  • y - 使用者組所有權限的和
  • z - 剩餘使用者和使用者組所有權限的和

比如:

chmod      

代表dell和dell的group擁有對檔案夾/home/dell讀和寫的權限,其他使用者組隻有讀的權限,​

​-R​

​代表遞歸的對所有檔案夾設定權限。

chmod      

find a pid process using a special port

sudo netstat -nlp | grep      

copy a folder to a remote machine

scp      

繼續閱讀