基本命令

date命令

参数 作用
%t 跳格
%H 小时(00-23)
%I 小时(00-12)
%M 分钟(00-59)
%S 秒(00-59)
%j 今年中的第几天
  1. [root@qdlinux Documents]# date
  2. Fri Aug 31 22:05:03 CST 2018
  3. [root@qdlinux Documents]# date "+%Y-%m-%d %H:%M-%S"
  4. 2018-08-31 22:05-57
  5. [root@qdlinux Documents]# date "+%Y-%m-%d %I:%M-%S"
  6. 2018-08-31 10:06-38
  7. [root@qdlinux Documents]# date "+%j"
  8. 243

wget命令

参数 作用
-b 后台下载模式
-P 下载到指定的目录
-t 最大尝试次数
-c 断点续传
-p 下载页面内所有资源,包括图片,视频等
-r 递归下载
  1. [root@qdlinux Documents]# wget https://www. linux probe .com/docs/LinuxProbe.pdf

ps命令

参数 作用
-a 显示所有进程(包括其他用户的进程)
-u 用户以及其他详细信息
-x 显示没有控制终端的进程
  1. [root@qdlinux Documents]# ps -aux

top命令

  • R:正在运行,正在为用户提供服务
  • S:正在休眠,等待为用户提供服务
  • D:进程不可中断
  • Z:僵死,僵尸进程
  • T:已经停止
  1. [root@qdlinux Documents]# top
  2. top - 22:17:38 up 3 days, 13:27, 3 users, load average: 0.02, 0.04, 0.07
  3. Tasks: 208 total, 1 running, 207 sleeping, 0 stopped, 0 zombie
  4. %Cpu(s): 0.5 us, 0.3 sy, 0.0 ni, 99.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
  5. KiB Mem : 2030172 total, 71556 free, 923720 used, 1034896 buff/cache
  6. KiB Swap: 2097148 total, 1944316 free, 152832 used. 810872 avail Mem
  7. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  8. 13292 root 20 0 2177072 204976 27668 S 1.0 10.1 52:20.88 firefox
  9. 560 root 20 0 320064 2836 2328 S 0.7 0.1 26:39.01 vmtoolsd
  10. 61616 root 20 0 161972 2320 1580 R 0.7 0.1 0:00.23 top
  11. 559 root 20 0 21664 964 804 S 0.3 0.0 2:53.58 irqbalance
  12. 2154 root 20 0 488996 20652 3216 S 0.3 1.0 8:46.37 containerd
  13. 2557 root 20 0 547932 29992 9424 S 0.3 1.5 14:19.50 dockerd
  14. 12950 root 20 0 731256 7456 2364 S 0.3 0.4 2:34.16 gsd-color
  15. 13092 root 20 0 402992 6844 2412 S 0.3 0.3 17:43.46 vmtoolsd
  16. 61020 root 20 0 0 0 0 S 0.3 0.0 0:11.00 kworker/0:0
  17. 1 root 20 0 125632 3492 2172 S 0.0 0.2 0:35.90 systemd
  1. [root@qdlinux Documents]# uptime
  2. 22:29:43 up 3 days, 13:39, 3 users, load average: 0.02, 2.05, 2.42

  1. [root@qdlinux Documents]# uname -a
  2. Linux qdlinux.com 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  3. [root@qdlinux Documents]# uname -snrvmpio
  4. Linux qdlinux.com 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  1. [root@qdlinux Documents]# free
  2. total used free shared buff/cache available
  3. Mem: 2030172 704064 106192 6116 1219916 1044096
  4. Swap: 2097148 151296 1945852
  5. [root@qdlinux Documents]# free -m
  6. total used free shared buff/cache available
  7. Mem: 1982 687 103 5 1191 1019
  8. Swap: 2047 147 1900
  9. [root@qdlinux Documents]# free -h
  10. total used free shared buff/cache available
  11. Mem: 1.9G 687M 103M 6.0M 1.2G 1.0G
  12. Swap: 2.0G 147M 1.9G
  13. [root@qdlinux Documents]# free -k
  14. total used free shared buff/cache available
  15. Mem: 2030172 704176 106060 6116 1219936 1043984
  16. Swap: 2097148 151296 1945852

wc命令

