Linux 常用命令

Linux 常用命令

  • [which 是什么?](#which 是什么?)
  • [whereis 是什么?](#whereis 是什么?)
  • [一个点 . 表示什么意思?](#一个点 . 表示什么意思?)

which 是什么?

which 常用于输出 可执行命令 的完整路径

适用场景:

  • 比如说我电脑上装了一个java环境,我想知道这个java环境装在哪了,就可以用which。

命令示例:

shell 复制代码
# 查看node命令的完整路径
root@dfq:~# which node
/usr/bin/node
# (由于当前node是一个软链接形式),使用ls命令查看node的真实位置
root@dfq:~# ls -al /usr/bin/node
lrwxrwxrwx 1 root root 58 Feb 27  2018 /usr/bin/node -> /usr/local/v6.9.5/bin/node
# 查看which帮助
root@dfq:~# which --help
Usage: /usr/bin/which [options] [--] COMMAND [...]
Write the full path of COMMAND(s) to standard output.

  --version, -[vV] Print version and exit successfully.
  --help,          Print this help and exit successfully.
  --skip-dot       Skip directories in PATH that start with a dot.
  --skip-tilde     Skip directories in PATH that start with a tilde.
  --show-dot       Don't expand a dot to current directory in output.
  --show-tilde     Output a tilde for HOME directory for non-root.
  --tty-only       Stop processing options on the right if not on tty.
  --all, -a        Print all matches in PATH, not just the first
  --read-alias, -i Read list of aliases from stdin.
  --skip-alias     Ignore option --read-alias; don't read stdin.
  --read-functions Read shell functions from stdin.
  --skip-functions Ignore option --read-functions; don't read stdin.

whereis 是什么?

whereis 功能与which相似,常用于输出 可执行命令 的安装信息

适用场景:

  • 比如说我服务器上装了一个tar命令,我想知道tar安装后都涉及哪些目录。

命令示例:

shell 复制代码
# 查看tar的安装信息
root@dfq:~# whereis tar
tar: /usr/bin/tar /usr/share/man/man5/tar.5.gz /usr/share/man/man1/tar.1.gz /usr/share/info/tar.info-1.gz /usr/share/info/tar.info.gz /usr/share/info/tar.info-2.gz
# 查看tar帮助
root@dfq:~# whereis --help

Usage:
 whereis [options] [-BMS <dir>... -f] <name>

Locate the binary, source, and manual-page files for a command.

Options:
 -b         search only for binaries
 -B <dirs>  define binaries lookup path
 -m         search only for manuals and infos
 -M <dirs>  define man and info lookup path
 -s         search only for sources
 -S <dirs>  define sources lookup path
 -f         terminate <dirs> argument list
 -u         search for unusual entries
 -l         output effective lookup paths

 -h, --help     display this help
 -V, --version  display version

一个点 . 表示什么意思?

Linux中,点 . 常用于表示当前目录。"./var" 即表示当前目录中的var目录下

适用场景:

  • 常用于表示相对路径的场景下,如表示 当前目录 的上级或下级目录,令目录表示更灵活。
shell 复制代码
# 查看 当前目录中var目录下的内容
root@dfq:/# ls ./var/
agentx  backups  cache  kurento  lib  local  lock  log  lsof_1.txt  lsof_2.txt  lsof_difference.txt  mail  net-snmp  opt  run  spool  t1.txt  tmp  www
# 在不使用点的情况下,也可以直接查看当前目录中的var目录(默认是以当前的工作目录作为起点操作)
root@dfq:/# ls var/
agentx  backups  cache  kurento  lib  local  lock  log  lsof_1.txt  lsof_2.txt  lsof_difference.txt  mail  net-snmp  opt  run  spool  t1.txt  tmp  www
相关推荐
m0_747124535 小时前
MIPI 屏幕移植到不同 Linux 开发板步骤(以全志平台为例)
linux·嵌入式硬件·mipi
.道阻且长.5 小时前
Linux基础IO:系统文件IO
linux·运维·服务器
迪康coolmu5 小时前
基于迪康端点安全一体化管理系统的屏幕录像审计:录屏的留存、回放与取证链
运维·服务器·网络·经验分享·安全·网络安全·制造
GZlangtian6 小时前
锂电池化成设备自动化产线集成设计:物流节拍、设备通信与MES接口
运维·自动化·制造·化成分容设备·电池化成分容设备·锂电检测设备·锂电池化成分容
zxcvb1537 小时前
运维实践里把备份mysql数据库做稳的一些思路
运维·数据库·mysql
女神下凡8 小时前
芯易选(146):树莓派(Raspberry Pi)_开发指南
linux·arm开发·stm32·单片机·嵌入式硬件
by209998 小时前
Linux 软硬链接与文件删除机制
linux·服务器
我不会起名字32210 小时前
eBPF 与 perf 性能观测:On-CPU、Off-CPU 火焰图与内核探针的 4 个边界
linux·云原生·ebpf·perf·性能观测
极创信息10 小时前
信创国产化适配流程全解:从环境矩阵到测试证明的完整路径
运维·人工智能·http·wireshark·健康医疗
俊俊几年的10 小时前
RK3588 开发板详解:硬件优势与嵌入式 Linux 学习路线
linux·c++·嵌入式