2017年12月

ubuntu samba 服务器配置

1. 检查windows所在的工作站域

windows若想通过samba服务器访问linux,必须和samba上配置的工作站域一致,默认都用WORKGROUP

2. 添加本地域名以便于访问

追加hosts文件:192.168.1.111    ubuntu.com    ubuntu

3. 建立匿名访问

  • 修改/etc/samba/smb.conf配置

    [global]
    workgroup = WORKGROUP
    server string = Samba Server %v
    netbios name = ubuntu
    security = user
    map to guest = bad user
    dns proxy = no

    [Anonymous]
    path = /samba/anonymous
    browsable =yes
    writable = yes
    guest ok = yes
    read only = no

  • 建立匿名访问根目录

    mkdir -p /samba/anonymous
    chmod -R 0777 /samba/anonymous
    chown -R nobody:nogroup /samba/anonymous

4. 建立安全访问

  • 追加/etc/samba/smb.conf配置

    [secured]
    path = /samba/secured
    valid users = @smbgrp
    guest ok = no
    writable = yes
    browsable = yes

  • 建立安全访问根目录

    addgroup smbgrp
    adduser smbusr -G smbgrp //若命令失败,可用 -g group_id
    smbpasswd -a smbusr
    mkdir -p /samba/secured
    chmod -R 0750 /samba/secured
    chown -R smbusr:smbgrp /samba/secured

5. 重启samba服务器

service smbd restart

6. 验证

在windows地址栏输入:\\ubuntu,可在anonymous和secured文件夹进行读写操作

git 推送本地版本库到 github

1. 在github上建repository
先注册github账号,假设账号名zhangsan,repository名test

2. 配置git用户名和email
git config --global user.name "zhangsan"
git config --global user.email "zhangsan@163.com"

3. cd 到工程根目录,执行以下命令
git init .
git add .
git commit -m "first create"
git remote add origin https://github.com/zhangsan/test.git
git pull origin master
git push -u origin master

ubuntu 配置静态 ip

1. 修改/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.154
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 192.168.1.1

2. 重启网卡
/etc/init.d/networking restart