参数 作用
-l 只显示行数
-w 只显示单词数
-c 只显示字节数
  1. [root@qdlinux ~]# cat anaconda-ks.cfg | tr [a-z] [A-Z]
  2. [root@qdlinux ~]# wc -l /etc/passwd
  3. 43 /etc/passwd
  4. [root@qdlinux ~]# wc -w /etc/passwd
  5. 85 /etc/passwd
  6. [root@qdlinux ~]# wc -c /etc/passwd
  7. 2245 /etc/passwd
  1. [root@qdlinux ~]# stat initial-setup-ks.cfg
  2. File: initial-setup-ks.cfg
  3. Size: 1783 Blocks: 8 IO Block: 4096 regular file
  4. Device: 803h/2051d Inode: 67157617 Links: 1
  5. Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
  6. Access: 2018-08-31 22:39:00.663764363 +0800
  7. Modify: 2018-08-04 15:07:54.860635244 +0800
  8. Change: 2018-08-04 15:07:54.860635244 +0800
  9. Birth: -
  1. [root@qdlinux ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.5.1804 (Core)
  1. [root@qdlinux ~]# cut -d: -f1 /etc/passwd
  1. [root@qdlinux ~]# dd if=/dev/zero of=560_file count=1 bs=560M

grep命令

参数 作用
-b 将可执行文件当做文本文件来搜索
-c 仅显示找到的行数
-i 忽略大小写
-n 显示行号
-v 反向选择
-E

find命令

参数 作用
-name 匹配名称
-perm 匹配权限
-user 匹配所有者
-group 匹配所有组
-mtime -n +n 匹配修改内容的时间 (-n n天以内 +n n天以前)
-atime -n +n 匹配访问文件的时间 (-n n天以内 +n n天以前)
-ctime -n +n 匹配修改文件权限的时间 (-n n天以内 +n n天以前)
-nouser 匹配无所有者的文件
-nogroup 匹配无所有组的文件
-newer f1 !f2 匹配比文件f1新但比f2旧的文件
--type b/d/c/p/l/f 匹配文件类型
-size 匹配文件的大小
-prune 忽略某个目录
-exec {} \ ; 后面可跟用于进一步处理搜索结果的命令

快照虚拟机网卡问题解决

  1. [root@www ~]# rm -f /etc/udev/rules.d/70-persistent-net.rules

CentOS6中设置开机自启动

  1. [root@www tools]# chkconfig --list sshd
  2. sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  3. [root@www tools]# echo /etc/init.d/sshd start >> /etc/rc.local
  4. [root@www tools]# cat /etc/rc.local
  5. #!/bin/sh
  6. #
  7. # This script will be executed *after* all the other init scripts.
  8. # You can put your own initialization stuff in here if you don't
  9. # want to do the full Sys V style init stuff.
  10. touch /var/lock/subsys/local
  11. /etc/init.d/sshd start
  12. [root@www tools]# chkconfig --level 345 sshd off
  13. [root@www tools]# chkconfig --list sshd
  14. sshd 0:off 1:off 2:on 3:off 4:off 5:off 6:off
  15. [root@www tools]# chkconfig --level 345 sshd on
  16. [root@www tools]# chkconfig --list sshd
  17. sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

linux启动流程

  1. Bios自检
  2. MBR引导

    0柱面0磁道1扇区 前446字节
  3. grub引导菜单
  4. 加载kernel
  5. 启动init进程
  6. 读取inittab文件

开启需要的服务

  1. [root@www tools]# chkconfig --list | grep 3:on| egrep -v "sshd|sysstat|network|crond|rsyslog" | awk '{print "chkconfig",$1,"off"}'|bash
  2. [root@www tools]# chkconfig --list | grep 3:on | awk '{print "chkconfig",$1,"off"}'
  3. [root@www tools]# chkconfig --list | grep -E "sshd|rsyslog|network|sysstat|crond"|awk '{print "chkconfig",$1,"on"}'

awk命令

  1. mkdir /tools
  2. cat /etc/passwd > /tools/awkfile.txt
  3. [root@www tools]# awk 'NR==1 {print NR,$1}' awkfile.txt
  4. 1 root:x:0:0:root:/root:/bin/bash
  5. awk -F ":" 'NR>=2&&NR<=5{print $1,$3}' /tools/awkfile.txt
  6. [root@www tools]# awk -F ":" 'NR==1 {print NR,$1,$NF}' awkfile.txt
  7. 1 root /bin/bash
  8. [root@www tools]# awk 'NR>=2 && NR<=5 {print NR,$1,$5}' awkfile.txt
  9. 2 bin:x:1:1:bin:/bin:/sbin/nologin
  10. 3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
  11. 4 adm:x:3:4:adm:/var/adm:/sbin/nologin
  12. 5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

chgrp命令

  1. [root@mail ~]# groupadd testgroup
  2. [root@mail ~]# mkdir testdir
  3. [root@mail ~]# ls
  4. anaconda-ks.cfg testdir 公共 视频 文档 音乐
  5. initial-setup-ks.cfg typechoDB.dump 模板 图片 下载 桌面
  6. [root@mail ~]# ls -ld testdir
  7. drwxr-xr-x. 2 root root 6 9 8 19:37 testdir
  8. [root@mail ~]# chgrp testgroup testdir
  9. [root@mail ~]# ls -ld testdir
  10. drwxr-xr-x. 2 root testgroup 6 9 8 19:37 testdir
  11. [root@mail ~]# chgrp -R testgroup testdir
  12. [root@mail ~]# ls -l testdir
  13. 总用量 0
  14. -rw-r--r--. 1 root testgroup 0 9 8 19:38 test

Linux基础学习-基本命令的更多相关文章

  1. Linux基础学习系列目录导航

    Linux基础学习-通过VM安装RHEL7.4 Linux基础学习-命令行与图形界面切换 Linux基础学习-基本命令 Linux基础学习-RHEL7.4之YUM更换CentOS源 Linux基础学习 ...

  2. linux基础学习之软件安装以及常用命令

    linux基础学习之软件安装以及常用命令 调用中央仓库: yum install wget 然后下载nodejs: wget https://nodejs.org/dist/v10.14.2/node ...

  3. linux基础学习路线&review

    linux基础学习网址: https://www.runoob.com/linux/linux-tutorial.html 比较重点的是这个启动过程的介绍学习:https://www.runoob.c ...

  4. Linux 基础学习1

    目录 Linux 基础学习 用户登录 终端 交互式接口 bash 修改ssh连接慢的步骤 命令提示符 显示提示符格式 命令 别名 命令格式 获取命令的帮助信息 man bash 快捷键 tab 键 引 ...

  5. Linux 基础学习2

    目录 Linux 基础学习2 文件目录结构 文件命名规范 文件系统结构 linux应用程序的组成 绝对路径和相对路径 目录名和基名 切换目录 切换到家目录 切换到上一次的目录 显示当前的工作目录 列出 ...

  6. Linux基础学习(全)

    使用的Linux发行版本为Redhat 1.Linux(RedHat)基础学习-命令行使用入门 2.Linux(RedHat)基础学习-文件寻址与管理 3.Linux(RadHat)基础学习-vim编 ...

  7. Linux基础学习(1)--Linux系统简介

    第一章——Linux系统简介 1.UNIX和Linux发展史: 1.1 unix发展史: (1)1965年,美国麻省理工学院(MIT).通用电气公司(GE)及AT&T的贝尔实验室联合开发Mul ...

  8. Linux基础学习笔记2-文件管理和重定向

    本节内容 1)文件系统结构元素 2)创建和查看文件 3)复制.转移和删除文件 4)软和硬链接 5)三种I/O设备 6)把I/O重定向至文件 7)使用管道 文件系统和结构 文件系统 文件和目录被组织成一 ...

  9. Linux 基础学习(第二节)

    free命令用于显示当前系统中内存的使用量信息,格式为:“free [-h]”. 为了保证Linux系统不会突然卡住宕机,因此内存使用量应该是运维人员时刻要关注的数据啦,咱们可以使用-h参数来以更人性 ...

