Ubuntu Server配置常用命令

1. Ubuntu Server 修改時區(qū)

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2. SMB服務(wù)的開啟

通過sudo apt-get install samba,安裝服務(wù)。

smbpasswd -a user 則添加用戶user到Samba用戶數(shù)據(jù)庫中。

共享文件夾可通過在/etc/samba/smb.conf文件的末尾之添加如下字段:

[data]
comment = data
path = /mnt/data
writable = yes

3. 源的更新

編輯文件 /etc/apt/sources.list ,將其中源URL內(nèi)容更改為鏡像站。建議使用清華大學(xué)站點:https://mirrors.tuna.tsinghua.edu.cn/ubuntu/。

安裝Telnet并自動啟動

  1. 安裝Telnet服務(wù):sudo apt-get install xinetd telnetd
  2. 運行 sudo vi /etc/inetd.conf 并加入以下一行,如果文件不存在,新建一個再加上一行即可。
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
  1. 運行 sudo vi /etc/xinetd.conf 并加入以下行,如果文件不存在,新建一個再加上:
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
    # Please note that you need a log_type line to be able to use
    log_on_success
    # and log_on_failure. The default is the following :
    # log_type = SYSLOG daemon info
    instances = 60
    log_type = SYSLOG authpriv
    log_on_success = HOST PID
    log_on_failure = HOST
    cps = 25 30
}
includedir /etc/xinetd.d
  1. 運行 sudo vi /etc/xinetd.d/telnet 并加入以下行,如果文件不存在,新建一個再加上:
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
    disable = no
    flags = REUSE
    socket_type = stream
    wait = no
    user = root
    server = /usr/sbin/in.telnetd
    log_on_failure += USERID
}
  1. 重啟機器或重啟網(wǎng)絡(luò)服務(wù):sudo /etc/init.d/xinetd restart
    通過安裝sysv-rc-conf設(shè)置Ubuntu開機自啟動。
sudo apt-get install sysv-rc-conf 

sysv-rc-conf是一個強大的服務(wù)管理程序,運行:

sudo sysv-rc-conf

也可以直接加入啟動程序,例如把 /etc/init.d/red5 加入到系統(tǒng)自動 啟動列表中:

sudo sysv-rc-conf red5 on

4. 磁盤掛載

Ubuntu下重新掛載一個硬盤的方法如下:

  1. 以Vmware軟件為例(使用硬件而非虛擬機軟件的直接連接硬盤即可),在Vmware中關(guān)閉Ubuntu虛擬機,在設(shè)置中,添加新的硬件設(shè)備,選擇Hard Disk。(這里如果不關(guān)閉Ubuntu系統(tǒng)就不能增加新的硬件設(shè)備) 之后點擊下一步,選擇硬盤類型,可以選擇IDE,或是SCSI,這里選擇SCSI,下一步,選擇虛擬新硬盤的位置,將之命名為Ubuntu2.vmdk,下一步,設(shè)定硬盤大小,我這里設(shè)定為2G,并選擇Allocate all disk space now,不選這項,剛開始,硬盤比較小,但是隨著硬盤讀寫訪問,虛擬硬盤文件會越來越大。選擇該項后,虛擬硬盤就固定為所選的2G空間,不會再增大了。之后,點擊 Finish,開始創(chuàng)建新硬盤。

  2. 啟動Ubuntu,用root用戶登錄。
    在終端輸入:fdisk -l ,可以看到

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000af383
Device Boot      Start         End      Blocks   Id System
/dev/sda1   *           1        1244     9992398+ 83 Linux
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

這里可以看到 /dev/sdb 就是新添加的硬盤,需要給新的硬盤分區(qū)。
在終端輸入:

fdisk /dev/sdb

之后鍵入:m,可以看到幫助信息;鍵入:n,添加新分區(qū);鍵入:p,選擇添加主分區(qū);鍵入:l,選擇主分區(qū)編號為1,這樣創(chuàng)建后的主分區(qū)為sdb1之后,fdisk會讓你選擇該分區(qū)的開始值和結(jié)束值,直接回車; 最后鍵入:w,保存所有并退出,完成新硬盤的分區(qū)。

  1. 格式化磁盤
    在終端輸入:
mkfs -t ext4 /dev/sdb1

用ext3格式對/dev/sdb1 進行格式化

  1. 掛載該分區(qū):
    手動掛載:
    在終端輸入:
mkdir /media

創(chuàng)建新的硬盤的掛載點。

在終端鍵入:

mount /dev/sdb1 /media

如果想開機自動掛載
修改/etc/fstab文件,添加如下行:

/dev/sdb1       /media      ext3    defaults,        0       1
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容