美文网首页Linux
Linux基础命令

Linux基础命令

作者: 五花肉_pork | 来源:发表于2019-06-01 20:01 被阅读141次

Linux概述

Linux是一个通用的操作系统,操作系统是负责内存分配、任务调度、处理外围设备I/O等的操作,通常由内核和系统程序两部分组成。内核是运行其他程序,管理磁盘、打印机等硬件设备的核心程序;系统程序是指设备驱动、shell、服务程序等。
Linux是由芬兰人Linus Torvalds在1991年发布,是一个自由的操作系统。

Linux优点

1.通用的操作系统,不被特定的硬件设备所绑定。
2.源码是C语言,可移植性强,并由内核编程接口。
3.可靠的安全性和稳定性。
4.支持多用户、多任务,支持安全的分层文件系统。
......

目前Linux发行版本

Redhat、Ubuntu、Centos、Fedora、Debian、openSUSE

Linux基础命令

Linux系统的命令通常是以下的格式:
命令名称 [命名参数] [命令对象]
下面介绍一些Linux操作系统的基础命令:
1.查看自己所使用的shell: ps

LxiindeMacBook-Pro:~ Lxiin$ ps
 PID TTY           TIME CMD
3768 ttys000    0:00.14 /bin/bash --rcfile /Applications/PyCharm.app/Contents/
4242 ttys001    0:00.07 -bash

shell是用户与操作系统内核交流的翻译官,简单来说是人与计算机交互的界面和接口。目前Linux系统默认的shell都是bash,其可以使用tab键进行命令和路径补全,可以保存历史命令,也可以进行环境配置及执行批处理的操作。
2.获取用户登录信息:w/ who/ last

LxiindeMacBook-Pro:~ kingsoft$ w
23:27  up 1 day,  5:35, 2 users, load averages: 3.93 2.89 2.83
USER     TTY      FROM              LOGIN@  IDLE WHAT
kingsoft console  -                四18   29:18 -
kingsoft s001     -                18:11       - w
LxiindeMacBook-Pro:~ Lxiin$ who
Lxiin console  May 30 18:09 
Lxiin ttys001  May 31 18:11
LxiindeMacBook-Pro:~ Lxiin$ who am i
Lxiin ttys001  May 31 18:11 
LxiindeMacBook-Pro:~ Lxiin$ last
Lxiin  ttys001                   Fri May 31 18:11   still logged in
Lxiin  ttys001                   Fri May 31 14:13 - 14:13  (00:00)
Lxiin  ttys001                   Fri May 31 13:08 - 13:08  (00:00)
Lxiin  ttys001                   Fri May 31 13:06 - 13:06  (00:00)

3.查看命令的说明:whatis

LxiindeMacBook-Pro:~ Lxiin$ whatis clear
zmq_plain(7)             - clear-text authentication
clear(1)                 - clear the terminal screen

4.查看命令的位置:which/whereis

LxiindeMacBook-Pro:~ Lxiin$ which python
/Library/Frameworks/Python.framework/Versions/3.7/bin/python
LxiindeMacBook-Pro:~ Lxiin$ whereis python
/usr/bin/python

5.查看命令的帮助文档:man/info/help

PS(1)                     BSD General Commands Manual                    PS(1)

NAME
     ps -- process status

SYNOPSIS
     ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
        [-g grp[,grp...]] [-u uid[,uid...]] [-p pid[,pid...]]
        [-t tty[,tty...]] [-U user[,user...]]
     ps [-L]

DESCRIPTION
···
LxiindeMacBook-Pro:~ Lxiin$ ps --help
ps: illegal option -- -
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-g grp[,grp...]] [-u [uid,uid...]]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]
LxiindeMacBook-Pro:~ kingsoft$ info ps
···

6.查看系统和主机名:uname/hostname

LxiindeMacBook-Pro:~ Lxiin$ hostname
LxiindeMacBook-Pro.local

7.查看日期和时间:cal/date

LxiindeMacBook-Pro:~ Lxiin$ cal
      六月 2019         
日 一 二 三 四 五 六  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
30
LxiindeMacBook-Pro:~ Lxiin$ date
2019年 6月 1日 星期六 19时26分34秒 CST

8.退出登录:exit/logout

LxiindeMacBook-Pro:~ Lxiin$ exit
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...21 completed.

9.查看历史命令:history;执行历史命令:!+[num]

LxiindeMacBook-Pro:~ Lxiin$ history
···
502  clear
503  history
LxiindeMacBook-Pro:~ Lxiin$ !502
clear

10.重启和关机:reboot/shutdown

相关文章

网友评论

    本文标题:Linux基础命令

    本文链接:https://www.haomeiwen.com/subject/hvlitctx.html