初识linux
时间:2006-09-17 来源:purple_lotuses
1. 修改启动时的默认系统,root下\boot\grub\grub.cnf 将default改为1。
2. linux中大小写有区分。
3. su 有可以使普通用户拥有超级用户的权限。
4. 上箭头可以重复上一个命令。继续上箭头可以重复以前的命令。
5. man 命令名 可以帮助显示命令的功能。q可以退出man命令。
6. find / -name 命令名 可以给出命令所在的路径。find 目录名可查找文件,ctrl+c可停止命令的执行过程。find 目录名 | more 可对目录中的内容分屏查看。
7. fdisk –l 可以查看许同的存储设备。
8. env 可以查看所有的环境变量。包括path路径。
9. export PATH=$ PATH:/sbin 可以将/sbin加入到path中。
10.mount –t vfat –o iocharset=cp936 /dev/hda5 /mnt/floppy是挂载命令。
mount [选项] <挂载设备名称> <挂载点>
umount /mnt/floppy
umount <挂载点或设备名>
11.export PATH=$PATH:/sbin 可以将/sbin加入到path中,可是只是暂时加入,当关掉shell后在从进入时必须重新加入,永久加入的方法是 vi /etc/profile 中将上命令加入,然后重新登陆或执行 source /etc/profile 意思是将/etc/profile中的命令全部执行一遍。
12.exit 可以退出shell;
13.rpm –ivh RPM软件包全路径名 安装软件包
rpm –e RPM软件包全路径名 卸载软件包
rpm –q 查看软件包
rpm –U RPM软件包全路径名 升级软件包
14.ctrl+space切换出输入法,shoft+ctrl更换输入法
15.改变swap大小的方法:
1) choose a location where you have lots of space (/usr comes to mind)
2)create a file the size you want the swap to be:
dd if=/dev/zero of=/usr/swap bs=1024 count=100000
(he above will create a file 100Mb in size, so adjust the count as yousee fit)
/*
Here may be wrong. Comment by baif.
*/
3) run the command: mkswap /usr/swap
4) run the command: swapon /usr/swap
5) check w/ free that you just added 100Mb of swap
6) if you want this to be permanent through reboots, you'll need to add the appropriate line to /etc/fstab
16. ls –ls 查看当前文件夹下文件用户权限及日期
17. pwd 查看当前目录
18.命令名 --help 查看命令的用法,选项等
19.cp [选项] 源文件 目的文件 拷贝文件命令
20 mkdir 目录名 创建目录命令 (在根用户下)
21. rm 删除目录文件
22.编译java程序的方法和Windows下一样,javac test.java //编译 java test//运行
23.编译c程序 gcc(g++)-o test test.c #编译 {#include “stdio.h”
./test #运行 printf();scanf();}
编译c++程序:g++ -o test test.cpp (或.cc) // 编译 {#include <iostream.h>
./test // 运行 cout<<; cin>>;}
.cc是c++源文件,在linux下用的多些,但一般都用.cpp,可编译c++的也可编译c程序,但反之不可。具体程序可参看linux下/home/C(programs)的程序g、f和hellcy!
24. vi下末行模式,:set number可显示程序代码行的行号。
25. scp *.cpp [email protected]:/home/cy/ 将当前目录下所有.cpp 文件远程传输到[email protected]:/home/cy/下
26. #ifconfig 用于查看网络配置信息
27. 按ctrl+alt+f1:可查看内核版本
Red hat linux release 9(shrink)
Kernel 2.4.20-8 on an i686
lks login:
是alt +f7 返回
28.查看内核版本命令:uname -a
29 cp 和rm命令都可用参数 -rf来直接完成命令,不需询问用户。
30.man 命令名 可查看关于命令的介绍 中间可加1、2、3参数,默认为1,表示函数,2为系统调用
31.mv s c 意思为将名为s的文件更名为c
32.set命令是显示当前环境变量的配置路径
33. # ps aux可显示运行进程