Linux Common Command Combat practice

Source: Internet
Author: User

1. Display all files or directories with L, ending with a lowercase letter, and with at least one digit in the middle of the/var directory

ls-d/var/l*[0-9]*[[:lower:]) or ls-d/var/l*[[:d igit:]]*[[:lower:]]

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/85/4C/wKioL1efUmSDwMy5AAANCgN7T5c410.png "title=" r8l " 1e62_cj6un5a9{7{[yn.png "alt=" Wkiol1efumsdwmy5aaancgn7t5c410.png "/>

2. display files or directories that start with any digit in the/etc directory and end with a non-digit

LS/ETC/[0-9]*[^0-9] or ls-d/etc/[[:d igit:]]*[^[:d igit:]]

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/4C/wKioL1efVGSDpe6eAAAKv4-dFlM727.png "title=" OU) 5 ' fdn$[~) 14veortgti3.png "alt=" Wkiol1efvgsdpe6eaaakv4-dflm727.png "/>

3, display/etc/directory with a non-letter beginning, followed by a letter and any other arbitrary length of any character file or directory

ls/etc/[^[:alpha:]][[:alpha:]]*

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/85/4C/wKiom1efVjagbqjtAAAMKf7-V8A633.png "title="% 78x103ip7_0t4anb[[p1nv.png "alt=" Wkiom1efvjagbqjtaaamkf7-v8a633.png "/>

4. Display all files or directories in/etc that start with a non-numeric end of M

ls-d/etc/m*[^[:d igit:]] or ls-d/etc/m*[^0-9]

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/85/4C/wKioL1efVv3ShOHmAAAr-4QUT78394.png "title=" je_r{ 1k3i[7lmun]ra ' 94uh.png "alt=" Wkiol1efvv3shohmaaar-4qut78394.png "/>

5. Display all files or directories ending with. D in the/etc directory

Ls-d/ETC/*.D

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/4C/wKiom1efV1LwWakGAAAl6WWhbn8985.png "title=" w6~ " Xt51pd7o{5da ') ul8}x.png "alt=" Wkiom1efv1lwwakgaaal6wwhbn8985.png "/>

6. Display the files or directories with the end of. conf and beginning with m,n,r,p in the/etc directory

Ls-d/etc/[mnrp]*.conf

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/85/4C/wKiom1efV6vzHmBtAAAfbANcd_U032.png "title=" 3XZUVBC ' B~ba1$bv1bfyv$v.png "alt=" Wkiom1efv6vzhmbtaaafbancd_u032.png "/>

1. Convert the contents of the/etc/issue file to uppercase and save to the/tmp/issue.out file

Tr ' A-Z ' A-Z ' </etc/issue &>/tmp/issue.out

tr [A-z] [a-z] </etc/issue >/tmp/issue

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/4C/wKioL1efWByDz9ZbAAARrolxRGo309.png "title=" 70X} $A %13i] $IT 8t2~4fqi1.png "alt=" Wkiol1efwbydz9zbaaarrolxrgo309.png "/>

2. Convert the current system login user's information to uppercase and save to the/tmp/who.out file

W.H.O. | Tr ' A-Z ' A-Z ' >/tmp/who.out

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/85/4C/wKioL1efWJGSbbeAAAAPHDUGAoc863.png "title=" p}%~6c _}c_{s ' 85$u9 ' zg}s.png "alt=" Wkiol1efwjgsbbeaaaaphdugaoc863.png "/>

3, a Linux user to the root email, request the message titled "Help", the message body is as follows:

Hello, I am Username, the system version is here,pleasehelp me to check it, thanks!

Operating system Version Information

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/85/4C/wKioL1efWWWyJaVCAABXy_tGDyo979.png "title=" {TK} Szzq}dwceu7uw}8_ts1.png "alt=" Wkiol1efwwwyjavcaabxy_tgdyo979.png "/>

echo "Hello, I am $HOSTNAME, the system version is here,please help me check it thanks! ' Cat/etc/redhat-release ' "|mail-s help root


echo "Hello, I am ' uname-n ', the system Versionis here,please help me check it thanks! ' Cat/etc/redhat-release ' "|mail-s help root

4, the/root/file list, displayed as a line, and the file name separated by a space

Ls-a/root/| TR "\ n" ""

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/85/4C/wKioL1efWpnwAECmAAAX7T89ZQE521.png "title="%6od@@ [{) 9ewehc~rtsye33.png "alt=" Wkiol1efwpnwaecmaaax7t89zqe521.png "/>

5. The contents of the File1 file are: "1 2 3 4 5 6 7 8 9 10" Calculates the sum of all numbers



6. Remove the ' ^m ' character from the Windows text file


Cat file.txt|tr-d "^m"


7, processing string "Xt.,l 1 jr#! $mn 2 c*/fe3 uz4", keep only the numbers and spaces

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/85/4F/wKiom1ef-BTAsY81AABCxUCJJcE806.png "title=" i]}d) DIAUYK) D%GEN@GN4C1.png "alt=" Wkiom1ef-btasy81aabcxucjjce806.png "/>

8. Display the path variable in a separate row for each directory

echo $PATH |tr ":" \ n "

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/85/4D/wKioL1efW2ejm0O7AAARzkag_vU543.png "title=" LXEZ7 ( t%ewjgg7@% (ua%6%r.png "alt=" Wkiol1efw2ejm0o7aaarzkag_vu543.png "/>

9. Delete blank lines of the specified file

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/4F/wKiom1ef9tGxmUcNAAAbYM0Vc4w963.png "title=") zqq~ g39% ($2[hl%rzfwv (3.png "alt=" Wkiom1ef9tgxmucnaaabym0vc4w963.png "/>


10. Display each word (letter) in the file in a separate line with no blank lines

Cat File.txt | Tr-s "" \ n "

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/85/4F/wKiom1ef7CjzaaxcAAAZ7QtQV3s080.png "title=" D1vy6) ({{u8s__ ' r36dw6.png "alt=" Wkiom1ef7cjzaaxcaaaz7qtqv3s080.png "/>

1. Create TestUser UID 1234, main group: Bin, Auxiliary Group: ROOT,FTP,SHELL:/BIN/CSH Home:/testdir/testuser


Useradd testuser-u 1234-g bin-g root,ftp-s/bin/csh-d/testdir/testuser

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/85/4F/wKiom1ef6krDIaCVAAAebAiRqfU210.png "title=" i%9k1$ Njcraj2a4$f8sej}h.png "alt=" Wkiom1ef6krdiacvaaaebairqfu210.png "/>

2, modify TestUser uid:4321, main group: root, Auxiliary Group: Nobody,loginname:test,home:/home/test Home Data migration

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/85/4F/wKiom1ef6wvxcltBAAAnr0IYRcs706.png "title="}s_98~ 9HZW) o[qr670a${1b.png "alt=" Wkiom1ef6wvxcltbaaanr0iyrcs706.png "/>

Usermod-u 4321-g root-g nobody-l "test"-d/home/test-m testuser

Usermod-u 4321-g root-g nobody-l test-d/home/test-m testuser


3, Batch create account: User1...user10

Uid:3000-3009,shell:/bin/csh,home:/testdir/username

Passwd:usernamepass

This article is from "Wake up your not alarm clock but dream" blog, please be sure to keep this source http://purify.blog.51cto.com/10572011/1833352

Linux Common Command Combat practice

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.