1. Convert the contents of the/etc/issue file to uppercase and save to the/tmp/issue.out file
[Email protected]/]# Cat/etc/issue | Tr ' A-Z ' A-Z ' >/tmp/issue.out[[email protected]/]# cat/tmp/issue.out CENTOS RELEASE 6.8 (FINAL) KERNEL \ r on an \m
2. Convert the current system login user's information to uppercase and save to the/tmp/who.out file
[email protected]/]# who | Tr ' A-Z ' A-Z ' >/tmp/who.out[[email protected]/]# cat/tmp/who.out ROOT pts/0 2016-08-02 17:54 (192.168.99 .1)
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,please help me to check it, thanks!
Operating system Version Information
[Email protected] ~]$ echo-e "hello,i am ' whoami ', the system version is Here,please help me to check it,thanks! \ n ' cat/etc/centos-release ' | Mail-s Help Root
4, the/root/file list, displayed as a line, and the file name separated by a space
[Email protected]/]# Ls-a/root/| Tr ' \ n '. .. Aa.log anaconda-ks.cfg. bash_history. Bash_logout bash_profile bashrc. CSHRC file1 install.log Install.log.syslog. Lesshst Mail. tcshrc. Viminfo. Xauthority
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] ~]# echo $[' cat file1 | tr-t ' + ']55[[email protected] ~]# cat File1 | Tr-t ' + ' | 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#bcmn2 c*/fe3 uz4" | TR-CD ' [:d igit:] ' 1 2 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 the extra blank line of the specified file
[[email protected] ~]# cat Aa.log Hello, I am root, my OS is CentOS Release 6.8 (Final) [[email protected] ~]# CA T Aa.log | Tr-s ' [: space:] ' Hello, I am root, my OS is CentOS Release 6.8 (Final)
9. Display each word (letter) in the file in a separate line with no blank lines
[email protected] ~]# Cat Aa.log | Tr-cs ' [: Alpha:] ' \ n ' helloiamrootmyosiscentosreleasefinal
10. Create testuser user, require UID 1234, main group: Bin, Auxiliary Group: ROOT,FTP,SHELL:/BIN/CSH Home:/testdir/testuser
[Email protected] testuser]# useradd-u 1234-g bin-g root,ftp-s/bin/csh-d/testdir/testuser testuser[[email protecte D] testuser]# ID testuseruid=1234 (testuser) gid=1 (BIN) group =1 (BIN), 0 (Root), (FTP) [[email protected] testuser]# getent passwd testusertestuser:x:1234:1::/testdir/testuser:/bin/csh
11, modify testuser user, request uid:4321, main group: root, Auxiliary group: Nobody, Login user name: Test, home directory:/home/test and home data migration
[Email protected] testuser]# usermod-u 4321-g root-g nobody-l test-d/home/test-m testuser[[email protected] test]# Getent passwd testtest:x:4321:0::/home/test:/bin/csh[[email protected] test]# ID testuid=4321 (test) gid=0 (root) group =0 ( Root), (nobody)
12, Batch Create account: User1...user10, request uid:3000-3009,shell:/bin/csh, home directory:/testdir/username
User password: Usernamepass
(1) Create User batch files
[[email protected]/]# vim Userlist[[email protected]/]# cat userlist user1:x:3000:3000::/home/user1:/bin/cshuser2:x : 3001:3001::/home/user2:/bin/cshuser3:x:3002:3002::/home/user3:/bin/cshuser4:x:3003:3003::/home/user4:/bin/ CSHUSER5:X:3004:3004::/HOME/USER5:/BIN/CSHUSER6:X:3005:3005::/HOME/USER6:/BIN/CSH, user7:x:3006:3006::/home/ user7:/bin/cshuser8:x:3007:3007::/home/user8:/bin/cshuser9:x:3008:3008::/home/user9:/bin/cshuser10:x:3009:3009 ::/home/user10:/bin/csh
(2) using the NewUsers command to call the user batch file
[Email protected]/]# newusers userlist [[email protected]/]# getent passwd...user1:x:3000:3000::/home/user1:/bin/ cshuser2:x:3001:3001::/home/user2:/bin/cshuser3:x:3002:3002::/home/user3:/bin/cshuser4:x:3003:3003::/home/ USER4:/BIN/CSHUSER5:X:3004:3004::/HOME/USER5:/BIN/CSHUSER6:X:3005:3005::/HOME/USER6:/BIN/CSHUSER7:X:3006:3006: :/home/user7:/bin/cshuser8:x:3007:3007::/home/user8:/bin/cshuser9:x:3008:3008::/home/user9:/bin/cshuser10:x : 3009:3009::/home/user10:/bin/csh
(3) Copy the user's home directory, the home directory template file in the/etc/skel directory
[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user1[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user2[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user3[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user4[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user5[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user6[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user7[[email protected] etc]# cp -r /etc/skel/. [^.] * /home/user8[[email protected] etc]# cp -r /etc/skel/. [^.] * /HOME/USER9[[EMAIL PROTECTED] USER1]# LS -A /HOME/USER1. &NBSP, .... .bash_logout .bash_profile .bashrc .gnome2
(4) Create user password
[Email protected] user1]# echo User1 | passwd--stdin user1 Change the password for the user user1. PASSWD: All the authentication tokens have been successfully updated. [Email protected] user1]# echo user2 | passwd--stdin user2 Change the password for the user user2. PASSWD: All the authentication tokens have been successfully updated. ... [Email protected] user1]# echo user10 | passwd--stdin user10 Change the password for the user user10. PASSWD: All the authentication tokens have been successfully updated.
This article is from the "Linux Operational Learning path" blog, please be sure to keep this source http://fengliang.blog.51cto.com/3453935/1833695
Basic command exercises and user management exercises