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参数来以更人性 ...
随机推荐
- iOS 7:漫谈#define 宏定义(转)
iOS :漫谈#define 宏定义 #define宏定义在C系开发中可以说占有举足轻重的作用.底层框架自不必说,为了编译优化和方便,以及跨平台能力,宏被大量使用,可以说底层开发离开define将寸步 ...
- android 一些常用权限
<!-- 网络访问权限 --> <uses-permission android:name="android.permission.INTERNET" /> ...
- Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured.
在搭建Hadoop集群的时候,遇到了这样的一个报错. 就在启动HDFS调用命令: start-dfs.sh 的时候,报错: 然后输密码就一直很奇怪,反正一直运行不成功. 百度了半天,确定是core-s ...
- 086 Partition List 分隔链表
给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前.你应当保留两个分区中每个节点的初始相对位置.例如,给定1->4->3->2-&g ...
- axios 在vue中使用
下载组件: npm install axios --save npm install qs --save //处理对象防止产生跨域问题 引入: 新建axios文件夹,文件下新建index.js文件 i ...
- [已读]javascript语言精粹
又是一本广为赞颂的好书,当时才刚开始学,啃这本书的时候于是比较困难.记得是有介绍一些js中的“精华”与“糟粕”.
- Ubuntu安装LAMP
1.安装apache2 sudo apt-get install apache2 sudo apt-get install apache2 Apache安装成功后,/var/www/默认作为web的根 ...
- JavaScript数据格式验证探讨
1.需求 修改某个文本框数据,要求对修改后的格式做验证(必须是数字). 注:实际需求比上述复杂,为了说明问题,这里特意简化了需求(如:对修改后数据依赖条件的判断,数据入库等). 2.关于NaN的探讨( ...
- Java、Node.js、PHP还是.Net? 无论你选谁,我都能教你一招!
七夕如期而至,不该来的终究还是来了.再傲娇的单身贵族恐怕也难免在今天会感觉一丝丝的空虚.还好你关注了我,因为接下来我准备了三大招教你一个人…..也可以优雅地过七夕. 招式一:移形幻影,无中生有 七夕当 ...
- SQL 时间日期函数
1.获取当前日期GetDate getdate()函数以datetime数据类型的格式返回当前SQLServer服务器所在计算机的日期和时间.其语法格式为getdate().返回值舍入到最近的秒小数部 ...