Shell Basics Exercises Explained

Source: Internet
Author: User
Tags stdin uuid

1037774765 cloning

1. Create a user redhat with an ID number of 1001, a basic group like (Group ID 2002), and rent it near Linux.

Groupadd-g 2002 Like
Groupadd Linux
Useradd-u 1001-g 2002-g Linux Redhat

2. Create a user fedora with the note information for Fedora commuity, the default shell is SH

Man Useradd See-C is a comment

Useradd-c "Fedora commuity"-s/bin/sh Fedora

3. Modify the ID number of the Redhat to 3003, the basic group is Linux, the additional group is like and fedora

Groupadd Fedora
Usermod-u 3003-g linux-g Like,fedora Redhat

ID Redhat
Id-u Redhat

4. Lock the Fedora account after adding the password to fedora, then unlock the Fadora account

Usermod-l Redhat Lock
Usermod-u Redhat Unlock

5. Speak as Redhat password, and do not need to interact (neither give you a hint of the old and new password, and let you enter the password)
passwd Redhat

The following method is not required to enter the old password
passwd--stdin Redhat In addition to the above method, this can be entered once set the password successfully

The following methods can also be
Echo-e "\"-e means to turn into a carriage return function
Echo-e "\" |passwd Redhat

Echo-e " |passwd--stdin Redhat

6. Add System user HBase, do not allow login

Useradd-r-s/sbin/nologin HBase R stands for system users

grep hbase/etc/passwd

7. Create a new user with no home directory Apache

Useradd-m Apache

8. Copy the contents of the/etc/skel into the/home/apache
9. The familiar group of/home/apache and its internal documents is Apache

Chown apache:apache/home/apache/
ls-la/home/apache/here will see the root group is not right, you need the following
Chown-r apache:apache/home/apache/

10. Change the permission attributes of/home/apache and internal files, belonging to group and other users without
Any access rights, view Apache account attributes
What is the information that 11./ETC/PASSWD's file describes? What is the meaning of each field in each line of content?

What is the configuration file for 12.sudo? How to edit a configuration file
Visudo This can open this configuration file

13. What is the inode?
Save the directory, the attribute information of the file, including the owner, the group and three time, but also the specific block on the disk

14. You find that there are two reasons for insufficient disk space, either disk space is insufficient, or the inode is full
Du-h Viewing space
Du-i View Inode

15.fdisk-l/DEV/SDA list Disk All partitions * represents boot partition

16.blkid viewing UUID
Mount uuid= "Copy and paste"/mnt/using the UUID mount

19. How to automatically mount your CDROM boot to the/mnt/cdrom directory?


20.mount-t VFAT/DEV/SDD1 defines the file system of the USB flash drive, if it is not recognized

21. Check the operating status of the network card
Mii-tool eth0

You can use the MKPASSWD command to generate the password automatically under CentOS, the installation package name is expect
Mkpasswd-l 20 defines a password length of 20

How many mkpasswd-l 20-d numbers are there?

Mkpasswd-l 20-d-C 5-c 8-s 0 C is uppercase, C is lowercase, s special character

Find. -type f-size-4k |xargs du-sh Find files of 4k size

Find. MaxDepth 1-type f-size-4k in the current directory under the first-level directory search

Find. MaxDepth 1-type f-size-4k |xargs-i mv {}/tmp/

MV ' Find. MaxDepth 1-type f-size-4k '/tmp/and the above mean
The meaning of this symbol is that the result inside is a parameter of the preceding command

For C in a B C D E F g;do echo $c; Done sequentially output

For C in a B C D E F g;do tar czvf install.log. $c. tar.gz Install.log; Done

For C in {a.. g}; do echo $c; Done the same as above

Seq 1 10 columns of numbers

For i in {1..10}; do echo $i; Done

modifying remote connection Ports
Vi/etc/ssh/sshd_config find the port in there. Modifications can also be added

NETSTAT-LNP viewing the monitored ports

Srvice sshd status to view his status

Grub-md5-crypt MD5 generated password

Shell Basics Exercises Explained

Related Article

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: 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.