Linux基础指令


常用操作

指令功能
manmanual,查看指令用法
clear清空终端
history输出历史命令
!cmd运行之前的命令,cmd由history运行后的cmd标号

文件操作——file operation

指令功能
lslist the direction and files
ls -alist all includes hidden directory and files,将所有文件(包括隐藏文件)一起显示
ls -lformat list,将文件信息一起输出
ll -aformat list (ls -l的缩写)
cdchange directory to the /home/user
cd ~~mean the /home/user directory
cd /回到根目录
cd dir_pathchange to the dir_path directory,回到用户目录
cd …返回上一级,‘.’代表着当前目录 ,‘…’代表着上级目录
pwdpresent working directory,打印当前目录
mkdir dircreate a directoy
touch filecreate a file
vi filegvim editor
gvim file返回上一级
chmod 777 dirchange r/w/x property

文件类型和权限
在这里插入图片描述
注意:chmod 777 中的777指的是rwxrwxrwx,750设置的比较多指的是rwxr-x—

查看文件内容

指令功能
cat filelook at the file context on terminal
more fileview the file ,按回车键能继续看
less fileview the file like gvim or vi,按“q”可推出
wc filecount lines words and characters,打印字数和行数
wc -w filecount word of file, 打印字数
wc -l filecount line ,打印行数
wc -c filecount characters ,打印字符数

拷贝文件

指令功能
cp (-f) file1 file2copy file1 to file2,拷贝文件, -f 强制拷贝
cp -r dir1 dir2copy directory recursively,递归拷贝

文件的移动和重命名

指令功能
mv file1 dir|file2move file1 to dir, or rename file1 to file2
-i如果存在同名,先询问是否覆盖
-f强制移动,不提示直接覆盖已有文件
-v显示删除速度

文件删除

指令功能
rm fileremove file
rm -r dirremove dir* recursively
rm -f fileenforce to remove file(force),强制删除
rm -rf direnforce to remove dir* recursively
rm [选项] file文件删除
-r递归删除,删除文件夹
-i删除前询问确认
-f强制删除
-v显示删除速度

模式匹配

指令功能
grep pattern filesearch pattern matched in file
grep error sim.log在sim.log中查找有error的行
grep -r pattern dirsearch pattern incursively in directory,在路径dir下递归匹配

文件查找

指令功能
find / -name file_namesearch the file form /directory,'/‘根目录 ,’.'当前目录
fine /etc -name ‘*con*’在/etc路径下查找
find / -size +100M查找大于100M的文件

文件打包和压缩

指令功能
tar -cvf file.tar filescreate a tar file,打包文件
tar -xvf file.tarextract a tar file,解绑文件
tar -czvf file.tar.gz filescreate a gzip file,压缩文件
tar -xzvf file.tar.fz解压文件
tar -cjvf file.tar.bz2 filescreate a bzip2 file
tar -xjvf file.tar.bz2
gzip filecreate a file.gz file
gzip -d file.gz解压

在这里插入图片描述
注:常用解压命令 tar -xzpf file.tar.gz ,不显示操作详细信息,或者是tar -xvzpf file.tar.gz,显示操作详细信息。

文件的比较

指令功能
diff [选项] file1 file2比较两个文件是否一样
diff -r dir1 dir2比较两个目录是否一致
-b忽略空格造成的不同
-q只报告什么地方不同,不报告具体的不同信息
-i忽略大小写的变化
-r在比较目录时比较所有的子目录
-s两个文件相同时才报告
-v在表尊输出上输出版本信息并退出

安装rpm包——install rpm package

指令功能
rpm -qaquery all install rpm packages,输出所有rpm包
rpm -ivh rpm.rpminstall rpm package

重定向和管道

重定向

指令功能
grep error cmp.log > error.log将cmp.log中含有error的行输出到error.log中
grep error cmp.log >> error.log追加输出到error.log中
cat > filesample the standard input and put them into the file,将键盘输入放入file中,^c退出

管道

指令功能
rpm -qa |grep vim将rpm -qa的输出作为grep vim的输入,即rpm -qa得到所有的rpm包,再通过grep vim匹配vim的rpm包
grep error sim.log | tee -a error.logtee也是将文件输出到error.log中,-a指的是追加
man ls | col -b > ls_man.txtcol -b 是将回车键给去掉

进程管理——process manage

指令功能
psdisplay the current active process
topdisplay all process of the OS,包括root,其他user的进程
kill pidstop the pid process
killall procstop all of the proc process
bglist the suspended job in background
fgresum the last suspended job in foreground,将后台的进程调到前台

打印系统信息——system info

指令功能
date打印时间
data +%Y%m%d年月日打印时间
cal打印日历
which cmd打印cmd的路径
whoamiprint effective userid,打印当前使用的账号名
who查看当前有哪些用户登录到系统中
wdisplay who logon and what are doing, 打印系统谁登录了并且干了什么
su rootusr
exit退出root
echo $PATHshow the variable,打印变量
cat /proc/cpuinfoshow CPU information,打印cpu信息
cat /proc/meminfoshow memory information,打印内存信息
dfreport file system disk space information
du -b|k|m file|direstimate file space usage
du -s file |dirsummary
du -sm file|file

网络信息——network info

指令功能
ping hostIP
hostnamedisplay system host name
ifconfig -aconfigure the network

快捷键——hot key

指令功能
ctrl + c终端指令
ctrl + z将指令放在后台

VNC常用指令

指令功能
vncserver开vncserver
vncserver -kill :#关闭vncserver,#代表端口号
vncpasswd更改vnc密码
vncserver -geometry 1200x800设置分辨率
vncserver -geometry 1200x800 :69申请指定的端口
vncconfig -nowin &window通过vnc和linux进行复制,-nowin可不要,&指的是后台运行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值