本文主要记录了我在工作中用到的一些linux命令
1、查询linux系统是32位还是64位
zhaolei@zhaolei :~# file /usr/bin/whoami
/usr/bin/whoami: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
2、自动登入SSH
zhaolei@zhaolei:~$ ssh-keygen -t rsa
zhaolei@zhaolei:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.100
zhaolei@zhaolei:~$ ssh root@192.168.1.100
3、修改用户登入名
zhaolei@zhaolei:~$ sudo usermod -l flyingzl zhaolei
下次登入后,zhaolei就无法登入了,改用flyingzl登入,登入后的命令行效果如下:
flyingzl@zhaolei:~$ finger flyingzl
Login: flyingzl Name: zhaolei-linux
Directory: /home/zhaolei-linux Shell: /bin/bash
On since Mon Nov 15 16:21 (CST) on tty7 from :0
3 days 16 hours idle
On since Mon Nov 15 16:21 (CST) on pts/0 from :0.0
No mail.
No Plan.
flyingzl@zhaolei:~$
4、MySQL编码修改
修改/etc/mysql/my.cnf文件,在[mysql]和[mysqld]下增加default-character-set utf8
5、任务计划
root@one-desktop:~# crontab -e
root@one-desktop:~# crontab -l
crontab -e 命令表示编辑任务计划,crontab -l 表示显示已有的任务计划,看截图:
解释一下,m表示minute,可选值为0~59;h表示hour,可选值为0~23;dom即Day Of Month,可选值为1~31;month表示月份,可选值为1~12;down即Day Of Week,表示星期几,可选值为0~6,0表示周日;command表示要执行的命令。
根据上面的解释,0 9 * * 1-5 就表示每周一~周五的9点执行命令。
6、提示 NO_PUBKEY 6AF0E1940624A220
输入命令 sudo gpg --keyserver keyserver.ubuntu.com --recv 0624A220 ,然后再sudo apt-get update即可
oot@ubuntu:~# gpg --keyserver keyserver.ubuntu.com --recv 0624A220
gpg: requesting key 0624A220 from hkp server keyserver.ubuntu.com
gpg: key 0624A220: "Launchpad PPA for TualatriX" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
root@ubuntu:~# apt-key list
/etc/apt/trusted.gpg
--------------------
pub 1024D/437D05B5 2004-09-12
uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>
sub 2048g/79164387 2004-09-12
pub 1024D/FBB75451 2004-12-30
uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>
pub 1024R/0624A220 2009-01-19
uid Launchpad PPA for TualatriX
root@ubuntu:~#
7、访问windows共享文件夹
flyingzl@zhaolei:~$ smbclient //10.4.68.14/www -U zhaolei%password
Domain=[PLATFORM] OS=[Windows 7 Ultimate 7600] Server=[Windows 7 Ultimate 6.1]
smb: \> dir
. D 0 Tue Mar 9 09:49:04 2010
.. D 0 Tue Mar 9 09:49:04 2010
phpinfo.php A 65 Wed May 27 08:48:56 2009
phpMyAdmin D 0 Tue Mar 9 09:49:04 2010
ext-3.1.1 D 0 Tue Feb 9 07:22:00 2010
two.html A 712 Thu May 20 16:04:26 2010
dojo-release-1.5.0rc1 D 0 Fri Jun 11 14:26:14 2010
飞秋.exe A 3305472 Sat Feb 20 11:57:52 2010
django-docs D 0 Thu Jun 17 17:14:30 2010
statusnet-0.9.3 D 0 Wed Jun 30 03:09:48 2010
demo.php A 32 Thu Oct 28 14:41:38 2010
hyk-proxy-install_0.9.0.exe A 2146018 Wed Oct 20 20:36:28 2010
charts D 0 Wed Oct 27 09:15:54 2010
demo1.php A 111 Thu Oct 28 14:44:04 2010
HQ.SQL A 1947 Tue Nov 2 14:37:48 2010
ajaxplorer-core-3.1.0 D 0 Mon Nov 15 18:46:14 2010
FusionWidgets_Developer D 0 Mon Jul 19 10:30:32 2010
java-linux.bin A 83790617 Wed Nov 24 18:23:08 2010
49558 blocks of size 524288. 19119 blocks available
smb: \>
也可以直接用命令 smbclient -c "dir" //10.4.68.14/www -U zhaolei%password
8、同步服务器时间
suo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#设置utc为no
sudo vim /etc/default/rcS
sudo ntpdate cn.pool.ntp.org
9、通过apt-get安装sun-jdk
在/etc/apt/sources.list中增加"deb http://archive.canonical.com/ lucid partner",然后apt-get update、apt-get install sun-java6-jdk即可