博客
关于我
Linux常用命令(1)
阅读量:164 次
发布时间:2019-02-27

本文共 4861 字,大约阅读时间需要 16 分钟。

Linux常用命令(1)

切换到ROOT用户(su - root)

[root@localhost ~]# su - root密码:[root@localhost ~]

查看IP地址(ifconfig)

[root@localhost ~]# ifconfigens33: flags=4163
(Ethernet) mtu 1500 inet 192.168.100.47 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::c461:4388:8c74:21af prefixlen 64 scopeid 0x20 ether 00:0c:29:d7:54:49 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 38 bytes 5021 (4.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73
(Local Loopback) mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 608 bytes 52896 (51.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 608 bytes 52896 (51.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0virbr0: flags=4099
(Virtual Bridge) mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:2c:fd:50 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

查看主机名(hostname)

[root@localhost ~]# hostnamelocalhost.localdomain**localhost为主机名**

查看自身路径(pwd)

[root@localhost ~]# pwd/root

查看登陆身份(whoami)

[root@localhost ~]# whoamiroot

查看日期(date)

[root@localhost ~]# date2021年 04月 22日 星期四 21:41:30 CST

查看日历(cal)

[root@localhost ~]# cal    四月 2021       日 一 二 三 四 五 六            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

关闭防火墙(systemctl stop firewalld.service)

[root@lrz ~]# systemctl stop firewalld.service

查看防火墙状态(systemctl status firewalld.service)

[root@lrz ~]# systemctl status firewalld.service● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: inactive (dead) since 四 2021-04-22 21:56:17 CST; 35s agoDocs: man:firewalld(1)Process: 6196 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)Main PID: 6196 (code=exited, status=0/SUCCESS)4月 22 21:31:13 localhost.localdomain systemd[1]: Starting firewalld - dynamic fir....4月 22 21:31:13 localhost.localdomain systemd[1]: Started firewalld - dynamic fire....4月 22 21:56:16 lrz systemd[1]: Stopping firewalld - dynamic firewall daemon...4月 22 21:56:17 lrz systemd[1]: Stopped firewalld - dynamic firewall daemon.

改主机名(hostname lrz)

[root@localhost ~]# hostname lrz[root@localhost /]# su - liu上一次登录:四 4月 22 21:31:25 CST 2021:0 上[liu@lrz ~]# su - root

查看内部命令(enable)

[root@lrz ~]# enableenable .enable : enable [enable alias enable bgenable bindenable break enable builtin enable caller enable cdenable command enable compgen enable complete enable compopt enable continue enable declare enable dirs enable disown enable echo enable enable enable eval enable exec enable exit enable export enable false enable fc enable fgenable getopts enable hash enable help enable history enable jobs enable kill enable let enable local enable logout enable mapfile enable popdenable printf enable pushdenable pwdenable readenable readarray enable readonly enable return enable setenable shiftenable shopt enable source enable suspend enable test enable times enable trap enable true enable type enable typeset enable ulimit enable umask enable unalias enable unset enable wait

查看命令信息(type XXX)

[root@lrz ~]# type pwdpwd 是 shell 内嵌[root@lrz ~]# type hostnamehostname 是 /bin/hostname

显示命令路径(which XXX)

[root@lrz ~]# which whoami/bin/whoami[root@lrz ~]# which hostname/bin/hostname

关闭安全防护(setenforce 0)

[root@lrz ~]# setenforce 0

查看当前目录下文件夹(ls)

[root@lrz ~]# cd /[root@lrz /]# lsbin   dev  home  lib64  mnt  proc  run   srv  tmp  varboot  etc  lib   media  opt  root  sbin  sys  usr

Linux命令行格式

[root@lrz /]# su --help用法: su [选项] [-] [USER [参数]...]将有效用户 id 和组 id 更改为 USER 的 id。单个 - 视为 -l。如果未指定 USER,将假定为 root。选项: -m, -p, --preserve-environment  不重置环境变量 -g, --group 
<组>
-G, --supp-group
<组>
-, -l, --login 使 shell 成为登录 shell -c, --command
<命令>
--session-command
<命令>
而不创建新会话 -f, --fast 向 shell 传递 -f 选项(csh 或 tcsh) -s, --shell
若 /etc/shells 允许,则运行 shell -h, --help 显示此帮助并退出 -V, --version 输出版本信息并退出

内部命令查看帮助(help XXX)

[root@lrz /]# help pwdpwd [-LP]    打印当前工作目录的名字。        选项:      -L	打印 $PWD 变量的值,如果它命名了当前的      -P	打印当前的物理路径,不带有任何的符号链接        默认情况下,`pwd' 的行为和带 `-L' 选项一致        退出状态:    除非使用了无效选项或者当前目录不可读,否则        返回状态为0。

进入某个文件夹(cd /home)

[root@lrz /]# cd /home[root@lrz home]#

切换到我刚刚命令执行的路径(cd -)

[root@lrz home]# cd -/home/liu[root@lrz liu]#

绝对路径与相对路径

  • 绝对路径:/home/liu/usr/bin
  • 相对路径:../home/liu../usr/bin

转载地址:http://dffd.baihongyu.com/

你可能感兴趣的文章
OSG中找到特定节点的方法(转)
查看>>
OSG学习:C#调用非托管C++方法——C++/CLI
查看>>
OSG学习:OSG组成(三)——组成模块(续):OSG核心库中的一些类和方法
查看>>
OSG学习:OSG组成(二)——渲染状态和纹理映射
查看>>
OSG学习:WIN10系统下OSG+VS2017编译及运行
查看>>
OSG学习:人机交互——普通键盘事件:着火的飞机
查看>>
OSG学习:几何体的操作(一)——交互事件、简化几何体
查看>>
OSG学习:几何体的操作(二)——交互事件、Delaunay三角网绘制
查看>>
OSG学习:几何对象的绘制(一)——四边形
查看>>
OSG学习:几何对象的绘制(三)——几何元素的存储和几何体的绘制方法
查看>>
OSG学习:几何对象的绘制(二)——简易房屋
查看>>
OSG学习:几何对象的绘制(四)——几何体的更新回调:旋转的线
查看>>
OSG学习:场景图形管理(一)——视图与相机
查看>>
OSG学习:场景图形管理(三)——多视图相机渲染
查看>>
OSG学习:场景图形管理(二)——单窗口多相机渲染
查看>>
OSG学习:场景图形管理(四)——多视图多窗口渲染
查看>>
OSG学习:新建C++/CLI工程并读取模型(C++/CLI)——根据OSG官方示例代码初步理解其方法
查看>>
Sql 随机更新一条数据返回更新数据的ID编号
查看>>
OSG学习:空间变换节点和开关节点示例
查看>>
OSG学习:纹理映射(一)——多重纹理映射
查看>>