Linux Basics Exercises (ls,tr,useradd,usermod)

Source: Internet
Author: User
Tags stdin

0729 Exercises

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

[[Email protected] ~]# TR ' A-Z ' A-Z ' </etc/issue >/tmp/issue.out[[email protected] ~]# Cat/tmp/issue.out\skernel \ r on an \m

2, 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

[Email protected] ~]# Mail-s "help" root <<eofi am ' id-nu '; ' Cat/etc/centos-release ' EOF [[email protected] ~]# Cat A | Mail-s "HELP5" root [[email protected] ~]# mail-s "HELP6" root < b [[email protected] ~]# cat bi am Second

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

one [[email protected] ~]# ls/root/| TR "\ n" "" a anaconda-ks.cfg b C d fish-1.23.1-1.el6.rf.x86_64.rpm initial-setup-ks.cfg lntest lovers.txt Mail two [[EM AIL protected] ~]# ls/root/| Xargs

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

[[Email protected] ~]# file Ab.txt ab.txt:ASCII text, with CRLF line Terminators[[email protected] ~]# cat-a ab.txt a^m$ B^m$c[[email protected] ~]# cat-a ab.txt | Tr-d ' ^m ' a$b$

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

[email protected] ~]# Cat File1 | Tr ' + ' | Bc55

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

[Email protected] ~]# echo "Xt.,l 1 jr#file1mn2 c*/fe3 uz4" | TR-DC ' [0-9] ' 1 12 3 4

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

[Email protected] ~]# echo $PATH | Tr ': ' \ n '/usr/lib64/qt-3.3/bin/usr/local/sbin/usr/local/bin/sbin/bin/usr/sbin/usr/bin/root/bin

8. Delete blank lines of the specified file

[[email protected] ~]# tr-s ' [[: Space:]] ' < A s refers to merging multiple successive merges into one ABCEFG123AAABBBCCC

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

[Email protected] ~]# Cat/etc/fstab | Xargs | TR ' "\ n" ##/etc/fstab#createdbyanaconda

....

10, create user Gentoo, additional group is bin and root, the default shell is/BIN/CSH, the annotated message is "Gentoo distribution"

[Email protected] ~]# useradd-g bin,root-s/bin/csh-c "Gentoo good" Gentoo

11. Create the following user, group, and group memberships

Group with the name Admins

User Natasha, using admins as a subordinate group

User Harry, also use admins as a subordinate group

User Sarah, no interactive login system, and not a member of admins, Natasha,harry,sarah password is CentOS

[Email protected] ~]# useradd-g admins natasha && echo "CentOS" | passwd--stdin natashachanging password for user Natasha.passwd:all authentication tokens updated successfully. [Email protected] ~]# useradd-g admins Harry && echo "CentOS" | passwd--stdin harrychanging password for user Natasha.passwd:all authentication tokens updated successfully. [Email protected] ~]# useradd-s/sbin/nologin Sarah [email protected] ~]# echo "CentOS" | passwd--stdin Harry


This article is from the "Mylinux" blog, make sure to keep this source http://luxiangyu.blog.51cto.com/9976123/1833143

Linux Basics Exercises (ls,tr,useradd,usermod)

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.