centos 常用命令
系统常用命令
systemctl 系统启动软件命令
disable 禁止启动
enable 开机启动
start 启动
restart 重启
status 查看状态
ps aux | grep (进程名) 查看进程
su- 切换到root权限
shutdown -h now 关机
shutdown -r now 重启
top 罗列出使用cup资源最多的任务 (q退出)
pstree 以树状图显示程序
man (程序名) 查询程序手册
passwd 修改密码
df -h 显示磁盘使用情况
firewalld.service 系统防火墙
文件与目录操作
cd 进入目录 要加/
cd .. 返回上一级目录
cd ../.. 返回上两级目录
cd - 返回上次所在目录
cp file1 file2 复制文件
cp -a dir1 dir2 复制目录
cp -a /tmp/dir1 . 复制一个目录到当前目录
ls 显示所有文件
ls -a 显示隐藏文件
ls -l 显示详细信息
ls -lrt 按时间显示文件(l便是详细列表,r表示反向排序,t便是时间排序)
pwd 显示当前工作路径
mkdir 创建目录 (多个目录空格隔开)
mkdir -p /tem/a/p 创建一个目录树
mv dir1 dir2 移动/重命名一个目录
rm -f 删除目录
rm -rf 删除目录及其子目录
查看文件内容
cat 从第一个字节开始查看文件内容
head -行数 fiel1 查看文件前两行
more file 查看一个长文件的内容
tac 从文件最后一行开始查看 -行数 倒数几行查看文件
文本内容处理
grep str /temp/test 在指定目录中的文件查找str
grep ^str /temp/test 在指定目录中的文件查找以str 开始的行
grep [0-9] /tmp/test 查找 ‘/tmp/test’ 文件中所有包含数字的行
grep str -r /tmp/* 在目录 ‘/tmp’ 及其子目录中查找 “str”
diff file1 file2 找出两个文件的不同处
sdiff file1 file2 以对比的方式显示两个文件的不同
vi 操作命令
操作 解析
i 进入编辑文本模式
Esc 退出编辑文本模式
:w 保存当前修改
:q 不保存退出vi
:wq 保存当前修改并退出vi
查询操作
find / -name file1 从 ‘/’ 开始进入根文件系统查找文件和目录
find / -user user1 查找属于用户 ‘user1’ 的文件和目录
find /home/user1 -name *.bin 在目录 ‘/ home/user1’ 中查找以 ‘.bin’ 结尾的文件
find /usr/bin -type f -atime +100 查找在过去100天内未被使用过的执行文件
find /usr/bin -type f -mtime -10 查找在10天内被创建或者修改过的文件
locate *.ps 寻找以 ‘.ps’ 结尾的文件,先运行 ‘updatedb’ 命令
find -name ‘*.[ch]’ | xargs grep -E ‘expr’ 在当前目录及其子目录所有.c和.h文件中查找 ‘expr’
find -type f -print0 | xargs -r0 grep -F ‘expr’ 在当前目录及其子目录的常规文件中查找 ‘expr’
find -maxdepth 1 -type f | xargs grep -F ‘expr’ 在当前目录中查找 ‘expr’
压缩、解压
bzip2 file1 压缩 file1
bunzip2 file1.bz2 解压 file1.bz2
gzip file1 压缩 file1
gzip -9 file1 最大程度压缩 file1
gunzip file1.gz 解压 file1.gz
tar -cvf archive.tar file1 把file1打包成 archive.tar(-c: 建立压缩档案;-v: 显示所有过程;-f: 使用档案名字,是必须的,是最后一个参数)
tar -cvf archive.tar file1 dir1 把 file1,dir1 打包成 archive.tar
tar -tf archive.tar 显示一个包中的内容
tar -xvf archive.tar 释放一个包
tar -xvf archive.tar -C /tmp 把压缩包释放到 /tmp目录下
zip file1.zip file1 创建一个zip格式的压缩包
zip -r file1.zip file1 dir1 把文件和目录压缩成一个zip格式的压缩包
unzip file1.zip 解压一个zip格式的压缩包到当前目录
unzip test.zip -d /tmp/ 解压一个zip格式的压缩包到 /tmp 目录
yum 安装器
yum -y install [package] 下载并安装一个rpm包
yum localinstall [package.rpm] 安装一个rpm包,使用你自己的软件仓库解决所有依赖关系
yum -y update 更新当前系统中安装的所有rpm包
yum update [package] 更新一个rpm包
yum remove [package] 删除一个rpm包
yum list 列出当前系统中安装的所有包
yum search [package] 在rpm仓库中搜寻软件包
yum clean [package] 清除缓存目录(/var/cache/yum)下的软件包
yum clean headers 删除所有头文件
yum clean all 删除所有缓存的包和头文件
网络相关
ifconfig eth0 显示一个以太网卡的配置
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 配置网卡的IP地址
ifdown eth0 禁用 ‘eth0’ 网络设备
ifup eth0 启用 ‘eth0’ 网络设备
iwconfig eth1 显示一个无线网卡的配置
iwlist scan 显示无线网络
ip addr show 显示网卡的IP地址
命令缩写
pwd: print work directory 打印当前目录 显示出当前工作目录的绝对路径
ps: process status(进程状态,类似于windows的任务管理器)
常用参数:-auxf
ps -auxf 显示进程状态
df: disk free 其功能是显示磁盘可用空间数目信息及空间结点信息。换句话说,就是报告在任何安装的设备或目录中,还剩多少自由的空间。
du: Disk usage
rpm:即RedHat Package Management,是RedHat的发明之一
rmdir:Remove Directory(删除目录)
rm:Remove(删除目录或文件)
cat: concatenate 连锁
cat file1file2>>file3 把文件1和文件2的内容联合起来放到file3中
insmod: install module,载入模块
ln -s : link -soft 创建一个软链接,相当于创建一个快捷方式
mkdir:Make Directory(创建目录)
touch: touch
man: Manual
su:Swith user(切换用户)
cd:Change directory
ls:List files
ps:Process Status
mkdir:Make directory
rmdir:Remove directory
mkfs: Make file system
fsck:File system check
uname: Unix name
lsmod: List modules
mv: Move file
rm: Remove file
cp: Copy file
ln: Link files
fg: Foreground
bg: Background
chown: Change owner
chgrp: Change group
chmod: Change mode
umount: Unmount
dd: 本来应根据其功能描述"Convert an copy"命名为"cc",但"cc"已经被用以代表"CComplier",所以命名为"dd"
tar:Tape archive (磁带档案)
ldd:List dynamic dependencies
insmod:Install module
rmmod:Remove module
lsmod:List module
文件结尾的"rc"(如.bashrc、.xinitrc等):Resource configuration
Knnxxx /Snnxxx(位于rcx.d目录下):K(Kill);S(Service);nn(执行顺序号);xxx(服务标识)
.a(扩展名a):Archive,static library
.so(扩展名so):Shared object,dynamically linked library
.o(扩展名o):Object file,complied result of C/C++ source file
RPM:Red hat package manager
dpkg:Debian package manager
apt:Advanced package tool(Debian或基于Debian的发行版中提供)
其他命令缩写
bin = Binaries (二进制文件)
/dev = Devices (设备)
/etc = Etcetera (等等)
/lib = LIBrary
/proc = Processes
/sbin = Superuser Binaries (超级用户的二进制文件)
/tmp = Temporary (临时)
/usr = Unix Shared Resources
/var = Variable (变量)
FIFO = First In, First Out
GRUB = GRand Unified Bootloader
IFS= Internal Field Seperators
LILO = LInux LOader
MySQL = My 是最初作者女儿的名字,
SQL = Structured QueryLanguage
PHP = Personal Home Page Tools = PHP HypertextPreprocessor
PS = Prompt String
Perl = “Pratical Extraction and Report Language”(实际的抽取和报告语言) =”Pathologically Eclectic Rubbish Lister”
Python 得名于电视剧Monty Python’s Flying Circus
Tcl = Tool Command Language
Tk = ToolKit
VT = Video Terminal
YaST = Yet Another Setup Tool
apache = “a patchy” server
apt = Advanced Packaging Tool
ar = archiver
as = assembler
awk = “Aho Weiberger and Kernighan”三个作者的姓的第一个字母
bash = Bourne Again SHell
bc = Basic (Better) Calculator
bg = BackGround
biff = 作者HeidiStettner在U.C.Berkely养的一条狗,喜欢对邮递员汪汪叫。
cal = Calendar (日历)
cat = Catenate (链接)
cd = Change Directory
chgrp = Change Group
chmod = Change Mode
chown = Change Owner
chsh = Change Shell
cmp = compare
cobra = Common Object Request BrokerArchitecture
comm = common
cp = Copy
cpio = CoPy In and Out
cpp = C Pre Processor
cron = Chronos 希腊文时间
cups = Common Unix Printing System
cvs = Current Version System
daemon = Disk And Execution MONitor
dc = Desk Calculator
dd = Disk Dump (磁盘转储)
df = Disk Free
diff = Difference
dmesg = diagnostic message
du = Disk Usage
ed = editor
egrep = Extended GREP
elf = Extensible Linking Format
elm = ELectronic Mail
emacs = Editor MACroS
eval = EVALuate
ex = EXtended
exec = EXECute (执行)
fd = file descriptors
fg = ForeGround
fgrep = Fixed GREP
fmt = format
fsck = File System ChecK
fstab = FileSystem TABle
fvwm = F*** Virtual Window Manager
gawk = GNU AWK
gpg = GNU Privacy Guard
groff = GNU troff
hal = Hardware Abstraction Layer
joe = Joe’s Own Editor
ksh = Korn SHell
lame = Lame Ain’t an MP3 Encoder
lex = LEXical analyser
lisp = LISt Processing = Lots of IrritatingSuperfluous Parentheses
ln = Link
lpr = Line PRint
ls = list
lsof = LiSt Open Files
m4 = Macro processor Version 4
man = MANual pages
mawk = Mike Brennan’s AWK
mc = Midnight Commander
mkfs = MaKe FileSystem
mknod = Make Node
motd = Message of The Day
mozilla = MOsaic GodZILLa
mtab = Mount TABle
mv = Move
nano = Nano’s ANOther editor
nawk = New AWK
nl = Number of Lines
nm = names
nohup = No HangUP
nroff = New ROFF
od = Octal Dump
passwd = Passwd
pg = pager
pico = PIne’s message COmposition editor
pine = “Program for Internet News &Email” = “Pine is not Elm”
ping = 拟声 又 = Packet Internet Grouper
pirntcap = PRINTer CAPability
popd = POP Directory
pr = pre
printf = Print Formatted
ps = Processes Status
pty = pseudo tty
pushd = PUSH Directory
pwd = Print Working Directory
rc = runcom = run command, rc还是plan9的shell
rev = REVerse
rm = ReMove
rn = Read News
roff = RunOFF
rpm = RPM Package Manager = RedHat PackageManager
rsh, rlogin, rvim中的
r = Remote
rxvt = ouR XVT
seamoneky = 我
sed = Stream Editor
seq = SEQuence
shar = Shell ARchive
slrn = S-Lang rn
ssh = Secure Shell
ssl = Secure Sockets Layer
stty = Set TTY
su = Substitute User
svn = SubVersion
tar = Tape ARchive
tcsh = TENEX C shell
tee = T (T形水管接口)
telnet = TEminaL over Network
termcap = terminal capability
terminfo = terminal information
tex = τέχνη的缩写,希腊文art
tr = traslate
troff = Typesetter new ROFF
tsort = Topological SORT
tty = TeleTypewriter
twm = Tom’s Window Manager= Tom’s Window Manager
tz = TimeZone= TimeZone
udev = Userspace DEV= Userspace DEV
ulimit = User’s LIMIT= User’s LIMIT
umask = User’s MASK= User’s MASK
uniq = UNIQue= UNIQue
i = VIsual = Very Inconvenient= VIsual = Very Inconvenient
vim = Vi IMproved= Vi IMproved
wall = write all= write all
wc = Word Count= Word Count
wine = WINE Is Not an Emulator= WINE Is Not an Emulator
xargs = eXtended ARGuments= eXtended ARGuments
xdm = X Display Manager= X Display Manager
xlfd = X Logical Font Description= X Logical Font Description
xmms = X Multimedia System= X Multimedia System
xrdb = X Resources DataBase= X Resources DataBase
xwd = X Window Dump= X Window Dump
yacc = yet another compiler compiler= yet another compiler compiler
Fish = the Friendly Interactive SHellFish = the Friendly Interactive SHell
su = Switch User= Switch User
MIME = Multipurpose Internet Mail Extensions= Multipurpose Internet Mail Extensions
ECMA = European Computer ManufacturersAssociation= European Computer ManufacturersAssociation