Linux notes Two

Source: Internet
Author: User

Users and Groups

Add a Tom user, set it to belong to the Users group, and add comment information
Step through: Useradd Tom
Usermod-g users Tom
Usermod-c "HR Tom" Tom
One-Step completion: Useradd-g users-c "hr Tom" Tom

Set the password for the Tom user
passwd Tom

Change Tom User's login name to Tomcat
Usermod-l Tomcat Tom

Add tomcat to the SYS and root groups
Usermod-g Sys,root Tomcat

View the group information for Tomcat
Groups Tomcat

Add a Jerry user and set a password
Useradd Jerry
passwd Jerry

Add a cross-America group
Groupadd America

Add Jerry to the America group
Usermod-g America Jerry

Remove the Tomcat user from the root group and the SYS group
gpasswd-d Tomcat Root
gpasswd-d Tomcat SYS

Modify the America group name to AM
Groupmod-n am America

Permissions

Create A.txt and B.txt files, set them to their owner and group writable, but not others:
chmod ug+w,o-w a.txt B.txt

Create C.txt file Everyone can write and execute
chmod a=wx c.txt or chmod 666 c.txt

Set all files and subdirectories in the/itcast directory to be readable by anyone
Chmod-r A+r/itcast

The owner of all files and subdirectories under the/itcast directory is set to root, and the user has a group of users
Chown-r Root:users/itcast

Sets all files in the current directory and subdirectories to Itcast, set to users
Chown-r Itcast:users *

Folder properties

1. View folder properties
LS-LD Test

2. Rwx of the folder
--x: Can CD in
R-x: Can CD in and LS
-WX: Can CD in and touch,rm own files, and can vi other user's files
-WT: You can CD in and touch,rm your files

Ls-ld/tmp
The DRWXRWXRWT permission value is 1777 (sticky)

Vim

Insert command:

Positioning mode

Delete command:

Replace and Cancel commands:

Common shortcut keys

0: Beginning of the current line of the file
$: The end of the current line of the file
G: Start of the last line of the file
1 + G to first line
9 + G to line Nineth =: 9

DD: Delete a row
3DD: Delete 3 rows
YY: Copy one line
3yy: Copy 3 rows
P: Paste
U:undo
CTRL + R:redo

"A shear plate a
"B Shear Plate B

The AP pastes the contents of the Clipboard A

Every time you enter VI, there's a line number.
VI ~/.VIMRC
Set Nu

: W a.txt Save As
: w >> a.txt content append to A.txt

: e! restored to its original state

: 1, $s/hadoop/root/g replace hadoop with Root on the first line to the Chase line
: 1, $s/hadoop/root/c replace the first line of Hadoop with the following line with root (hint)

Installing the Software

1. Installing the JDK
* Add Execute permission
chmod u+x Jdk-7u45-linux-i586.bin
* Unzip
./jdk-7u45-linux-i586.bin
* Create a Java directory in the/usr directory
Mkdir/usr/java
* Cut the extracted jdk1.7.0_45 from the/soft directory into the/usr/java directory
MV jdk1.7.0_45//usr/java/
* Add Environment variables
Vim/etc/profile
* Added at the end of the/etc/profile file
Java_home=/usr/java/jdk1.7.0_45
Export path= $JAVA _home/bin: $PATH
* Update Configuration
Source/etc/profile

2. Install Tomcat
Tar-zxvf/soft/apache-tomcat-7.0.47.tar.gz-c/programs/
cd/programs/apache-tomcat-7.0.47/bin/
./startup.sh

Find

1. Find the executable command:
which LS

2. Find the location of the executable commands and help:
Whereis ls

3. Find files (need to update Library: updatedb)
Locate Hadoop.txt

4. Start a search from a folder
Find/-name "hadooop*"
Find/-name "hadooop*"-ls

5. Find and delete
Find/-name "hadooop*"-ok rm {} \;
Find/-name "hadooop*"-exec rm {} \;

