linux 学习笔记

Posted 12 months ago at 9:00 am. 0 comments

限制 ssh root 登录和尝试次数

vi /etc/ssh/sshd_config

# #LoginGraceTime 2m
# PermitRootLogin no
# #StrictModes yes
# MaxAuthTries 4

解压 .7z 文件

sudo apt-get install p7zip
p7zip -d putyourfilename.7z

-d : decompress

mysql 备份

mysqldump -u user -p [database] > database.sql

Securing your PHP with Suhosin

1) Grab Suhosin source from the web

user#wget -c http://download.suhosin.org/suhosin-0.9.27.tgz

2) Extract and compile

user#tar xzvf suhosin-0.9.27.tgz

user#cd suhosin-0.9.27

user#phpize

user#./configure

user#make

user#make install

3) Now add extension module in php.ini configuration

user#vi /etc/php.ini

extension=suhosin.so

4) Restart your web server

user#service httpd restart

5) Check your php version to indicates that Suhosin is there

user#php -v
PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

scp 比 ftp 安全

scp file.txt user@domain.com:/home/user

什么是 Maemo

Posted 1 year, 10 months ago at 3:23 am. 0 comments

诺基亚的开源linux平台。

Maemo is an open source development platform to create applications for Nokia Internet Tablet products like Nokia N800 and Nokia 770. The platform gives developers a powerful Linux based development environment and optimized end-user interface for handhelds.

linux shell 技巧

Posted 1 year, 11 months ago at 2:44 am. 0 comments

apropos ls

显示 ls 的相关信息

man -t ls | ps2pdf -> ls.pdf

输出 ls 手册为 postscript 然后转成 pdf

which ls

显示 ls 的完整路径

time ls 执行 ls 然后输出执行的时间

alias l=’ls -l’

定义 ls 别名,l 即可执行 ls -l 命令

cd -

回到刚才的目录

cd

进入 home 目录(等同于 cd ~)

cd 目录 && ls -l

进入“目录”,执行 ls -l 命令,然后返回当前目录

find -type f ! -perm -444

查找所有权限 444 以下的文件(不可读)

ls | pr -T9

9列显示

look fire

快速搜索字典中 fire 开头的单词

grep –color fire /usr/share/dict/words

在字典中高亮显示包含 fire 的单词

gpg -c file
gpg file.gpg

加(解)密文件

dd bs=1M if=/dev/sda | gzip | ssh user@remote ‘dd of=sda.gz’

备份硬盘数据到远程 ssh 主机

ssh -f -Y USER@HOSTNAME firefox

以 USER 身份登录 HOSTNAME 主机打开 GUI 程序(firefox)

wget -r -nd -np -l1 -A ‘*.jpg’ http://www.example.com/dir/

下载 http://www.example.com/dir/ 目录中的所有 jpg 图片(如果服务器允许目录浏览的话,否则返回 403 forbidden 错误)

wget –limit-rate=20k http://111.com

限制 wget 下载速度 20k/s

smbtree

寻找局域网中的 windows 主机

nmblookup -A 192.168.100.1

解析目标机器的 NetBIOS 名、组等

smbclient -L 192.168.100.97

查看 windows 主机的共享目录

mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share

挂接windows共享目录

飞鸽传书 ipmsg GTK2版(转)

Posted 2 years, 1 month ago at 11:32 am. 0 comments

以下全文来自 http://www.herofit.cn/2007/03/20_168

ipmsg(译名:飞鸽传书)是局域网内的文件传输工具。它是免费的,开源的,在GPL协议下发布。它有windows,linux,Mac,java等不同平台或语言的版本。

下面我来说一下它的GTK2版在ubuntu dapper下的安装过程。

安装依赖的包

sudo apt-get install libxml-parser-perl libgnomeui-dev libpanel-applet2-dev

下载

wget http://www.ipmsg.org/archive/g2ipmsg-0.9.1.tar.gz

更改语言(不改则为日语)

将g2ipmsg-0.9.1/src/codeset.c中的CP932 改为CP936

配置

./configure –prefix=/usr –sysconfdir=/etc –enable-systray

编译

make

安装

sudo make install

使用

将G2IPMSG Applet小程序添加到你的面板上。

效果如图:

g2ipmsg.png

参考资料:

http://www.ipmsg.org

让gaim发声
Filed under: linux, 软件 — ahlongxp @ 22:00

以前以为gaim发声是它本身的事,今天仔细看了一下发现,gaim还可以利用系统中的程序进行发声。

sudo apt-get install alsaplayer

alsaplayer是alsa驱动的命令行的播放录音工具,可用于多个用途。现代linux一般都用alsa,所以它是最好的选择了。

装完后就有了播音工具aplay,录音工具arecord。让gaim发声用aplay就可以了。

主界面中按Ctrl+P, 选Sounds。