随机推荐

  1. dumpe2fs: Bad magic number in super-block

    今天使用tune2fs和dumpe2fs来查看文件系统信息,出现如下图所示错误提示: 解决方法: 1.原来tune2fs和dumpe2fs只能打开ext3/ext4等文件类型. dumpe2fs - ...

  2. hibernate下载

  3. c3p0连接池下载

  4. bootstrapValidator 常用的验证

    $("#表单ID").bootstrapValidator({ message: 'This value is not valid', excluded: [':disabled' ...

  5. centos7版本对比之前版本的部分命令差异

    centos7版本下的命令和之前的centos版本的命令有些许不同,最近在电脑上用VBox安装了一个centos7版本.在做一些网卡配置和安装mysql的时候遇到了一些问题.在这里总结跟大家分享下. ...

  6. mysql(MySQL客户端连接工具)

    在MySQL提供的工具中,DBA使用最频繁的莫过于mysql.这里的mysql不是指MySQL服务,也不是mysql数据库,而是连接数据库的客户端工具.类似于Oracle的sqlplus. 语法: m ...

  7. 094 Binary Tree Inorder Traversal 中序遍历二叉树

    给定一个二叉树,返回其中序遍历.例如:给定二叉树 [1,null,2,3],   1    \     2    /   3返回 [1,3,2].说明: 递归算法很简单,你可以通过迭代算法完成吗?详见 ...

  8. Codeforces Beta Round #12 (Div 2 Only) D. Ball 树状数组查询后缀、最值

    http://codeforces.com/problemset/problem/12/D 这里的BIT查询,指的是查询[1, R]或者[R, maxn]之间的最值,这样就够用了. 设三个权值分别是b ...

  9. 打包google浏览器插件到本地

    依次打开‘更多工具’--->'扩展程序',或者在google浏览器输入chrome://extensions/网址就可以打开已安装插件页面,在顶部选中‘开发者模式’后就会出现每个插件的ID,这个 ...

  10. bootstrop媒体对象、面板和Well

    媒体对象   <div class="media">     <div class="media-left">         < ...