IT袋

当前位置:主页 > 经验教程 > 系统教程 >

linux常用基本命令和用法

linux常用基本命令和用法 分享linux入门基础教程(2)

更新:2023-08-23 02:08:09 来源:IT袋 作者:苏晓敏
导读:linux常用基本命令和用法,escape@ubuntu:~\$ whatis datecal(1), ncal(1) - displays a calendar and the date of easterdate(1) - display or set date and timeiwidgets_datefield(n), iwidgets::datefield(n) - Create and manipulate a d

linux常用基本命令和用法

escape@ubuntu:~\$ whatis datecal(1), ncal(1) - displays a calendar and the date of easterdate(1) - display or set date and timeiwidgets_datefield(n), iwidgets::datefield(n) - Create and manipulate a date field widgetntpdate(8) - set the date and time via NTP

1.1 内建 hash 命令

在 shell 搜中寻到的外部命令的路径结果会缓存至 key-value 存储中,而 hash 用来显示命令缓存。

# 显示命令缓存次数[root@centos7 ~]# hash hits command 2 /usr/bin/file 8 /usr/bin/ls# 列出缓存过的命令[root@centos7 ~]# hash -l builtin hash -p /usr/bin/file file builtin hash -p /usr/bin/ls ls

# 可以给命令建立缓存[root@centos7 ~]# hash -p /usr/bin/file f[root@centos7 ~]# hash -l builtin hash -p /usr/bin/file file builtin hash -p /usr/bin/file f builtin hash -p /usr/bin/ls ls# 删除某个命令的缓存[root@centos7 ~]# hash -d f[root@centos7 ~]# hash -l builtin hash -p /usr/bin/file file builtin hash -p /usr/bin/ls ls

# 列出单个别名的路径[root@centos7 ~]# hash -t file /usr/bin/file# 删除所有命令缓存[root@centos7 ~]# hash -r[root@centos7 ~]# hash hash: hash table empty

1.2 内建 history 命令

history 命令用于管理命令历史。当登录 shell 时,会读取命令历史文件(~/.bash_history)中记录下的命令。当登录进 shell 后新执行的命令只会记录在缓存中,这些命令会用户退出时“追加”至命令历史文件中。

# [命令选项]# 追加本次会话新执行的命令历史列表至历史文件中$ history -a# 删除历史中指定的命令$ history -d ## 清空命令历史$ history -c

# [快捷操作]# 调用历史中第#条命令!## 调用历史中最近一个以string开头的命令!string# 上一条命令!!

1.3 外部 man 命令

man 命令的配置文件 /etc/man.config。

# 要查看指定章节中的手册man1: 用户命令man2: 系统调用man3: C库调用man4: 设备文件及特殊文件man5: 配置文件格式man6: 游戏man7: 杂项man8: 管理类的命令

# 指明新的手册文件搜索位置$ MANPATH /PATH/TO/SOMEWHERE# 到指定位置下搜索COMMAND命令的手册页并显示$ man -M /PATH/TO/SOMEWHERE COMMAND# 帮助手册中的段落说明NAMESYNOPSISDESCRIPTIONOPTIONSEXAMPLESAUTHORREPORTING BUGSSEE ALSO

1.4 外部 info 命令

# 查看帮助$ info COMMAND

2. 日期时间

Linux 中提供了什么我们日常操作所需要的基础命令,我们需要经常使用它们来提高我们的效率。本文将介绍几种 Linux 常用的命令以及操作,耐心看完肯定会对你有帮助的。

2.1 date 命令

系统时钟设定命令

相关阅读