Linux Command 2018-03-01 Update

Source: Internet
Author: User
Tags create directory

Introduction: Linux is mainly used in server-side, embedded development and personal PC desktop side
I WeChat:ywnlodaymzu5mtezmtq=.
***

Gpl

The GPL is an open source license agreement created by the Free Software Foundation. The core of the GPL license is to ensure that anyone has the freedom to share and modify free software, and that anyone has the right to obtain, modify and republish free software, but must also give the source code for the specific changes.


***

Service
开机启动的重要服务:sshd,rsyslog,network,crond,sysstatchkconfig --list # 列出所有系统服务chkconfig --list sshd # 查看ssh服务chkconfig --level 3 sshd off # on设置ssh在等级3为开机自启动服务,off为关闭# ssh服务/etc/ssh/sshd_configport 52113UseDNS noPermitRootLogin noListenAddress 192.168.1.17GSSAPIAuthentication no/etc/init.d/sshd restart
Common Commands 80

The Three Musketeers of Linux

grep "abc" test.txt test2.txt # 分离出含有abc字符串grep -v "abc" test.txt # 分离出不含abc字符串grep -E "[a-z]+" test.txt # 根据正则表达式分离# sed是一种流编辑器,处理时把当前处理的行放到临时缓冲区中,# 处理完成后把缓冲区内容送往屏幕,默认文件内容没有改变,除非使用重定向sed ‘s/hhh/aaa/‘ test.txt # 把每一行第一个hhh替换成aaased -i ‘s/hhh/aaa/g‘ test.txt # 把所有的hhh替换成aaa,-i参数改变文件内容sed ‘/^test/‘d test.txt # 删除所有开头是test的行sed ‘/^$/d‘ test.txt # 删除空白行sed ‘2d‘ test.txt # 删除第2行sed ‘$d‘ test.txt # 删除最后1行sed ‘2d,$d‘ test.txt # 删除第2到最后1行之间所有行sed -n ‘20,30p‘ test.txt # 打印文件20到30行之间的内容# 把递归查找到的所有test.txt中所有的alex替换成lemased -i ‘s/alex/lema/g‘ `find . -name "test.txt"` awk -F ‘:‘ ‘{print $NF,$(NF-1)}‘ /etc/passwd # 打印最后两列awk ‘{if(NR>19&&NR<31) print $0}‘ test.txt # 打印20到30行的整行内容

File Directory Management

################### #增 ################### #touch把已存在文件的时间更新为当前系统时间或者创建新文件cp sshd_config sshd_config.lema.20180301 # Backup Mkdir-p/home/lema/test/core # recursively create directory mkdir stu{1..100} # Create 100 directories ################### #删 ################### #rm-fr/## ################# #查 ################### #diff比较两个文本文件的不同, if the comparison is a directory compares two directories with the same file Vimdiff test.txt Test2.txttree Print the contents of the catalog in a tree view cat >>test.txt<<eof>aaa>bbb>eofhead-3 test.txtless Test.txtmore Test.txttail displays the last 10 lines of the specified file, and reads the standard input # by name in the specified directory if no file is specified find. -name "*.log"-o-iname "*.txt" #-o parameter indicates either,-a represents and find. ! -name "*.log"-O! -iname "*.txt" # Search files by file type and time find. -type f-atime-7 # Files visited in the last 7 days find. -type F-atime +7 # files that were visited before more than 7 days find. -type f-atime 7 # files accessed just 7 days ago Find/home/lema-type f-exec rm-f {} \;updatedblocate/etc/sh # Search All files starting with SH in the ETC directory, than the find Find faster # Do not search for specific directories but search database/var/lib/locatedb################### #改 ################### #mv剪切文件或重命名文件 >test.txt # empty file Contents # > redirect,>>,<< append input redirect,< input redirect # Standard input 0, standard normal output 1, standard error Output 2echo "HHH" 1>./test.txt 2>./test2.txt 

viewing system and hardware information

uname打印当前系统相关信息(内核版本号,硬件架构)[[email protected] ~]# uname -aLinux localhost 2.6.32-504.el6.i686 #1 SMP Wed Oct 15 03:02:07 UTC 2014 i686 i686 i386 GNU/Linux# 2表示主版本号,有结构性变化才更改,6表示次版本号,新增功能时才变化,# 32表示对次版本的修订次数或补丁包数,504代表编译的次数,el代表企业版Linuxenv # 显示系统已存在的环境变量

