linux shutdown command terminal
1.linux terminal is shut down: shutdown -h now (normal shutdown), halt (OFF Memory), init O;
Linux file system
1.Linux everything is a file
① in Windows is a file, the same file in linux;
② not file in Windows, linux is stored in the form of documents.
2.Linux file directory structure
directory structure
1. the Bin : full name of the binary, meaning binary. The currently stored are some binary files, files are can be run.
2. Dev : This is currently the main external storage devices such as disk, other CD-ROM. In which external devices can not be directly used, needMount (assign a drive letter in similar Windows).
3. Etc : The main directory to store some configuration files.
4. Home : that "home", saidIn addition to the root user's home directory to other users, User / user directory similar to Windows.
5. Proc : Process, it means the process, which is stored in the directory when running Linux process.
6. Root : The root directory is the user's own home directory.
7. sbin : full name super binary, the directory also stores some binaries can be executed, but have to have super user privileges to perform.
8. Tmp : for "temporary", the temporary files when the system is running when produced will be stored in the directory.
9. Usr : stored in the user's own software is installed. Similar to the program files under Windows.
10. The var : log file directory program / storage system.
11. Mnt : When the need to mount external device, you need to mount mnt.
Linux basic instructions
Command and options
What is the Linux command?
It refers to a Linux terminal (command) contents of the instruction input on the call.
A full standard format instruction: Linux common format
#Instruction body [Option] [Operation Object]
The instructions may include a plurality of options for
the operation target may be a plurality.
Basic instructions
1.ls command
meaning: ls (list)
Usage 1: #ls
Name lists the current directory of all files / folders: Meaning
Usage 2: #ls path
Meaning: lists the names of all files in the developing path / folder
About path (important)
The path can be divided into two types: relative path, absolute path.
Relative path: first of all there is a relative reference (in general is the current working directory);
wording opposite path: the relative path typically used two symbols"./" represents the current directory [], [] on a directory "... /"
Absolute path: the path does not require absolute reference, direct From the root "/" Start looking for the corresponding path;
Usage 3: #ls path options
Meaning: The file is listed under the specified path / folder name, and displays the specified format.
Common syntax:
#ls the -l path
#ls -la path
options explained:
the -l: representation list, indicate on display in the form of a detailed list of
-la: displays all files / folders (including hidden files / folders)
the first column of the above list of characters indicates the type of document,Wherein "-" indicates that the line corresponding to the type of document files, "d" indicates that the document is a folder。
In Linux, hidden documents generally. "" Beginning。
Usage 4: #ls -lh path
Meaning: develop lists all the files in the path name / folder in list form and displayed in the form of a high readability of the display when the document size.
2.pwd command
Usage: #pwd (print working directory, print the current working directory)
3.cd command
command: #cd (change directory: change directory)
Syntax: #cd Path
Case: The current in "/", it is necessary to use the absolute path to switch to the / usr / local
Case Study: currently under / usr / local need using a relative path switching to Linux123 user home directory in the home directory to
add:
there is a special symbol "~" in linuxIt represents the current user's home directory。
切换的方式:cd ~
4.mkdir指令
指令:mkdir (make directory,创建目录)
语法:#mkdir 路径【路径,可以是文件夹名称也可以是包含名称的一个完整路径】
案例:在当前路径下创建出目录“StudyLinux”
注意:ls列出的结果颜色说明,其中蓝色的名称表示文件夹,黑色的表示文件,绿色的其权限为拥有所有权限。
案例:在指定路径下创建一个文件夹“StudyLinux”
语法2:#mkdir -p 路径
含义:当一次性创建多层不存在的目录的时候,添加-p参数,否则会报错。
语法:#mkdir 路径1 路径2 路径3…【一次性创建多个目录】
5.touch指令
指令:touch
作用:创建文件
语法:#touch 文件路径 【路径可以是直接的文件名也可以是路径】
案例:使用touch来在当前路径下创建一个文件夹,命名为StudyLinux.txt
案例:使用touch来同时创建多个文件
案例:使用touch来在“Linux123”用户的家目录中创建文件,linux.txt
6.cp指令
指令:cp (copy,复制)
作用:复制文件/文件夹到指定的位置
语法:#cp 被复制的文档路径 文档被复制到的路径
案例:使用cp命令来复制一个文件
注意:在复制过程中是可以重新对新位置的文件进行重命名的,但是如果不是必须的需要,则建议保持前后名称一致。
案例:使用cp命令复制一个文件夹
注意:当使用cp命令进行文件夹复制操作的时候需要添加选项“-r”【-r表示递归复制】,否则目录讲被忽略。
7.mv指令
指令:mv (move :移动,剪切)
作用:移动文档到新的位置。
语法:#mv 需要移动的文档路径 需要保存的位置路径
案例:使用mv移动一个文件
案例:使用mv移动一个文件夹
补充:在Linux中重命名的命令也是mv,语法也是和移动语法一样。
8.rm命令
指令:rm (remove :移除、删除)
作用:移除/删除文档
语法:#rm 选项 需要移除的文档路径
选项:
-f :force ,强制删除,不提示是否删除
-r :表示递归
案例:删除一个文件
在删除的时候如果不带选项,会提示是否删除,如果需要确认则输入“y/yes”,否则输入“n/no”按下回车。
==注意: 如果在删除的时候不想频繁的确认,则可以在指令中添加选项“-f”,表示force(强制) ==
案例:删除一个文件
案例:删除一个文件夹
注意:删除一个目录的时候需要做递归删除,并且一般也不需要进行删除确认询问,所以移除目录的时候一般需要使用“-rf”选项。
案例:删除多个文档
案例:删除一个目录下有共同特性的文档,例如都以linux开头
其中,“*”称为通配符,表示任意的字符,Linux※,则表示只要文件以Linux开头,后续字符则不管。
9.vim命令
指令:vim (vim是一款文本编辑器)
语法:#vim 文件路径
作用:打开一个文件(可以不存在,也可以存在)
案例:使用vim来打开文件
退出打开的文件,在没有按下其他命令的时候,按下shift+英文冒号,输入q,按下回车即可退出
10.输出重定向
一般命令的输出都会显示在终端中,有些时候需要将一些命令的执行结果想要保存到文件中进行后续的分析/统计,则这时候需要使用到的输出重定向技术。
>:覆盖输出,会覆盖掉原先的文件内容
>> :追加输出,不会覆盖原始文件内容,会在原始内容末尾继续添加。
语法:#正常执行的指令 >/>> 文件的路径
注意:文件可以不存在,不存在则创建
案例:使用覆盖重定向,保存ls -la的执行结果,保存到当前目录下的ls.txt
案例:使用追加重定向,保存ls-la的执行结果到ls.txt中
11.cat指令
作用1:cat 直接打开一个文件的功能
语法1:#cat 文件的路径
作用2:cat 可以对文件进行合并
语法2:# cat 待合并的文件路径1 待合并的文件路径2 … 文件路径n > 合并后的文件路径
案例:合并2个文件,并存到一个文件中【配合输出重定向使用】
1、df查看磁盘空间
2、free 只看内存使用情况
3、head查看前几行命令
4、tail查看后几行命令
5、less指令
6、wc统计行数、单词数、字节数指令
7、date查看时间指令
8、cal 查看日历指令
9、clear/ctrl_L
10、管道
一、高级指令
1、hostname
2、id指令
3、whoami
4、ps -ef查看服务器进程
5、top查看服务器查看进程占用资源
6、du -sh指令,查看目录的真实大小
7、find查找文件
8、service控制软件服务的启动与停止
9、kill杀死进程指令
10、ifconfig获取网卡信息
11、reboot重启计算机
12、shutdown关机指令
除了shutdown命令关机以外,还有以下关机命令:
#init0
#halt
#poweroff
13、uptime输出计算机的持续在线时间
14、uname获取计算机相关信息
15、netstat -tnlp查看网络连接状态
16、man查询Linux手册
补充练习:
1、如何通过命令重启Linux操作系统? #reboot
2、如何在命令行中快速删除光标前/后的内容? 前:Ctrl+u、后:Ctrl+k
3、如何删除/tmp下所有A开头的文件? rm -f /tmp/A*
4、系统重要文件需要备份,如何把/etc/passwd备份到/tmp目录下?
#cp /etc/passwd /tmp
5、如何查看系统最后创建的3个用户? #tail -3 /etc/passwd
6、什么命令可以统计当前系统中一共有多少账户? #wc -l /etc/passwd #cat /etc/passwd
7、如何创建/tmp//test.conf文件? #touch /tmp/test.conf
8、如何通过vim编辑打开/tmp/test.conf? #vim /tmp/test.conf
9、如何查看/etc/passwd的头3行和尾3行?
#head -3 /etc/passwd
#tail -3 /etc/passwd
10、如何一次性创建目录 /text/1/2/3/4? mkdir -p /text/1/2/3/4
11、如何最快的返回到当前账户的家目录?
#cd~ 、 #cd
12、如何查看/etc所占的磁盘空间? #du -sh /etc
13、如何删除 /tmp下所有的文件? rm -rf /tmp/*
14、尝试启动Apache的服务,并检查是否启动成功。
#service httpd start
#ps -ef |grep httpd
15、使用已学过命令杀死Apache的进程 #killall httpd