• slider image 221
:::

3-4-3 學生帳號

快速建立多個帳號


sudo newusers < newuser_list.txt

s601:9999:1101:1101:s601:/home/s601:/bin/bash
s602:9999:1102:1102:s602:/home/s602:/bin/bash
s603:9999:1103:1103:s603:/home/s603:/bin/bash
s604:9999:1104:1104:s604:/home/s604:/bin/bash
s605:9999:1105:1105:s605:/home/s605:/bin/bash
s606:9999:1106:1106:s606:/home/s606:/bin/bash
s607:9999:1107:1107:s607:/home/s607:/bin/bash
s608:9999:1108:1108:s608:/home/s608:/bin/bash
s501:9999:1111:1111:s501:/home/s501:/bin/bash
s502:9999:1112:1112:s502:/home/s502:/bin/bash
s503:9999:1113:1113:s503:/home/s503:/bin/bash
s504:9999:1114:1114:s504:/home/s504:/bin/bash
s505:9999:1115:1115:s505:/home/s505:/bin/bash
s506:9999:1116:1116:s506:/home/s506:/bin/bash
s507:9999:1117:1117:s507:/home/s507:/bin/bash
s508:9999:1118:1118:s508:/home/s508:/bin/bash
s401:9999:1121:1121:s401:/home/s401:/bin/bash
s402:9999:1122:1122:s402:/home/s402:/bin/bash
s403:9999:1123:1123:s403:/home/s403:/bin/bash
s404:9999:1124:1124:s404:/home/s404:/bin/bash
s405:9999:1125:1125:s405:/home/s405:/bin/bash
s406:9999:1126:1126:s406:/home/s406:/bin/bash
s407:9999:1127:1127:s407:/home/s407:/bin/bash
s408:9999:1128:1128:s408:/home/s408:/bin/bash
s301:9999:1131:1131:s301:/home/s301:/bin/bash
s302:9999:1132:1132:s302:/home/s302:/bin/bash
s303:9999:1133:1133:s303:/home/s303:/bin/bash
s304:9999:1134:1134:s304:/home/s304:/bin/bash
s305:9999:1135:1135:s305:/home/s305:/bin/bash
s306:9999:1136:1136:s306:/home/s306:/bin/bash
s307:9999:1137:1137:s307:/home/s307:/bin/bash
s308:9999:1138:1138:s308:/home/s308:/bin/bash 
stud:0000:1139:1139:stud:/home/stud:/bin/bash

 

 

在某一帳號(stud)先做好預設值

  • 學校首頁、常用網站書籤
  • 檔案關聯-- xmind   , Imagination , sweetHome 3D ...
  • 作業目錄 

sudo ln -s  /home/nfs_work/class4/  作業

sudo ln -s  /home/nfs_work/class_data/   資料目錄

 

 

 

 

登出捷徑
 

/etc/skel/Desktop/登出.desktop
[Desktop Entry]
Name=使用者登出
Exec=gnome-session-quit
Type=Application
StartupNotify=true
Icon=gnome-logout

 

 

Wine 權限修改(預先安裝 user 目錄中)

修改目前已安裝的帳號,不能再安裝軟體,並提供個其他帳號可以執行

cd /home/user
sudo chown root.root ~/.wine/drive_c -R 
sudo chmod 777 ~/.wine/drive_c/users 
 

放個 logo 圖 128*128

/home/user/.wine/Sculptrislogo.png


可使用 Sculptris 帳號需要複制 .wine 並改以連結方式使用 C 碟 ,原以 user 帳號安裝,

#刪除原建立的檔
rm ~/.wine/driver_c
#如果未建立過

mkdir /home/stud/.wine

sudo chown stud.stud  .wine

#指定 user windows 
ln -s /home/user/.wine/driver_c  /home/stud/.wine/driver_c

ln -s /home/user/.wine/dosdevices /home/stud/.wine/dosdevices

其餘不可使用 wine 的帳號,建立一個空的 .wine
 

sudo touch .wine 
sudo chown root.root .wine

 

 

Sculptris捷徑做法:

要修改 個帳號桌面上的 Sculptris.desktop 內容 ,如 stud 帳號為例 

[Desktop Entry]
Name=Sculptris
Exec=env WINEPREFIX="/home/stud/.wine" wine C:\\\\windows\\\\command\\\\start.exe /Unix /home/stud/.wine/dosdevices/c:/users/Public/桌面/Sculptris.lnk
Type=Application
StartupNotify=true
Comment=Execute Sculptris
Path=/home/stud/.wine/dosdevices/c:/Program Files (x86)/Pixologic/Sculptris Alpha 6
StartupWMClass=sculptris.exe


可以複製再做修改 
cp /home/user/桌面/Sculptris.desktop /home/stud/桌面/Sculptris.desktop

sudo chown stud.stud /home/stud/桌面/Sculptris.desktop

sudo -i 's/stud/%s/g' /home/stud/桌面/Sculptris.desktop


 

 

 

多帳號境複製

  • 先需要調整一個使用者的各項設定,設定好後再複製給其他的帳號。如下:
    sudo cp -arpf /home/s601/. home/s602/
    sudo chown s602.s602 /home/s602/. -R
    
    

 

python 寫法

#! /usr/bin/python3
#在ubuntu 多人環境,複製相同的環境設定檔
import os
sourcepath='/home/stud/.'

#先清除會干擾的目錄、檔案 (會自動生成)
line2="sudo rm -f  /home/stud/.config/gtk-3.0/bookmarks"
os.system(line2)
line2="sudo rm -fR  /home/stud/.java"
os.system(line2)
#清除最近使用記錄等
line2="sudo rm -fR  /home/stud/.local/share/"
os.system(line2)

for y in range(3 , 7) :
    for c in range(1 , 9) :
        newuser='s' +  str( y*100+c)
        #清空帳號內容 ,改刪除重建
        #line_clear= "sudo rm  -fR /home/%s/{,.[!.],..?}*" % ( newuser )
        line_clear= "sudo rm  -fR /home/%s/" % ( newuser )
        
        print(line_clear)
        os.system(line_clear)

        line1="sudo mkdir /home/%s " % (   newuser )
        print(line1)
        os.system(line1)
 
        line1="sudo cp -arpf %s /home/%s/" % ( sourcepath , newuser )
        print(line1)
        os.system(line1)


        line2="sudo chown -R  %s.%s /home/%s/." %(newuser , newuser , newuser )
        print(line2)
        os.system(line2)

        #wine 3d 軟體的路徑修正
        line2="sudo sed -i 's/stud/%s/g' /home/%s/桌面/Sculptris.desktop" %(newuser , newuser)
        #print(line2)
        os.system(line2)

        # Audacity 設定檔刪除
        line2="sudo rm -fR  %s.%s /home/%s/.audacity-data/ " %(newuser , newuser , newuser )
        print(line2)
        os.system(line2)

 

 

 


站內搜尋