Linux操作指令
type
status
date
slug
summary
tags
category
icon
password
本文详细介绍了Linux操作指令,包括文件目录类(如建立目录、删除目录、改变当前目录等)、驱动挂载类(如检查硬盘使用情况、挂载软硬光区等)、程序安装类(如RPM包安装、源代码包安装等)、压缩解压类(如tar.gz类、zip类等)以及进程控制类(如列出当前进程ID、终止进程、查看资源占用情况等)。
在Linux终端命令
一、文件目录类
1.建立目录:mkdir 目录名
2.删除空目录:rmdir 目录名
3.无条件删除子目录: rm -rf 目录名
4.改变当前目录:cd 目录名 (进入用户home目录:cd ~;进入上一级目录:cd -)
5.查看自己所在目录:pwd
6.查看当前目录大小:du
7.显示目录文件列表:ls -l (-a:增加显示隐含目录)
其中:蓝:目录;绿:可执行文件;红:压缩文件;浅蓝:链接文件;灰:其他文件;红底白字:错误的链接文件
8.浏览文件:more 文件名.txt;less 文件名.txt
9.复制文件: cp 源文件 目标文件 (-r:包含目录)
10.查找文件:(1)find (2)locate 命令名
11.链接:(1)建立hard链接:ln 来源文件 链接文件(-d:创建目录链接);(2)建立符号链接:ln -s 来源文件 链接文件
二.驱动挂载类
1.检查硬盘使用情况:df -T -h
2.检查磁盘分区:fdisk -l
3.挂载软硬光区:mount -t /dev/fdx|hdax /mnt/目录名
其中::modos--FAT16;vfat--FAT32;ntfs--NTFS;光驱--iso9660
支持中文名:mount -o iocharset=x /dev/hdax /mnt/目录名(其中:x=cp936或
挂载光驱:mount -t auto /dev/cdrom /mnt/cdrom
挂载ISO文件:mount -t iso9660 -o loop xxx.iso /path
4.解除挂载:umount /mnt/目录名
解除所有挂载:umount -a
5.建立文件系统:mkfs -t /dev/hdxx。其中:ftype:ext2、ext3、swap等
三.程序安装类
1.RPM包安装:(1)安装 rpm -ivh somesoft.rpm
(2)反安装 rpm -e somefost.rpm
(3)查询 rpm -q somefost 或 rpm -qpi somefost.rpm(其中:p未安装;i包含的信息)
(4)查询安装后位置:rpm -ql somefost.rpm
(5)升级安装:rpm -Uvh somesoft.rpm
(6)强制安装:rpm -ivh --nodeps somesoft.rpm 或 rpm -ivh --nodeps --force somesoft.rpm
2.源代码包安装:
查阅README
基本用法 (1)配置:解压目录下 ./configure
(2)编译:解压目录下 make
(3)安装:解压目录下 make install
3.src.rpm的安装
四.压缩解压类
1.tar.gz类:(1)解压:tar -xvzf 文件.tar.gz;(2)tar.gz解至tar:gzip -d 文件.tar.gz(2)压缩:gzip 待压缩文件
2.tar未压缩类:(1)解包:tar -xvf 文件.tar;(2)打包:tar -cvf 文件.tar 文件列表
3.zip类:(1)解压:unzip 文件.zip -d dir;(2)压缩:zip zipfile 待压缩文件列表
4.bz2类:(1)解压:bunzip2 文件.bz2或bzip2 -d 文件.bz2;(2)压缩:bzip2 待压缩文件
5.z类:(1)解压:uncompress 文件.z;(2)压缩:compress 文件
五.进程控制类
1.列出当前进程ID:ps -auxw
2.终止进程:(1)终止单一进程:kill 进程ID号
(2)终止该程序所有进程:Killall 程序名
(3)终止X-Window程序:xkill
3.查看资源占用情况:(1)top (2)free (3)dmesg
4.查看环境变量值:env
5.重启:(1)reboot (2)Ctrl Alt Del (3)init 6
6.关机:(1)shutdown -h now (2)halt (3)init 0
7.切换桌面:switchdesk gnome|KDE|...
ls:
this will show you everything in the directory where you are currently located.
ls -1
it will list them all in a single column for you.
ls stands for "list" and the -1 tells your computer to list the directory in one column. If you are in your home directory,
cd Documents
this will take you into your Documents directory, if that was one of the options shown when you used the 'ls' command above. cd stands for "change directory."
ls -1
again to see all the files inside your Documents directory.
Type ls -1F: notice a difference? Any item in the list with a / at the end is another directory.
cd ..
to go back one directory. Directories stack on top of one another and the directory "above" your current directory is always called
pwd
this command shows you the directory you are currently working in. pwd stands for "print working directory." You should see something that starts with /Users/, followed by your computer username. This is called your home directory and you can always get here by typing cd ~.
I like to put all my GitHub projects in the same directory. So the first thing I do is create a directory called "code":
cd ~
to make sure you're in your home directory
mkdir
to create the directory called code in your home directory. mkdir stands for Make directory.
cd
code should bring your terminal into your code directory.