ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Linux常用的帮助

2020-04-14 17:57:51  阅读:456  来源: 互联网

标签:locate 帮助 常用 dbus rhcsa ifconfig usr Linux root


博主本人热爱学习,读者阅读过程中如果发现有错误的地方或是有更好的实现方式,请与本人联系(qq:1805608587),或是在评论区留言,谢谢!


文章说明:本文是作者原创,请尊重个人劳动成果,转载需注明出处

1.man

常见的几个数字的意义是这样的:

代号+代表内容

1 使用者在shell环境中可以操作的指令或可可执行文件

2 系统核心可调用的函数与工具等

3 一些常用的函数(function)与函数库(library),大部分为C的函数库(libc)

4 设备文件的说明,通常在/dev下的文件

5 配置文件或者是某些文件的格式

6 游戏(games)

7 惯例与协定等,例如Linux文件系统、网络协定、ASCII code等等的说明

8 系统管理员可用的管理指令

9 跟kernel有关的文件

 

2.help

help是我最常用的帮助命令

3.yum provides

模糊查询,这个功能真的很有效,检查命令是由哪个包提供的,例如:

[root@rhcsa ~]# yum provides ifconfig  

......   

net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools

Repo        : @anaconda

Matched from:

Filename    : /usr/sbin/ifconfig

[root@rhcsa ~]# yum install -y net-tools-2.0-0.24.20131004git.el7.x86_64

4.X服务

X服务在Linux里面是提供图形化操作的,也是非常友好的一个功能

4.1.安装与配置X服务

Xming下载地址:https://xming.en.softonic.com/

Xming配置:

 

 

 

 

 

 

 

 

 

 

SecureCRT配置:

 

 

4.2.设置X服务地址

(WindowsIP:192.168.1.2):

[root@ORACLE ~]# export DISPLAY=192.168.1.2:0.0  (根据本地电脑而定)

 

4.3.打开Firefox验证

[root@ORACLE ~]# firefox &      

LINUX7可以顺利打开X服务,LINUX6则会进行如下报错 :  

/usr/bin/firefox: line 255: dbus-send: command not found

Starting a11y dbus service...

Failed to launch bus: Failed to connect to session busprocess 2471: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory

See the manual page for dbus-uuidgen to correct this issue.

  D-Bus not built with -rdynamic so unable to print a backtrace

Redirecting call to abort() to mozalloc_abort

 

添加安装支持服务:

 

mkdir -p /var/lib/dbus/

yum install dbus-uuidgen -y    (yum provides  */dbus-uuidgen    yum install dbus-1.2.24-11.el6_10.x86_64 -y)

dbus-uuidgen >/var/lib/dbus/machine-id

firefox

5.查看日历

5.1.Linux7

要求:

1.显示日历

2.显示当前时间

3.将时区设置为上海,并且同步时间

[root@rhcsa ~]# cal

    October 2019    

Su Mo Tu We Th Fr Sa

       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 31

[root@rhcsa ~]# date

Sat Oct  5 21:43:16 CST 201

[root@rhcsa ~]# timedatectl list-timezones |grep hai

Asia/Shanghai

[root@rhcsa ~]# timedatectl set-timezone Asia/Shanghai

[root@rhcsa ~]# man chronyc |grep make

       makestep, makestep threshold limit

           The makestep command can be used in this situation. There are two forms of the command.

   ...

[root@rhcsa ~]# chronyc -a makestep

200 OK

[root@rhcsa ~]# timedatectl

      Local time: Sat 2019-10-05 21:45:41 CST

  Universal time: Sat 2019-10-05 13:45:41 UTC

        RTC time: Sat 2019-10-05 13:45:41

       Time zone: Asia/Shanghai (CST, +0800)

     NTP enabled: yes

NTP synchronized: yes

 RTC in local TZ: no

      DST active: n/a

[root@rhcsa ~]#

5.2.Linux6

date -s 时间字符串

例如只修改系统的日期,不修改时间(时分秒)

date -s 2012-08-02

或只修改时间不修改日期

date -s 10:08:00

当然也可以同时修改日期和时间

date -s "2012-05-18 04:53:00"

 

要求:

1.显示日历

2.显示当前时间

3.将时区设置为上海,并且同步时间

[root@TESTB ~]# cal

    October 2019    

Su Mo Tu We Th Fr Sa

       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 31

[root@TESTB ~]# date

Sat Oct  5 10:15:01 EDT 2019

 

修改时区方法一:

