[Linux] Linux Command Learning (note 2)

Source: Internet
Author: User
Tags rpmbuild

 

Sualinux Account Management]

1. How to log on to the Linux host? How can you determine when you enter the account and password system?

1) first find the/etc/passwd file with this account

No: Jump out

Yes: Read the UID and GID corresponding to the account, and set the shell and Home Directory (home)

2) check whether the GID and uid password in the/etc/shadow file match.

Compliant with: log on to the system

Non-conforming: Jump out

Root UID and GID are both 0

2. passwd Construction

Column 1: Account name

Column 2: Password (replace the password with X because it is moved to etc/shadow)

Column 3: uid

Column 4: GID is related to the/etc/group file

Column 5: Description

Column 6: Home Directory

Column 7: shell: interface for communicating real actions between commands issued by humans and hardware!

3. Shadow Construction

Column 1: User Name

Column 2: Password (the first character in the password column is * indicates that the user does not need to log in.) That is to say, the administrator cannot log in as long as he adds a * password before the "disobedient" account!

[What should I do if I forget the root password ?]

Log on to the/etc/shadow file in single mode and edit the shadow file to clear the password. After logging on, use passwd and set the password.

Column 4: date of the last password change. 15274 indicates the cumulative number of days

Column 5: Number of days for Password Change

Column 6: the future is not important ............

4. Introduction to/etc/group and/etc/gshadow

Group name password the account name supported by the group ID

Just read it.

5. General steps for adding users

Groupadd-G 600 test //-G is the self-set GID size

Groupdel Test

Useradd-u 666-G 600-D/home2-s bash Tian

// Uid 666 belongs to the group where GID is 600.-D indicates the home directory.-s indicates the shell.

// When useradd is used, the system automatically copies/etc/skel to the home directory. To add the content under the Home Directory, you only need to change/etc/skel before using useradd.

6. Set the account change time, password length, password minimum, uid_min, and gid_max at/etc/login. defs.

The useradd command and Its settings are in the/etc/default/useradd file.

7. Use of the passwd command

View the storage location: Which passwd LS-l 'which passwd' is stored in/usr/bin/passwd

Passwd root Change Password as prompted

8. sudo can execute commands only by the root user.

Sudo VI/etc/shadow, but you need to enter the user's password instead of the root password.

9. query the UID gid of the Account (in addition to directly viewing it in/etc/passwd/etc/group)

Id Root

Finger root // query related information

Groups // enter the group to which the current user belongs.

(1) Routine commands: scheduled tasks

1. Answers to the questions about setting interface commands using graphical interfaces

Ntsysv // open the interface

If the RedHat prompt cannot find the command, it should be a problem with variable settings!

The solution is as follows:

1) Enter
Export Path =/usr/bin:/usr/sbin:/bin:/sbin:/usr/x11r6/bin:
Enter
In this way, you can temporarily restore the environment variable settings,
Then you can use it. Always useful
# Or $ Cd ~
Vi. bashrc or VI. bash_profile
Then write the above sentence, as if you want to add something.
Export Path =/usr/bin:/usr/sbin:/bin:/sbin:/usr/x11r6/bin $ path
The next time Bash is used, it will take effect.

2) permanent settings (not resolved)

2. At usage (one-time command)

[]/Etc/crontabcron will read this file and the following file every minute

[] When you issue a command, the command will automatically create a document named after the user name in the/var/spool/cron directory.

[] Put the executed records in:/var/log/cron

1) At-M time (for example: At-M 10 pm, the screen output result is displayed when the *** task is executed at 10 o'clock in the evening)

-M // indicates the execution result of the screen output.

Time Format: 04: 20; 4 + 3 days; executed at four o'clock P.M. three days later

1 am May 30 // executed at AM on January 1, May 30

After the time is written, this symbol will appear> write the command CTL + D to be executed to end the command

2) ATQ // view the current task

3) atrm number // delete a task. The number here is the task number Atq, which can be viewed.

3. crontab usage (commands that can be executed cyclically)

Parameter resolution:-l // list crontab content

-E // edit crontab

-R // Delete crontab content (delete all)

Example: crontab-E // enter the VI editing page

59 23 1 5 * mail tianshuai

Resolution: minute/hour/day/month/year (* indicates that everything is suitable)

Meaning: I want to send a letter to tianshuai at on January 1, May 1 each year.

// */5 run the command every 5 minutes.

The received mail is stored in the/var/spool/mail/Tianshui file.

2. Procedures and Resource Management]

1. X-window is only a set of software in Linux and cannot be regarded as an operating system.

2. Man command (manpath is searched in/etc/man. conf when the system executes the man command, and manpath is stored in/usr/share/man/usr/local/man)

, 3. Background work management

1) & run the command in the background. For example: Find/-name Test &

2) Ctrl + z background execution is not interrupted by Ctrl + C (for example, you can pause the execution when editing VI)

3) jobs Query

4) FG number // get the paused task to the foreground for execution

5) BG number // pause or run the task in the background

6) Kill Number //-9 force process interruption

7) PS-Aux // view the system process in progress.

An important column: stat: the State of the program. (r) is executable, (s) is the program sleeping, that is, it is not executed, (t) detecting or stopping. (z) the zombie program is the Dead zombie! Kill is required!

PS-l // It can also be displayed

8) Top View process // dynamic view, refresh every 5 seconds

9) free view memory usage

10) uname-A // All system information-P // CPU information-N // list host name-r // kenel version information

PS-Aux | grep crondd

Iii. Boot Process and Loader: not carefully read

4. Original code and tarball]

1), file aa.txt // view the file type and related information

2) Update the original code using patch

1. original code. Update expatch. Old

Expatch. Old

Echo tianshuai