将Method选成command,Sound command填成/usr/bin/aplay %s。其它的可随意设置。

注意,此时的Test是无效的,要看效果请重启gaim。

gaim不再哑巴了吧!

LinuxMCE

Posted 2 years, 1 month ago at 11:32 am. 0 comments

ubuntu 下的媒体波方中心。官方站点下载太慢

LinuxMCE installer: http://www.neversfw.com/linux/mce-in…0.0-1_i386.deb
ISO Mirror 1: http://www.neversfw.com/linux/linuxMCE.iso
ISO Mirror 2: http://www.robogoat.com/rampage/linuxmce/linuxMCE.iso
Torrent File: http://torrents.thepiratebay.org/364…55.TPB.torrent

更多下载地址:

http://wiki.linuxmce.com/index.php/Mirrors

用 azureus 下载的时候,老是异常退出,报告java错误

An unexpected error has been detected by HotSpot Virtual Machine

重新选择 java 环境即可。

sudo update-alternatives –config java

选gij

linux shell diary

Posted 2 years, 1 month ago at 11:32 am. 0 comments

sure,my ubuntu feisty amd64 is all ok now.though i have no scim to input chinese.But everything is ok include sound,updating and touring the web…

uname -a
Linux guoshuang-laptop 2.6.20-12-generic #2 SMP Wed Mar 21 19:34:23 UTC 2007 x86_64 GNU/Linux

rocinfo — Display system status gathered from /proc folder
Summary:
procinfo gathers system data from the /proc directory and prints it nicely formatted on the standard output device.
Example:
$ procinfo — Show MEM,CPU Usage and IRQ details.
$ procinfo -f — Run in Full screen mode and update will happen for every 5 Sec.
$ procinfo -n.1 — Run in […]

ssh,vnc 反向连接

Posted 2 years, 1 month ago at 11:32 am. 0 comments

反向连接不需要网关映射,因此不需要惊动网管大人,这样我就可以从家里(ADSL)连接控制单位局域网中的我的机器…
嘿嘿…坏处就是,两头都要有人…
感谢 pal(小时)蹲在我家里帮忙测试。

ssh 反向连接

如果没有安装 ssh的话,安装之

sudo apt-get install ssh

被控端,执行

ssh -f -N -R 10000:localhost:22 guoshuang@xxx.xxx.xxx.xxx

控制端执行
ssh guoshuang@localhost -p 10000

参考此文

vnc 反向连接

其实只要网关(防火墙)没有关掉 5500 就可以。注意:是5500能出去即可,不是进来,所以一般都是开放的。

sudo apt-get install x11vnc

控制端执行下面命令,等待邀请

vncviewer -listen

被控端,主动发起邀请

x11vnc -connect xxx.xxx.xxx.xxx:5500

参考此文

windows 和 mac 下的软件可参考下文

Free and easy remote access (through firewalls and NAT routers) with VNC reverse connections
内网远程控制全攻略

注意:vncviewer -fullscreen 模式全屏连接 vnc,用 f8 或者 ctrl+esc esc 退出。即便如此,也会经常出现不能退出或者控制失灵的情况,这篇 patch: fix WM bindings for vncviewer -fullscreen 应该有些帮助

或者使用 xvnc4viewer(sudo apt-get install xvnc4viewer)而不是tightvnc viewer。

f8 和窗口控制都没问题。

linux shell 快捷方式

Posted 2 years, 1 month ago at 11:32 am. 0 comments

原文来自 Bash Shell Keyboard Shortcuts For Linux Users,大部分快捷方式我以前一无所知…

# Ctrl + A – Go to the beginning of the line you are currently typing on
# Ctrl + E – Go to the end of the line you are currently typing on
切到命令行开始|结尾

# Ctrl + L – Clears the Screen, similar to the clear command
清屏,类似于 clear 命令

# Ctrl + U – Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
清除光标以前

# Ctrl + H – Same as backspace
退格键 backspace

# Ctrl + R – Let’s you search through previously used commands
从命令历史中找

# Ctrl + C – Kill whatever you are running
终止命令

# Ctrl + D – Exit the current shell
退出 shell

# Ctrl + Z – Puts whatever you are running into a suspended background process. fg restores it.
??

# Ctrl + W – Delete the word before the cursor
清除光标之前

# Ctrl + K – Clear the line after the cursor
清除光标之后

# Ctrl + T – Swap the last two characters before the cursor
# Esc + T – Swap the last two words before the cursor
切换光标前最后两个字母(单词)

# Alt + F – Move cursor forward one word on the current line
# Alt + B – Move cursor backward one word on the current line
??在 ubuntu x windows终端中会切换到菜单!tty 可能可以

# Tab – Auto-complete files and folder names
自动补全

# Ctrl + Y – to paste it (as in delete and copy) all text in front of the cursor
粘贴(刚才 ctrl+w 或者 ctrl+k 的内容)