[root@TESTB ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[root@TESTB ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

修改时区方法二:

TZ变量,eport 可以看到系统变量。如果设置了 TZ 变量,系统将按 TZ 的变量设置本机的时区。且优先级比 /etc/localtime 高。
具体的命令是 export TZ=Asia/Shanghai

[root@TESTB ~]# tzselect
取消这个变量的命令是 unset TZ。

5.3图形化操作(Linux6/7)

(需要安装X服务)

[root@localhost ~]# yum provides zenity  

[root@localhost ~]# yum install -y zenity-3.28.1-1.el7.x86_64

[root@localhost ~]# zenity --calendar

Gtk-Message: 20:15:56.851: GtkDialog mapped without a transient parent. This is discouraged.

 

6.设置编码格式

一开始使用Linux的时候,喜欢用中文语系。在这种情况下就需要修改编码格式,否则会出现乱码的情况

 

6.1.Linux6

要求:

l 设置编码格式为en_US.UTF-8

 

编辑i18n文件即可:

cat /etc/sysconfig/i18n  

LANG="en_US.UTF-8"

查询所有支持的格式:

[root@TESTB ~]# locale -a

 

6.2.Linux7

要求:

l 设置编码格式为en_US.UTF-8

设置语系:

[root@rhcsa ~]# localectl set-locale LANG=en_US.UTF-8

检查当前语系:

cat /etc/locale.conf

LANG="en_US.UTF-8"

或是:

[root@rhcsa ~]# localectl

   System Locale: LANG=en_US.UTF-8

查询所有的编码格式:

[root@rhcsa ~]# localectl list-locales

7.搜寻指令

7.1.which

选项或参数:

1.-a :将所有由 PATH 目录中可以找到的指令均列出,而不止第一个被找到的指令名称

注意:这个指令是根据“PATH”这个环境变量所规范的路径,去搜寻“可执行文件”的文件名

 

查找ifconfig

[root@rhcsa ~]# which  ifconfig   

/usr/sbin/ifconfig

 

7.2.whereis

选项与参数:

-l :可以列出 whereis 会去查询的几个主要目录而已

-b :只找 binary 格式的文件

-m :只找在说明文档 manual 路径下的文件

-s :只找 source 来源文件

-u :搜寻不在上述三个项目当中的其他特殊文件 

 

查找ifconfig的说明文档:

[root@rhcsa ~]# whereis -m ifconfig

ifconfig: /usr/share/man/man8/ifconfig.8.gz

 

7.3.type

type可以区分内外部命令

外部命令ifconfig

[root@rhcsa ~]# type ifconfig

ifconfig is /usr/sbin/ifconfig

[root@rhcsa ~]#

 

内部命令cd

[root@rhcsa ~]# type cd

cd is a shell builtin

[root@rhcsa ~]#

 

7.4.locate

locate(locate) 命令用来查找文件或目录。 locate命令要比find -name快得多,原因在于它不搜索具体目录,而是搜索一个数据库/var/lib/mlocate/mlocate.db

选项与参数:

-i :忽略大小写的差异;

-c :不输出文件名,仅计算找到的文件数量

-l :仅输出几行的意思,例如输出五行则是 -l 5

-S :输出 locate 所使用的数据库文件的相关信息,包括该数据库纪录的文件/目录数量等

-r :后面可接正则表达式的显示方式

 

[root@rhcsa ~]# locate ifconfig

locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

 

 

[root@rhcsa ~]# updatedb

[root@rhcsa ~]# locate ifconfig

/usr/libexec/hypervkvpd/hv_set_ifconfig

/usr/sbin/ifconfig

/usr/sbin/pifconfig

/usr/share/man/de/man8/ifconfig.8.gz

/usr/share/man/fr/man8/ifconfig.8.gz

/usr/share/man/man8/ifconfig.8.gz

/usr/share/man/man8/pifconfig.8.gz

/usr/share/man/pt/man8/ifconfig.8.gz

 

locate原理:这个 locate 的使用更简单,直接在后面输入“文件的部分名称”后,就能够得到结果。但是,这个东西还是有使用上的限制!为什么呢?你会发现使用 locate 来寻找数据的时候 特别的快, 这是因为 locate 寻找的数据是由“已创建的数据库 /var/lib/mlocate/” 里面的数据所

搜寻到的,所以不用直接在去硬盘当中存取数据,当然是很快速啰!

那么有什么限制呢?就是因为他是经由数据库来搜寻的,而数据库的创建默认是在每天执行

一次 (每个 distribution 都不同,CentOS 7.x 是每天更新数据库一次!),所以当你新创建 起来的文件, 却还在数据库更新之前搜寻该文件,那么 locate 会告诉你“找不到!因

为必须要更新数据库!

那能否手动更新数据库哪?当然可以啊!更新 locate 数据库的方法非常简单,直接输入“

updatedb ”就可以了! updatedb 指令会去读取 /etc/updatedb.conf 这个配置文件的设置,

 

8.小结

1.在终端机模式中,如果你知道某个指令,但却忘记了相关选项与参数,请先善用 --help 的功能来查询相关信息;

2.当有任何你不知道的指令或文件格式这种玩意儿,但是你想要了解他,请赶快使用man或者是info来查询!

3.而如果你想要架设一些其他的服务,或想要利用一整组软件来达成某项功能时,请赶快 到/usr/share/doc 下面查一查有没有该服务的说明文档!

4.如果需要使用一些命令,又不知道是由哪个包提供的,请使用provides

5.语系设置LINUX6需要修改/etc/sysconfig/i18n里面的内容,LINUX7直接使用localectl set-locale LANG=""(后加tab提示即可)

 

标签:locate,帮助,常用,dbus,rhcsa,ifconfig,usr,Linux,root
来源: https://www.cnblogs.com/tanshouke/p/12699596.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有