1、將/etc/issue文件中的內容轉換為大寫后保存至/tmp/issue.out文件中
cat /etc/issue | tr 'a-z' 'A-Z' > /tmp/issue.out
2、將當前系統登錄用戶的信息轉換為大寫后保存至/tmp/who.out文件中
who am i |tr '[:lower:]' '[:upper:]' > /tmp/who.out
3、一個linux用戶給root發郵件,要求郵件標題為”help”,郵件正文如下:
Hello, I am 用戶名,the system
version is here,please help me to
check it ,thanks!
操作系統版本信息
[stu@localhost ~]$ mail -s help root <<end
>Hello, I am `whoami`.
>The system version is here.
>Please help me to check it,thanks
>`lsb_release`
>end
4、將/root/下文件列表,顯示成一行,并文件名之間用空格隔開
ls /root |tr '\n' ' '
5、file1文件的內容為:”1 2 3 4 5 6 7 8 9 10” 計算出所有數字的總和
echo $[`echo "1 2 3 4 5 6 7 8 9 10" |tr ' ' '+' `]
6、刪除Windows文本文件中的'^M'字符
cat ./Desktop/test.txt |tr -d '\r' > file.txt
7、處理字符串“xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4”,只保留其中的數字
和空格
echo 'xt.,l 1 jr#'\n'mn 2 c*/fe 3 uz 4' |tr -cd '[:digit:] \n'
8、將PATH變量每個目錄顯示在獨立的一行
echo $PATH |tr ':' '\n'
9、刪除指定文件的空行
cat file.txt |tr -s '\n'
10、將文件中每個單詞(字母)顯示在獨立的一行,并無空行
cat file.txt |tr -cs '[:alpha:]' '\n'
1、創建用戶gentoo,附加組為bin和root,默認shell為
/bin/csh,注釋信息為"Gentoo Distribution"
useradd -G bin,root -c "gentoo Distribution" -s /bin/csh gentoo ; id gentoo
2、創建下面的用戶、組和組成員關系
名字為admins 的組
用戶natasha,使用admins 作為附屬組
用戶harry,也使用admins 作為附屬組
用戶sarah,不可交互登錄系統,且不是admins 的成員,
natasha,harry,sarah密碼都是centos
4、創建testuser uid 1234,主組:bin,輔助組:root,ftp,shell:/bin/csh home:/testdir/testuser
useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser
5、修改testuser uid:4321,主組:root,輔助組:nobody,loginname:test,home:/home/test 家數據遷移
usermod -u 4321 -g root -G nobody,loginname,test -m /home/test testuser
6、批量創建帳號:user1…user10
uid:3000-3009,shell:/bin/csh,home:/testdir/username
passwd:usernamepass
注意家目錄相關配置,使用戶正常登錄
-
創建用戶添加文件
vi test.txt
2.添加用戶
newusers useradd.txt
3.創建密碼文件
vi pwadd.txt
4.為用戶添加密碼
cat pwadd.txt | chpasswd
原創文章,作者:zhanghuanyu,如若轉載,請注明出處:http://www.www58058.com/27150
第5題錯了