6. Find files for Hadoop for users
Find/usr-user Hadoop-ls

7. Find the file that the user is Hadoop and (-a) has a group root
Find/usr-user hadoop-a-group Root-ls

8. Look for a file with a user who has a group root and is a folder type for Hadoop or (-O)
Find/usr-user hadoop-o-group root-a-type D

9. Find a file with a permission of 777
Find/-perm-777-type D-ls

10. Show Command History
History

11.grep
grep Hadoop/etc/password

Packaging and compression

1.gzip compression
Gzip A.txt

2. Unzip
Gunzip a.txt.gz
Gzip-d a.txt.gz

3.BZIP2 compression
Bzip2 A

4. Unzip
BUNZIP2 a.bz2
Bzip2-d a.bz2

5. Package the files of the current directory
TAR-CVF Bak.tar.
Append the/etc/password file to the Bak.tar (R)
TAR-RVF Bak.tar/etc/password

6. Unzip
TAR-XVF Bak.tar

7. Package and Compress gzip
TAR-ZCVF a.tar.gz

8. Unzip
TAR-ZXVF a.tar.gz
Unzip to the/usr/.
TAR-ZXVF a.tar.gz-c/usr

9. View the contents of a compressed package
TAR-ZTVF a.tar.gz

Zip/unzip

10. Package and compress into bz2
TAR-JCVF a.tar.bz2

11. Unzip the BZ2
TAR-JXVF a.tar.bz2

Regular expressions

1.cut intercept to: divide and retain the seventh paragraph
grep hadoop/etc/passwd | Cut-d:-f7

2. Sorting
Du | Sort-n

3. Queries that do not contain Hadoop
Grep-v hadoop/etc/passwd

4. Regular expression contains Hadoop
grep ' Hadoop '/etc/passwd

5. Regular expression (dots represent any one character)
grep ' H.*p '/etc/passwd

6. Regular expression begins with Hadoop
grep ' ^hadoop '/etc/passwd

7. Regular expressions End with Hadoop
grep ' hadoop$ '/etc/passwd

Rules:
. : any one character
A *: Any number of a (0 or more a)
A? : 0 or one A
A +: one or more a
. *: Any number of arbitrary characters
\. Escape.
\O\{2\}: o repeat two times

grep ' ^i.\{18\}n$ '/usr/share/dict/words

Find lines that do not start with #
Grep-v ' ^# ' a.txt | Grep-v ' ^$ '

Starting with H or R
grep ' ^[hr] '/etc/passwd

Not starting with H and R.
grep ' ^[^hr] '/etc/passwd

Not starting with H to R.
grep ' ^[^h-r] '/etc/passwd

Input and output redirection and piping

1. Create a new file
Touch A.txt
> B.txt

2. Error redirection:2>
Find/etc-name zhaoxing.txt 2> Error.txt

3. Enter the correct or incorrect information into the Log.txt
Find/etc-name passwd >/tmp/log.txt 2>&1
Find/etc-name passwd &>/tmp/log.txt

4. Additional >>

5. Convert lowercase to uppercase (input redirection)
TR "A-Z" "A-Z" </etc/passwd

6. Automatically create files
Cat > Log.txt << EXIT
> CCC
> DDD
> EXI

7. How many files do you see in/etc?
Ls-l/etc/| grep ' ^d ' | Wc-l

8. See how many files are in/etc, and enter the file details into the Result.txt
Ls-l/etc/| grep ' ^d ' | Tee Result.txt | Wc-l

Process Control

1. Check the user's recent login status
Last
Lastlog

2. View hard Drive usage
Df

3. View File Size
Du

4. View Memory usage
Free

5. View the file system
/proc

6. View Logs
ls/var/log/

7. Check the system error log
Tail/var/log/messages

8. View the process
Top

9. End Process
Kill 1234
Kill-9 4333

Linux notes Two

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.