Rights Management

u:User,即文件或目录的拥有者;g:Group,即文件或目录的所属群组;o:Other,除了文件或目录拥有者或所属群组之外,其他用户皆属于这个范围;a:All,即全部的用户,包含拥有者,所属群组以及其他用户;r:读取权限,数字代号为“4”;w:写入权限,数字代号为“2”;x:执行或切换权限,数字代号为“1”;-:不具任何权限,数字代号为“0”;s:特殊功能说明:变更文件或目录的权限。chmod u+x,g+r test.txtchmod 770 test.txtchown -R lema test.txt # 改变某文件的所有者和所属组sudo # 在/etc/sudoers中设置了可执行sudo指令的用户visudo # vi /etc/sudoersroot   ALL=(ALL)      ALL # sudo su rootchattr +i /etc/passwd /etc/inittab # 改变文件属性 lsattr # 查看文件的第二扩展文件系统属性

Shell Management

xargs将标准输入数据转换成命令行参数cat test.txt|xargs -n3 # 格式化输出find /root/data -type f|xargs rm -fHISTSIZE=5 # 设置history只显示5条历史命令HISTFILESIZE=3 # 设置~/.bash_history文件中只保存3条历史命令history # 显示之前用过的命令!304unalias cp # 取消别名alias # 查看已经设置的别名whereis cd # 用来定位指令的二进制程序,源代码文件及man手册页的路径which chattrulimit -n # 限制用户对shell资源的访问

Software safety loading and unloading

# yum是在Fedora和redhat以及suse中基于rpm的软件包管理器,# 能够从指定的服务器自动下载rpm包并且安装,自动处理依赖关系。yum grouplist # 显示已安装程序组yum groupinstall # 安装程序组yum install tree -y # -y参数对所有的提问都回答yes# rpm是rpm软件包的管理工具rpm -ivh packagesname.rpmrpm -qa|grep sql # 检查是否安装带sql的软件包# apt-get是Debian Linux发行版中的apt软件包管理工具。Debian软件库存在互联网上的一些公共站点上,# /etc/apt/sources.list是存放这些地址列表的配置文件

Process Management

# init进程是所有Linux进程的父进程,进程号为1,系统中的第一个进程# ps报告当前系统的进程状态ps -e # 显示所有程序ps -ef |grep ssh # -f参数显示UID,PPIP,C与STIME栏位kill # 删除执行中的程序和工作

Network management

ping www.zhihu.com # 执行ping指令会使用ICMP传输协议,发出要求回应的信息测试网络连通性ifconfig eth0 downifconfig eth0 upifup eth0激活网络接口eth0ifdown eth0禁止指定的网络接口eth0/etc/init.d/network restart/etc/init.d/networking restartnetstat -lntup # 查看开放的端口

System Management

haltshutdown -h 11:50rebootrunlevel # 查看当前系统运行的级别init 6 # 进程初始化,切换到运行等级6#0 停机(绝对不能把initdefault设置为0)#1 单用户模式#2 多用户,没有NFS#3 完全多用户模式#4 没有用到#5 x11(Xwindows)#6 重新启动(绝对不能把initdefault设置为6)ntpdate ntp.api.bz # 时间同步date # 显示系统时间hwclock -w # 显示硬件时钟时间,-w参数与系统时钟同步

User Management

useradd lema -g a -G b # -g指定群组,-G指定附加群组passwd -l lema # 设置用户lema不能更改密码userdel -r lema # 删除用户连同其家目录文件su lema # 切换用户id lema # 显示用户id和组id

Other

seq -s ‘/‘ 1 2 10 # 产生奇数列setup # 启动图形界面设置系统配置服务# scp在Linux下远程拷贝文件,scp传输加密# 从远处复制文件到本地目录scp [email protected]:/home/lema/test.py /home/akast/# 从远处复制目录到本地目录scp -r [email protected]:/home/lema /home/akastlrzsz查看系统用户登录信息非常危险的系统命令基础网络操作深入网络操作搜索文件文件压缩及解压系统安全系统性能监视线上查询及帮助信息显示用户管理磁盘文件系统

Linux Command 2018-03-01 Update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.