# Esc + . (or Esc + Underscore) – Insert Last Argument
??

# Ctrl + b – Move back a character
# Ctrl + f – Move forward a character
向前|后移动一个字母

# Ctrl + r – Search the history backwards
??
# Ctrl + xx – Move between EOL and current cursor position
光标在当前位置和 EOL 之间切换(EOL end of line?但我实验,是在开头和当前位置之间切换,怎么理解?谁知道?)

# Ctrl + x @ – Show possible hostname completions

# Alt +
# Alt + > – Move to the last line in the history

# Alt + ? – Show current completion list

# Alt + * – Insert all possible completions

# Alt + / – Attempt to complete filename

# Alt + . – Yank last argument to previous command

# Alt + c – Capitalize the word

# Alt + d – Delete word

# Alt + l – Make word lowercase

# Alt + n – Search the history forwards non-incremental

# Alt + p – Search the history backwards non-incremental

# Alt + r – Recall command

# Alt + t – Move words around

# Alt + u – Make word uppercase

# Alt + back-space – Delete backward from cursor

# Here “2T” means Press TAB twice

# $ 2T – All available commands(common)

# $ (string) 2T – All available commands starting with (string)

# $ /2T – Entire directory structure including Hidden one

# $ 2T – Only Sub Dirs inside including Hidden one

# $ *2T – Only Sub Dirs inside without Hidden one

# $ ~2T – All Present Users on system from “/etc/passwd”

# $ $2T – All Sys variables

# $ @2T – Entries from “/etc/hosts”

# $ =2T – Output like ls or dir

rdesktop – ubuntu 连接远程 windows xp

Posted 2 years, 1 month ago at 11:32 am. 1 comment

sudo apt-get install rdesktop
rdesktop 192.168.100.x

-f 全屏
-a 16位色
端口 3389(linux 22 sh)
注意:windows 的服务中的 Terminal Servies 需要开启。我的电脑 右键 属性 远程中,勾选 允许远程用户链接到此计算机。另外,退出的时候选择注销,而不是关机!

问题有二:
1.windows xp 必须打开 允许远程用户登录
2.很奇怪,我的 guoshuang 登录时,会提示踢掉已经登录的用户(据查,xp sp2 以后不能同时登录)
3.我的 windows 2003 允许远程用户登录 灰色不可选!

更多参数:

-u xxxxxx 登录用户,可选
-p xxxxxx 登录密码,可选
-r clipboard:PRIMARYCLIPBOARD 重要,剪贴板可以与远程桌面交互
-a 16 颜色,可选,不过最高就是16位
-z 压缩,可选
-g 1024×768 分辨率,可选,缺省是一种比当前本地桌面低的分辨率
-P 缓冲,可选
-r disk:wj=/home/magicgod 映射虚拟盘,可选,会在远程机器的网上邻居里虚拟出一个映射盘,功能很强,甚至可以是软盘或光盘
-r sound:off 关闭声音,当然也可以把远程发的声音映射到本地来。

重定向:

这时才发现它原来也可以将本地磁盘带到远端,而且连中文文件名也支持。只要加上 -r 参数就可以了。它除了可以将本地磁盘带到远端以外,还支持串口和打印机,这下 Windows 上远程桌面客户端的功能在 Linux 上都齐了。-r 参数的格式如下:
-r comport:COM1=/dev/ttyS0 // 将串口 /dev/ttyS0 重定向为 COM1
-r comport:COM1=/dev/ttyS0,COM2=/dev/ttyS1 // 多个串口重定向
-r disk:floppy=/mnt/floppy // 将 /mnt/floppy 重定向为远程共享磁盘 ‘floppy’
-r disk:floppy=/mnt/floppy,cdrom=/mnt/cdrom,root=/,c=/mnt/c // 多个磁盘重定向
-r clientname= // 为重定向的磁盘设置显示的客户端名称
-r lptport:LPT1=/dev/lp0 // 将并口 /dev/lp0 重定向为 LPT1
-r lptport:LPT1=/dev/lp0,LPT2=/dev/lp1 // 多个并口重定向
-r printer:mydeskjet // 打印机重定向
-r printer:mydeskjet=”HP LaserJet IIIP” // 打印机重定向
-r sound:[local|off|remote] // 声音重定向

ubuntu portal

Posted 2 years, 1 month ago at 11:32 am. 0 comments

Questions and answers
ubuntu documents
ubuntu wiki
ubuntu planet
ubuntu weeklynews
ubuntu 版本

Locale support – Chinese

IRC: #ubuntu-zh on irc.freenode.net
Mailing list: http://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
Website: ubuntu.org.cn
Forums: forum.ubuntu.org.cn
Wiki Documentation: wiki.ubuntu.org.cn

ad 468x60