首页 > 系统相关 >Linux常用命令(01)

Linux常用命令(01)

时间:2024-01-21 18:35:54浏览次数:31  
标签:opt 01 centos 常用命令 cd Linux test txt root

1.pwd

查看当前所在的位置 print working directory

查看当前root用户默认所在的位置
[root@centos ~]# pwd 输入命令
/root	 显示绝对路径
[root@centos ~]# 

2.ls

 ls      # 列出当前目录看下所有的文件

语法格式:
ls  直接回车  # 显示当前所在目录下所有的文件
ls  目录      # 指定显示某个目录下所有的文件
参数选项: ls -l 显示文件的详细信息
ls -l 有个外号: ll 当我们执行ll时实际系统为我们执行的是ls -l
        
注意: 以颜色区分 白色的为普通文件 类似windows的.txt文件
      蓝色为目录
	  
ls 直接回车 查看当前

[root@centos ~]# ls
anaconda-ks.cfg
[root@centos ~]# 


ls 指定查看/目录下所有文件 # / 根目录
[root@centos ~]# ls /
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr
[root@centos ~]#

3.cd

切换路径 change directory
语法结构:
		 cd  目录
		 cd  /目录/目录/目录

案例

 进入到/opt目录 绝对路径
# 注意空格
[root@centos ~]# cd /opt/
[root@centos opt]# cd / opt
[root@centos /]# pwd
/
[root@centos /]# cd / opt fiejf fjwifj afjie
[root@centos /]# 
[root@centos /]# 

[root@centos /]# cd /o pt
-bash: cd: /o: No such file or directory
[root@centos opt]# cd
进入到深层目录/etc/sysconfig/
[root@centos ~]# cd /etc/sysconfig/
[root@centos sysconfig]# pwd
/etc/sysconfig
[root@centos sysconfig]# 
然后快速回到家目录
方法1: cd直接回车
[root@centos sysconfig]# cd
[root@centos ~]# 
方法2: 使用绝对路径回家
[root@centos sysconfig]# pwd
/etc/sysconfig
[root@centos sysconfig]# cd /root
[root@centos ~]# pwd
/root
方法3: 使用~回家
[root@centos sysconfig]# cd ~
[root@centos ~]# 

4.mkdir

创建目录 make directory语法结构:
	   mkdir  zzz                     # 在当前创建zzz目录
	   mkdir -p zzz/test/www    # 创建多级目录

案例

 在当前目录创建一个test目录

[root@centos ~]# mkdir test
[root@centos ~]# ll
total 8
-rw-------. 1 root root 1522 Feb 22 16:41 anaconda-ks.cfg
-rw-r--r--. 1 root root  158 Feb 24 10:55 hosts
drwxr-xr-x. 2 root root    6 Feb 24 11:18 test

[root@centos ~]# mkdir test
mkdir: cannot create directory ‘test’: File exists

mkdir 无法创建目录test 文件已存在

5.touch

创建普通文件 摸 类似windows创建的txt文档
         如果不存在则创建
         如果文件存在则更新文件的时间,不影响文件内容
  语法结构:
  		  touch 文件   # 在当前创建一个文件
  		  touch 文件1 文件2 文件3  # 一次创建多个文件
  		  touch /opt/test.txt   # 在指定目录下创建test.txt

案例

 在当前创建一个test.txt
[root@centos ~]# touch test.txt
[root@centos ~]# 
[root@centos ~]# ll
total 0
-rw-r--r--. 1 root root 0 Feb 24 12:00 test.txt

6.tree

tree命令: 
# 语法结构:    tree 目录/路径
[root@centos ~]# tree /opt/
/opt/
├── bbs
│   ├── 1.txt
│   └── 2.txt
├── blog
│   ├── 1.txt
│   └── 2.txt
└── www
    ├── 1.txt
    └── 2.txt

3 directories, 6 files

# -L显示最大深度等级为1级(默认显示所有的深度)
[root@centos ~]# tree -L 1 /opt/
/opt/
├── bbs
├── blog
└── www

7.帮助手册man help

#### 1.man cp

man   空格 命令
空格: 一次翻一页
f   : 一次往下翻一页
b   : 一次网上翻一页
↓  : 一次一行
↑  : 一次一行
q  : 退出帮助 quit

#### 2.help

help cd

8.shutdown

