本文來自個人博客 sunyongfeng.com。博客的文章保持更新,此文可能不是最新狀態。
Linux開發環境常用配置記錄,含遠程登錄、文件共享、串口訪問與共享、交叉編譯器、終端等內容。
遠程登錄windows
remmina
安裝包:
remmina
remmina-plugin-rdp
配置:
- Protocol,選擇“RDP - Remote Desktop Protocol”
- Basic標籤
- Server,windows的IP
- User name
- Password
- Advanced標籤
- Security,選擇“Negotiate”
- SSH標籤
- 去掉Enable SSH tunnel
freerdp
本人傾向使用freerdp,簡單易用。
安裝包:freerdp
。
命令:(將username / password / 1.1.1.1替換成自己的內容)
xfreerdp -u username -p "password" -g 1024x768 -x l --plugin cliprdr --plugin rdpsnd 1.1.1.1
因爲版本不同,可能命令參數不一樣:
xfreerdp --sec rdp -u username -p "password" -g 1440x790 -x l --plugin cliprdr --plugin rdpsnd 1.1.1.1
跨系統拷貝粘貼失敗問題
注意,windows 7有bug,導致clipboard有問題。即windows與Linux的copy、paste無法共用。解決方法見鏈接,其中mike 1504的做法,通過任務管理器殺掉rdpclip.exe再重啓rdpclip.exe進程規避本問題。
This is an old problem. It has been around since pre2004, and microsoft is well aware of it. The cause is tied to MS Office as well as the OS. It usually occurs during Remote desktop sessions, and the problem is on the remote machine. The best solution I have found is to pull up task man, end the process rdpclip.exe, and then restart it by first changing focus from task manager to another program and back to task manager, choose file>new task (run) and then typing in rdpclip.exe and hit enter. The remote clip service will restart, and usually the copy you wanted to paste immediately becomes available.
If you fail to change focus from Task Manager to another program and back you may find the remote session locks up. If so, don't panic, simply end the remote session and begin a new one.In case you don't know how to access task manager on the remote machine (CTRL ALT DELETE is always to the local machine), simply right click on the task bar and choose it from the context menu.
I would have thought by win7 this would have been fixed, but I am running Win7 enterprise trial right now and having the problem there.
ssh遠程登錄Linux
安裝包:openssl-server
客戶端登錄:ssh username@hostIP
串口
PAC Manager
安裝包:
- PAC Manager,不在Ubuntu倉庫中,Sourceforge鏈接。
cu
需要把/dev/ttyUSB0的用戶切換成cu的uucp才能被cu使用。
使用cu時需要用sudo
還沒有明白remote-tty怎麼用。
kermit
安裝包:
ckermit
-
lrzsz
,用於xmodem傳輸
不改權限的話,只有用超級用戶才能正常用kermit訪問串口。
sudo kermit
set line /dev/ttyUSB0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set receive packet-length 9024
set send packekt-length 9024
set protocol xmodem
在ckermit命令提示符下:
- connect,連接串口;
- ?,查看所有命令,前面的配置命令在此都可以看到;
- send /path/to/file,傳輸文件,支持相對路徑;
- 在串口控制檯下,通過ctrl + \,再敲c,返回ckermit控制檯。
Ser2net
共享串口(SerialPort),提供telnet服務。
配置文件/etc/ser2net.conf
,類似下面的配置依葫蘆畫瓢就可以了。
- 2001,端口號
- telnet,用telnet訪問串口
- /dev/ttyUSB1,表示實際串口
- 9600,波特率
- 8DATABITS NONE 1STOPBIT,常見的8N1
- 600,port timeout,如果在超時時間間隔內沒有對串口進行任何操作,ser2net會自動退出。
可以將所有的波特率的配置都添加進去,注意使用不同的端口號。
2001:telnet:600:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT -XONXOFF -RTSCTS banner
3001:telnet:600:/dev/ttyUSB1:115200 8DATABITS NONE 1STOPBIT -XONXOFF -RTSCTS banner
Windows下,可使用Comfoolery
共享串口,功能更加強大。
wine連接不上串口
來源鏈接。
步驟:
- 映射/dev/ttyUSB0成windows中的概念com1
ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com1
- 查看/dev/ttyUSB0的用戶組,如下,用戶組爲dialout
ls -l /dev/ttyUSB0
crw-rw---T 1 root dialout 4, 6 Nov 18 20:34 ttyUSB0
- 將當前用戶加入用戶組dialout
sudo vi /etc/group
修改
dialout:x:20:
爲
dialout:x:20:your_user_name
文件共享
samba
安裝包:samba
配置:
- 修改配置文件
/etc/samba/smb.conf
,確認要共享的目錄。sudo service samba restart
生效。配置樣例如下。 - 創建samba用戶:
sudo smbpasswd -a user_name
,user_name填成自己想要的名稱。
[linuxMint]
comment = linux
path = /home/sunyongfeng/
writeable = yes
valid users = sunyongfeng
其中,linuxMint是共享目錄顯示給使用者的名稱。path是實際共享的目錄,valid users是合法的用戶。
windows 7 如何清除自動登錄的憑據
控制面板
-> 用戶賬戶
-> 管理您的憑據
,然後單擊要清除的那個憑據,點擊從保管庫中刪除
,重啓生效。
解決Ubuntu用戶名變動後,無法從win7 登錄 samba。
Linux 訪問 Windows 共享目錄
- 在 windows 設置好共享目錄;
- 使用
smbclient
訪問共享目錄(可測試共享目錄是否可用):smbclient //IP/share_dir -U your_username
; - 掛載共享目錄到 linux:
sudo mount -t cifs -o username=your_username,password=your_passwd //IP/share_dir /mnt
- 亦可直接在文件管理器中直接輸入
smb://IP
,按提示輸入用戶名密碼,即可從 Linux 文件管理器中直接查看 windows 的共享目錄。
-
smbclient
訪問 log:
sunyongfeng@sunnogo:~$ smbclient //IP/share_dir -U your_name
Enter oa's password:
Domain=[sunnogo] OS=[Windows 7 Ultimate 7601 Service Pack 1] Server=[Windows 7 Ultimate 6.1]
smb: \> ls
. D 0 Thu Mar 10 19:24:05 2016
.. D 0 Thu Mar 10 19:24:05 2016
asic D 0 Thu Mar 10 18:58:41 2016
linux D 0 Thu Mar 10 18:58:43 2016
python D 0 Thu Mar 10 18:59:04 2016
工具 D 0 Thu Mar 10 19:06:10 2016
項目 D 0 Thu Mar 10 20:08:25 2016
40960 blocks of size 4194304. 33262 blocks available
smb: \>
-
mount
掛載 log:
sunyongfeng@sunnogo:~$ sudo mount -t cifs -o username=your_username,password=your_passwd //IP/share_dir /mnt
sunyongfeng@sunnogo:~$ ls -al /mnt/
總用量 3244
drwxr-xr-x 2 root root 4096 3月 10 19:24 .
drwxr-xr-x 3 root root 4096 3月 11 09:35 ..
drwxr-xr-x 2 root root 0 3月 10 18:58 linux
drwxr-xr-x 2 root root 0 3月 10 18:59 python
drwxr-xr-x 2 root root 0 3月 10 19:06 工具
drwxr-xr-x 2 root root 0 3月 10 20:08 項目
tftp
安裝包:tftpd-hpa
配置:
- 修改配置文件
/etc/default/tftpd-hpa
,樣例如下。 - 需要
chmod 777 /home/sunyongfeng/tftpboot
,否則可能出現權限問題,TFTP error: 'Permission denied' (0)
。tftpboot爲tftp共享的主目錄。
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
#TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_DIRECTORY="/home/sunyongfeng/tftpboot"
TFTP_ADDRESS="[::]:69"
#TFTP_OPTIONS="--secure"
TFTP_OPTIONS="-l -c -s"
異常:
- 如果一直timeout,可能是網卡出問題了,
sudo service networking restart
,或者重啓電腦。 - 有時不清楚爲何啓機之後,tftpd-hpa在,但是tftp無法下載。
sudo service tftpd-hpa restart
可解決此問題。沒有看系統log細究原因。
atftpd
另一款tftp服務器。
安裝包:atftpd
配置:
- 修改
/etc/default/atftpd
,樣例如下。 - 把
/etc/inet.conf
中的tftp註釋掉,不然會出現“atftpd: cannot bind port: 69/udp"。
限制:最大文件有限制,32M。
#/etc/default/atftpd
USE_INETD=false
OPTIONS="--tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=7 /home/sunyongfeng/tftpboot"
安裝linaro gcc交叉編譯器
sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabi
終端(Terminal)
guake
fbterm
screen
script
啓機進入命令行
/etc/default/grub
, change this line
RUB_CMDLINE_LINUX_DEFAULT="splash quiet"
to
GRUB_CMDLINE_LINUX_DEFAULT="text"
Runsudo update-grub
when done. This is easily reversed too if you need to change back.