Linux基础学习-基本命令
基本命令
date命令
| 参数 | 作用 |
|---|---|
| %t | 跳格 |
| %H | 小时(00-23) |
| %I | 小时(00-12) |
| %M | 分钟(00-59) |
| %S | 秒(00-59) |
| %j | 今年中的第几天 |
[root@qdlinux Documents]# date
Fri Aug 31 22:05:03 CST 2018
[root@qdlinux Documents]# date "+%Y-%m-%d %H:%M-%S"
2018-08-31 22:05-57
[root@qdlinux Documents]# date "+%Y-%m-%d %I:%M-%S"
2018-08-31 10:06-38
[root@qdlinux Documents]# date "+%j"
243
wget命令
| 参数 | 作用 |
|---|---|
| -b | 后台下载模式 |
| -P | 下载到指定的目录 |
| -t | 最大尝试次数 |
| -c | 断点续传 |
| -p | 下载页面内所有资源,包括图片,视频等 |
| -r | 递归下载 |
[root@qdlinux Documents]# wget https://www. linux probe .com/docs/LinuxProbe.pdf
ps命令
| 参数 | 作用 |
|---|---|
| -a | 显示所有进程(包括其他用户的进程) |
| -u | 用户以及其他详细信息 |
| -x | 显示没有控制终端的进程 |
[root@qdlinux Documents]# ps -aux
top命令
- R:正在运行,正在为用户提供服务
- S:正在休眠,等待为用户提供服务
- D:进程不可中断
- Z:僵死,僵尸进程
- T:已经停止
[root@qdlinux Documents]# top
top - 22:17:38 up 3 days, 13:27, 3 users, load average: 0.02, 0.04, 0.07
Tasks: 208 total, 1 running, 207 sleeping, 0 stopped, 0 zombie
%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
KiB Mem : 2030172 total, 71556 free, 923720 used, 1034896 buff/cache
KiB Swap: 2097148 total, 1944316 free, 152832 used. 810872 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13292 root 20 0 2177072 204976 27668 S 1.0 10.1 52:20.88 firefox
560 root 20 0 320064 2836 2328 S 0.7 0.1 26:39.01 vmtoolsd
61616 root 20 0 161972 2320 1580 R 0.7 0.1 0:00.23 top
559 root 20 0 21664 964 804 S 0.3 0.0 2:53.58 irqbalance
2154 root 20 0 488996 20652 3216 S 0.3 1.0 8:46.37 containerd
2557 root 20 0 547932 29992 9424 S 0.3 1.5 14:19.50 dockerd
12950 root 20 0 731256 7456 2364 S 0.3 0.4 2:34.16 gsd-color
13092 root 20 0 402992 6844 2412 S 0.3 0.3 17:43.46 vmtoolsd
61020 root 20 0 0 0 0 S 0.3 0.0 0:11.00 kworker/0:0
1 root 20 0 125632 3492 2172 S 0.0 0.2 0:35.90 systemd
[root@qdlinux Documents]# uptime
22:29:43 up 3 days, 13:39, 3 users, load average: 0.02, 2.05, 2.42
[root@qdlinux Documents]# uname -a
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
[root@qdlinux Documents]# uname -snrvmpio
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
[root@qdlinux Documents]# free
total used free shared buff/cache available
Mem: 2030172 704064 106192 6116 1219916 1044096
Swap: 2097148 151296 1945852
[root@qdlinux Documents]# free -m
total used free shared buff/cache available
Mem: 1982 687 103 5 1191 1019
Swap: 2047 147 1900
[root@qdlinux Documents]# free -h
total used free shared buff/cache available
Mem: 1.9G 687M 103M 6.0M 1.2G 1.0G
Swap: 2.0G 147M 1.9G
[root@qdlinux Documents]# free -k
total used free shared buff/cache available
Mem: 2030172 704176 106060 6116 1219936 1043984
Swap: 2097148 151296 1945852
wc命令
| 参数 | 作用 |
|---|---|
| -l | 只显示行数 |
| -w | 只显示单词数 |
| -c | 只显示字节数 |
[root@qdlinux ~]# cat anaconda-ks.cfg | tr [a-z] [A-Z]
[root@qdlinux ~]# wc -l /etc/passwd
43 /etc/passwd
[root@qdlinux ~]# wc -w /etc/passwd
85 /etc/passwd
[root@qdlinux ~]# wc -c /etc/passwd
2245 /etc/passwd
[root@qdlinux ~]# stat initial-setup-ks.cfg
File: ‘initial-setup-ks.cfg’
Size: 1783 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 67157617 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-08-31 22:39:00.663764363 +0800
Modify: 2018-08-04 15:07:54.860635244 +0800
Change: 2018-08-04 15:07:54.860635244 +0800
Birth: -
[root@qdlinux ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@qdlinux ~]# cut -d: -f1 /etc/passwd
[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 {} \ ; | 后面可跟用于进一步处理搜索结果的命令 |
快照虚拟机网卡问题解决
[root@www ~]# rm -f /etc/udev/rules.d/70-persistent-net.rules
CentOS6中设置开机自启动
[root@www tools]# chkconfig --list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@www tools]# echo /etc/init.d/sshd start >> /etc/rc.local
[root@www tools]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/etc/init.d/sshd start
[root@www tools]# chkconfig --level 345 sshd off
[root@www tools]# chkconfig --list sshd
sshd 0:off 1:off 2:on 3:off 4:off 5:off 6:off
[root@www tools]# chkconfig --level 345 sshd on
[root@www tools]# chkconfig --list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
linux启动流程
- Bios自检
- MBR引导
0柱面0磁道1扇区 前446字节 - grub引导菜单
- 加载kernel
- 启动init进程
- 读取inittab文件
开启需要的服务
[root@www tools]# chkconfig --list | grep 3:on| egrep -v "sshd|sysstat|network|crond|rsyslog" | awk '{print "chkconfig",$1,"off"}'|bash
[root@www tools]# chkconfig --list | grep 3:on | awk '{print "chkconfig",$1,"off"}'
[root@www tools]# chkconfig --list | grep -E "sshd|rsyslog|network|sysstat|crond"|awk '{print "chkconfig",$1,"on"}'
awk命令
mkdir /tools
cat /etc/passwd > /tools/awkfile.txt
[root@www tools]# awk 'NR==1 {print NR,$1}' awkfile.txt
1 root:x:0:0:root:/root:/bin/bash
awk -F ":" 'NR>=2&&NR<=5{print $1,$3}' /tools/awkfile.txt
[root@www tools]# awk -F ":" 'NR==1 {print NR,$1,$NF}' awkfile.txt
1 root /bin/bash
[root@www tools]# awk 'NR>=2 && NR<=5 {print NR,$1,$5}' awkfile.txt
2 bin:x:1:1:bin:/bin:/sbin/nologin
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
4 adm:x:3:4:adm:/var/adm:/sbin/nologin
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
chgrp命令
[root@mail ~]# groupadd testgroup
[root@mail ~]# mkdir testdir
[root@mail ~]# ls
anaconda-ks.cfg testdir 公共 视频 文档 音乐
initial-setup-ks.cfg typechoDB.dump 模板 图片 下载 桌面
[root@mail ~]# ls -ld testdir
drwxr-xr-x. 2 root root 6 9月 8 19:37 testdir
[root@mail ~]# chgrp testgroup testdir
[root@mail ~]# ls -ld testdir
drwxr-xr-x. 2 root testgroup 6 9月 8 19:37 testdir
[root@mail ~]# chgrp -R testgroup testdir
[root@mail ~]# ls -l testdir
总用量 0
-rw-r--r--. 1 root testgroup 0 9月 8 19:38 test
Linux基础学习-基本命令的更多相关文章
- Linux基础学习系列目录导航
Linux基础学习-通过VM安装RHEL7.4 Linux基础学习-命令行与图形界面切换 Linux基础学习-基本命令 Linux基础学习-RHEL7.4之YUM更换CentOS源 Linux基础学习 ...
- linux基础学习之软件安装以及常用命令
linux基础学习之软件安装以及常用命令 调用中央仓库: yum install wget 然后下载nodejs: wget https://nodejs.org/dist/v10.14.2/node ...
- linux基础学习路线&review
linux基础学习网址: https://www.runoob.com/linux/linux-tutorial.html 比较重点的是这个启动过程的介绍学习:https://www.runoob.c ...
- Linux 基础学习1
目录 Linux 基础学习 用户登录 终端 交互式接口 bash 修改ssh连接慢的步骤 命令提示符 显示提示符格式 命令 别名 命令格式 获取命令的帮助信息 man bash 快捷键 tab 键 引 ...
- Linux 基础学习2
目录 Linux 基础学习2 文件目录结构 文件命名规范 文件系统结构 linux应用程序的组成 绝对路径和相对路径 目录名和基名 切换目录 切换到家目录 切换到上一次的目录 显示当前的工作目录 列出 ...
- Linux基础学习(全)
使用的Linux发行版本为Redhat 1.Linux(RedHat)基础学习-命令行使用入门 2.Linux(RedHat)基础学习-文件寻址与管理 3.Linux(RadHat)基础学习-vim编 ...
- Linux基础学习(1)--Linux系统简介
第一章——Linux系统简介 1.UNIX和Linux发展史: 1.1 unix发展史: (1)1965年,美国麻省理工学院(MIT).通用电气公司(GE)及AT&T的贝尔实验室联合开发Mul ...
- Linux基础学习笔记2-文件管理和重定向
本节内容 1)文件系统结构元素 2)创建和查看文件 3)复制.转移和删除文件 4)软和硬链接 5)三种I/O设备 6)把I/O重定向至文件 7)使用管道 文件系统和结构 文件系统 文件和目录被组织成一 ...
- Linux 基础学习(第二节)
free命令用于显示当前系统中内存的使用量信息,格式为:“free [-h]”. 为了保证Linux系统不会突然卡住宕机,因此内存使用量应该是运维人员时刻要关注的数据啦,咱们可以使用-h参数来以更人性 ...
随机推荐
- 使用MethodSwizzle导致按home app进入后台或者app间切换发生crash的解决方法
参考文章: 1.http://blog.csdn.net/alincexiaohao/article/details/45913857 2.http://www.cocoachina.com/ios/ ...
- MyBatis逆向工程中domainObjectRenamingRule报错或无效
使用domainObjectRenamingRule报错 在使用MyBatis逆向工程时报错如下: org.mybatis.generator.exception.XMLParserException ...
- java的无序机制
简单说一下上面提到的无序写,这是jvm的特性,比如声明两个变量,String a; String b; jvm可能先加载a也可能先加载b.同理,instance = new Singleton();可 ...
- java数据结构----数组篇
1.数组作为java常用的数据结构之一,使用相对简单,下图展示了数组常用操作在允许和不允许重复值的情况下的比较次数 2.进行封装后的代码: package com.cn.higharray; /** ...
- Caffe实战五(Caffe可视化方法:编译matlab接口)
接上一篇文章,这里给出配置caffe后编译matlab接口的方法.(参考:<深度学习 21天实战Caffe 第16天 Caffe可视化方法>) 1.将Matlab目录更新至Caffe的Ma ...
- 浅谈算法——AC自动机
在学习AC自动机之前,你需要两个前置知识:Trie树,KMP 首先我们需要明白,AC自动机是干什么的(用来自动AC的) 大家都知道KMP算法是求单字符串对单字符串的匹配问题的,那么多字符在单字符上匹配 ...
- HDU6301(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6301 队友AC的,没怎么看 #include<iostream> #incl ...
- Unity Shader入门精要学习笔记 - 第5章 开始 Unity Shader 学习之旅
一个顶点/片元 着色器的结构大概如下: Shader "MyShaderName" { Properties { //属性 } SubShader { //针对显卡A的SubSha ...
- 将Form以强类型Model提交,后台获取不到的问题
F.TextBoxFor(m => m.Name) 不能自定ID属性
- 浅谈Hibernate中的三种数据状态
Hibernate中的三种数据状态:临时.持久.游离 1.临时态(瞬时态) 不存在于session中,也不存在于数据库中的数据,被称为临时态. 数据库中没有数据与之对应,超过作用域会被JVM垃圾回收器 ...