[root@centos ~]# shutdown		# 关机
[root@centos ~]# poweroff	    # 立刻关机
[root@centos ~]# halt		    # 立刻关机
[root@centos ~]# init 0          # 立刻关机
[root@centos ~]# reboot			# 重启操作系统



[root@centos ~]# shutdown -c     # 取消关机
[root@centos ~]# shutdown -h 5   # 5分钟后关机
[root@centos ~]# shutdown -h now # 立刻关机

9.重启

reboot 

init 6 

shutdown -r

标签:opt,01,centos,常用命令,cd,Linux,test,txt,root
From: https://www.cnblogs.com/liuzhonghua1/p/17978125

相关文章

  • 一本通金牌导航 分治法 E.工程划分 / P5290 [十二省联考 2019] 春节十二响(启发式合并)
    题目传送门题意简述:将树上\(n\)个点划分为若干个集合,使得集合中的点两两没有祖孙关系。一个集合的权值是集合内点的权值的最大值,求所有集合的权值之和的最小值。首先这题有个非常显然的贪心:将几个权值大的点尽可能的合并到一个集合中是更优的。集合中的点两两没有祖孙关系,说......
  • Linux常见的系统目录及作用
    /bin:存放可执行的二进制文件,包括常用的系统命令,如ls、cp等。/dev:包含设备文件,用于与硬件设备进行交互,如磁盘、键盘、鼠标等。/home:用户主目录的基本位置,每个用户通常在此目录下有一个对应的子目录。/mnt:用于挂载外部设备的目录,如光驱、USB设备等。/proc:虚拟文件系统,提供了有......
  • linux 键盘按键坏了怎么改键?
    方法一:通过/usr/share/X11/xkb/keycodes/evdev直接改(不推荐)参考:https://blog.csdn.net/L141210113/article/details/106616629方法二:使用xmodmap工具(推荐)参考:https://www.cnblogs.com/yinheyi/p/10146900.htmlvim~/.bashrc添加:if[-f~/.Xmodmap];thenxmodmap~/......
  • 20230120
    A.真实排名分类当前选手是否被操作,组合#include<bits/stdc++.h>usingnamespacestd;#defineintlonglong#defineullunsignedlonglong#defineALL(a)(a).begin(),(a).end()#definepbpush_back#definemkmake_pair#definepiipair<int,int>#definepisp......
  • Linux 中 使用set 给shell脚本设置参数
     001、[root@PC1test1]#ls##准备两个测试文件a.shb.sh[root@PC1test1]#cata.sh##a文件#!/bin/bashecho$*[root@PC1test1]#catb.sh##b文件#!/bin/bashsetonetwothreeecho$*[root@P......
  • linux之线程互斥(万字长文详解)
    linux之线程互斥多线程在访问共享资源时的问题假如我们设置一个全局变量!inttickets=1000;//充当有1000张票void*getTicket(void*args){std::stringusername=static_cast<constchar*>(args);while(true){if(tickets>0){......
  • 45个经典Linux面试题!赶紧收藏!
    问题一:绝对路径用什么符号表示?当前目录、上层目录用什么表示?主目录用什么表示?切换目录用什么命令?答案:绝对路径:如/etc/init.d当前目录和上层目录:./../主目录:~/切换目录:cd问题二:怎么查看当前进程?怎么执行退出?怎么查看当前路径?答案:查看当前进程:ps执行退出:exit查看当前路径:pwd问题三......
  • Linux 系统中 $* 和 $@的区别和联系
     001、两者都可以表示shell脚本的所有参数,两者没有差异(不管是否增加双引号) 举例:a、不加双引号[root@PC1test1]#ls##准备了两个测试脚本a.shb.sh[root@PC1test1]#cata.sh##a.sh的内容如......
  • 前端学习-简单项目练习01-小兔鲜
    一些笔记使用flex-wrap换行(一行一个元素)ul{display:flex;flex-wrap:wrap;}ulli{flex:100%;}html中让img撑满整个divdiv要设置宽高,img也要有宽高且均为100%,最重要的是img要给display:block。<divid="mainDiv"style="width:100%;height:100%">......
  • Linux内核accept系统调用源码分析
    内核版本:Linux3.10内核源码地址:https://elixir.bootlin.com/linux/v3.10/source(包含各个版本内核源码,且网页可全局搜索函数)一、应用层-accept()函数/***sockfd:监听socket的文件描述符*addr:存放地址信息的结构体的首地址(用来保存客户端的IP、Port)*addrlen:存放地......