Linux伺服器常用命令詳情,linux常用命令詳情

來源:互聯網
上載者:User

Linux伺服器常用命令詳情,linux常用命令詳情
一、使用者篇

1. 建立賬戶用到useradd命名

useradd newname // 建立使用者newnamepasswd newname // 設定&&修改密碼,輸入此命令後會提示你輸入密碼

2. 刪除使用者

userdel newname

3. 切換使用者

su - youruser

4. ssh遠程登入

ssh -l root 192.168.0.11ssh root@192.168.0.11

指定連接埠:

ssh -p 12333 192.168.0.11ssh -l root -p 12333 216.230.230.114ssh -p 12333 root@216.230.230.114

5. 補救伺服器ssh登入連接埠

登入伺服器後

#sudo vi /etc/ssh/sshd_config

裡面的port 22改成port 連接埠號碼

改完之後重新啟動SSH服務,/etc/init.d/ssh restart

二、群組篇

1. 建立組

groupadd testgroup

2. 修改組

groupmod -n test2group testgroup

3. 刪除群組

groupdel testgroup

4. 查看組

cd /homels -l #第三列表示檔案或目錄的所有者,第四列表示檔案或目錄的所在群組

5. 修改使用者群組

-l:對使用者重新命名,但是/home目錄中的使用者家目錄名不會改變,需要手動修改。
-g:修改使用者所在群組

 usermod -g siatstudent newname

一次將一個使用者添加到多個群組,就用 -G 參數(大寫的G):

usermod -G friends,happy,funny newname

注意:使用usermod時要小心,因為配合-g或-G參數時,它會把使用者從原先的群組裡剔除,加入到新的群組。如果你不想離開原先的群組,又想加入新的群組,可以在-G參數的基礎上加上-a參數,a是英語append的縮寫,表示“追加”。例如:

usermod -aG happy newname  //這樣newname就屬於兩個群組:siatstudent和happy
groups newname #查看newname所屬群組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.