Linux常用命令(一)

王朝system·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

(1) ln - Create file hard link, or soft link (symbolic link)

hard link:

ln /root/install.log x.hard

soft link:

ln -s /root/install.log x.soft

(2) shutdown - reboot the system

reboot the system now:

shutdown -r now

(3) pwd - show current working directory

(4) cd - change directory

(5) mkdir - make directory

(6) rmdir - remove directory

(7) ls - list files

list all files:

ls -al

(8) more - viewing files

view a file:

more a.txt

(9) cat - viewing files or concatenate files into one

view a file:

cat a.txt

(10) kill - raise a signal to a process

terminate a process:

kill -9 1447 (process id)

or

kill -9 %1 (sequence id)

(11) logout - login out of the system

(12) vi - text editor

(13) emacs - powerful editor & compiler

(14) cp - copy files

copy a to b:

cp a b

(15) mv - remove files

remove file:

rm a.txt

(16) echo - show information

show value of $PATH:

echo $PATH

(17) chsh - change shell

(18) who - show current users in memory

(19) date - show date and time

(20) export - create a enviroment variable

set enviroment variable:

export JM=ls

echo $JM

$JM

another way is simple:

JM=ls

(21) > - redirection to a file

save output to file:

cat a b c > d

(22) >> - append output to a file

append output to file:

cat a b c >> d

(23) & - background process operation

put work background:

gcc invinitjig.c &

(24) ps - show processes in memory

(25) fg - bring background processes forehead

(26) 1 and 2 usage - 1 stands for standard output, and 2 for standard error output

save error output:

cat notexistfile 2> err_file

save standard output:

cat existfile 1> out_file

(27) /dev/null - throw away output

throw away all output:

cat abc > /dev/null

(28) sort - sort strings

(29) du - stands for "disk usage" and shows how many blocks each file occupies under the current directory

(30) | - pipeline

(31) man - manual book

see manual of ls:

man ls

(32) info - read info doucments, stronger than man command

see info of grep:

info grep

(33) r/w/x - ownership of files: read / write / execute, left to right: owner/group/others

(34) chown - change owner of files

change owner:

chown jm filename

(35) chgrp - change group of files

(36) chmod - change file access mode

set r/w/x permission to all (owner/group/others):

chmod +x a.exe

chmod +r a.exe

chmod +w a.exe

chmod -x a.exe

chmod -r a.exe

chmod -w a.exe

specify the owner/group/others:

chmod u+r a.exe

chmod ug+r a.exe

(37) su - run a shell with substitute user and group IDs

(38) history - command history

(39) dd - Copy a file, converting and formatting according to the options

(40) alias - make alias name

eg.

alias x="ls"

x

(41) mount - 挂载分区或镜像文件(.iso,.img)文件。

用法:

磁盘分区:mount deviceName mountPoint -o options,其中deviceName是磁盘分区的设备名,比如/dev/hda1,/dev/cdrom,/dev/fd0,mountPoint是挂载点,它是一个目录,options是参数,如果分区是linux分区,一般不用-o options,如果是windows分区那options可以是iocharset=cp936,这样windows分区里的中文文件名就能显示出来了。

用例:比如/dev/hda5是linux分区,我要把它挂到目录a上(如没目录a那就先mkdir a),mount /dev/hda5 a,这样目录a里的东西就是分区hda5里的东西了,比如hda1是windows分区,要把它挂到b上,mount /dev/hda1 b -o iocharset=cp936。

镜像文件:

mount fileName mountPoint -o loop,fileName是镜像文件名(*.iso,*.img),其它的不用说了,跟上面一样。

用例:如我有一个a.iso光盘镜像文件,mount a.iso a -o loop,这样进入目录a你就能浏览a.iso的内容了,*.img文件的用法一样。

(42) find - 查找文件。

用法:

find inDir -name filename,inDir是你要在哪个目录找,filename是你要找的文件名(可以用通配符),用通配符时filename做好用单引号引起来,否则有时会出错,

用例:find . -name test*,在当前目录查找以test开头的文件。

(43) grep - 在文件里查找指定的字符串。

用法:

grep string filename,在filename(可用通配符)里查找string(最好用双引号引起来)。参数:-r在所有子目录里的filename里找。

用例:grep hello *.c -r在当前目录下(包括子目录)的所有.c文件里查找hello。

(44) tar - pack or unpack files

(45) netconfig - network configuration

(46) rpm - install softwares

(47) rdev - query/set image root device, RAM disk size, or video mode

(48) passwd - change password

(49) adduser - add a user

(50) userdel - delete a user

(51) umount - reverse to mount

(52) mkfs - build a Linux file system

(53) fsck - check and repair a Linux file system

(54) free - display information about free and used memory on the system

(55) makeswap - make swap

(56) swapon - swap on

(57) swapoff - swap off

(58) mknod - make block or character special files

(59) gzip - pack / unpack files

(60) crontab - scheduling jobs

(61) setterm - set terminal attributes

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航