Expatch. New

Echo tianshuai

ECHO is a student

2. Enter the command to view the differences between the two documents.

Diff-C expatch. Old expatch. New

Output:

* ** Expatch. Old 19:42:09. 000000000 + 0800 // This is awaiting update

--- Expatch. New 20:03:24. 000000000 + 0800

***************

* ** 1 ****

--- 1, 2 ----

Echo tianshuai

+ ECHO is a good student // Add code first

3, VI patch. Path

Copy the above Code

Run the command: patch-P0 <expatch. Patch

3), static Link Library lib ***.

Compilation behavior: The entire static Link Library is integrated into the execution File

Independent execution status: After compilation is successful, it can be executed independently without having to read the function library.

Upgrade difficulty: need to be compiled again

Dynamic Link Library lib ***. So

Compile behavior: only points to the dynamic function library location after compilation, not integrated into the execution File

Independent execution status: it cannot be executed independently. It is required that the function library be read and the Directory remain unchanged.

Upgrade difficulty: No need to recompile

4) verify the correctness of the software

Md5sum-BCT filename

-B // binary file reading Method

-C // check the archive fingerprint of md5sun

-T // read the archive fingerprint of md5sum in text format

Vi. rpm and srpm suite Administrator]

1), RPM (RedHat Package Manager) *******. rpm

You do not need to compile the source code of the package during installation, but you must install the package in the same environment as that of the original host. The dependency attribute requirements of the suite must be met. During installation, the suite information is written to the RPM database for future query, verification, and reverse installation.

Disadvantage: Do not remove the underlying system suite during anti-installation; otherwise, problems may occur.

2), srpm (source RedHat Package Manager) ********. SRC. rpm

A suite with source code. To install the SDK, compile it.

The advantage is that you can modify the source code before compiling.

3), detailed explanation of RPM

Rpm-I ***. RPM // during installation

-I // The meaning of Installation

-V // display details

-H // The installed information column displays the installation progress

Rpm-e *** // uninstall

Tip: can't create transaction lock on/var/lib/RPM/_ db.000

Cause: the installation is not logged on as root.

Solution: Install su root.

4) linuxqq-v1.0.2-beta1.i386.rpm

Kit name VERSION release times suitable hardware platform attachment file name

***************** ***************

5) 1, download zxvf rp-pppoe-3.10.tar.gzhttp: // www.roaringpenguin.com/pppoe/

2. It is best to run the su root command under the root identity.

3, CP/home/rp-pppoe-3.10/rp-pppoe.spec/usr/src/RedHat/sources/

CP/home/rp-pppoe-3.10.tar.gz/usr/src/RedHat/sources/

// Copy the configuration file and the compressed package to the required path for making the RPM.

4, CD/usr/src/RedHat/sources/

5, rpmbuild-BB rp-pppoe.spec <= only compiled into RPM files

Rpmbuild-Ba rp-pppoe.spec <= compile and generate both rpm and srpm files

Error: rpm build errors:

Installed (but unpackaged) file (s) found:

Solution:

In/usr/lib/RPM/macros

% __Check_files/usr/lib/RPM/check-Files % {buildroot} Comment out

Step: CD/usr/lib/RPM/then: chmod A + W macros

6. Run the rpm-IVH ******. RPM // to install your own RPM package.

[7. Differences between tarball and RPM]

The tarball is the original code. It is packaged into .tar.gz and extracted:

1. Source Code 2, detection program file (Configure/config) 3, installation instructions of the suite (install or reademe)

2. But anti-installation is very troublesome, that is, it is difficult to uninstall it.

Rpm is the installation package rpm-IVH ******. you can install rpm. The dependency may be high !!

8. Core compilation and module Management]

Concept: Compile the core original code into an executable file of binary and become an executable file that the system can recognize.

Download command: wget http://aerosol.ev.ncku.edu.tw /~ Vbird/download/linux-2.4.18.tar.gz

View kernel version: uname-R

1) Core Compilation: Put the core in this folder/usr/src/Linux

2), if there is no Linux folder. Directly put the decompressed kernel folder in the/usr/src directory. Then CD usr/src/Linux ***

3), make mrproper // remove compiled files

4). Note: If you compile the program more than twice, the module that was compiled last time will be put into/lib/modules.

CD/lib/modules

MV file. Old

5), make menuconfig // set the kernel option (here you must refer to the instructions, there are many services and hardware support must be selected)

6), start Compilation: Make Dep // establish dependency attribute relationships

Make clean // remove old data

Make bzimage // start compiling the core

Make modules // start the compilation Module

Make modules_install // install data in/lib/modules /***

Make install // install the built Core

7) Installation core: the Core compilation is completed in/usr/src/Linux/ARCH/i386/boot/bzimage.

You need to put the core in the/boot directory

CP/usr/src/Linux/ARCH/i386/boot/bzimage/boot/vmlinuz-2.4.18

9. Common commands set by the System]

1), setup // a graphical setting Interface

2) start the service immediately: start Apache

/Etc/rc. d/init. d/httpd start

[10. Recognition of system services]

1) ing between VI/etc/services // window and service

Column 1: Daemon name

Column 2: The port used by daemon and the type of network data packet transfer

Column 3: Service Description

Service ***** start // start the service

3). services enabled by the System

Netstat-r // display the current route table

Netstat-A // display the online status of all networks

Netstat-T/-u // display the status of tcp udp Packets

Netstat-l // only display the content of listen

Netstat-TLP // get the service name of the port currently in listen

Listen: port in the listening status

Established: online connection established

Time_wait: the connection is already waiting.

[11. Know logon files]

Chattr + A filename // the file cannot be operated

Chattr-a filename // file Restoration

Last // call up the login log

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.